Merge pull request #119 from danigonzser/m4/preview/ultimos_detalles #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Code test + deploy to production | |
on: | |
push: | |
branches: | |
- master | |
paths: | |
- "src/**/*.tsx" | |
- "src/**/*.ts" | |
- "cypress/**/*.ts" | |
jobs: | |
build-cache: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install pnpm | |
uses: pnpm/action-setup@v4 | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
cache: "pnpm" | |
cache-dependency-path: ./pnpm-lock.yaml | |
- name: Build Caching | |
uses: actions/cache@v4 | |
with: | |
path: | | |
node_modules | |
${{ github.workspace }}/.next/cache | |
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }} | |
restore-keys: | | |
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}- | |
- run: pnpm install && pnpm prisma generate | |
- run: pnpm run build | |
- name: Build Caching | |
uses: actions/cache@v4 | |
with: | |
path: | | |
node_modules | |
${{ github.workspace }}/.next/cache | |
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }} | |
restore-keys: | | |
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}- | |
unit-tests: | |
timeout-minutes: 15 | |
runs-on: ubuntu-latest | |
container: | |
image: cypress/browsers:node-20.18.0-chrome-129.0.6668.89-1-ff-131.0.2-edge-129.0.2792.65-1 | |
options: --user 1001 | |
strategy: | |
fail-fast: false | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install pnpm | |
uses: pnpm/action-setup@v4 | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
cache: "pnpm" | |
cache-dependency-path: ./pnpm-lock.yaml | |
- name: "Unit tests" | |
uses: cypress-io/github-action@v6 | |
with: | |
browser: chrome | |
spec: cypress/unit/* | |
config-file: cypress.config.ts | |
env: | |
POSTGRES_PRISMA_URL: postgresql://postgres:postgres@postgres:5432/proyecto-tfg | |
POSTGRES_URL_NON_POOLING: postgresql://postgres:postgres@postgres:5432/proyecto-tfg | |
ui-chrome-desktop-tests: | |
needs: build-cache | |
timeout-minutes: 15 | |
runs-on: ubuntu-latest | |
container: | |
image: cypress/browsers:node-20.18.0-chrome-129.0.6668.89-1-ff-131.0.2-edge-129.0.2792.65-1 | |
options: --user 1001 | |
strategy: | |
fail-fast: false | |
services: | |
postgres: | |
image: postgres | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install pnpm | |
uses: pnpm/action-setup@v4 | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
cache: "pnpm" | |
cache-dependency-path: ./pnpm-lock.yaml | |
- name: Build Caching | |
uses: actions/cache@v4 | |
with: | |
path: | | |
node_modules | |
${{ github.workspace }}/.next/cache | |
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }} | |
restore-keys: | | |
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}- | |
- run: pnpm install | |
- run: pnpm run ci:prisma | |
- run: pnpm run build | |
- name: "UI Desktop Tests - Chrome" | |
uses: cypress-io/github-action@v6 | |
with: | |
start: pnpm run start | |
wait-on: "http://localhost:3000" | |
wait-on-timeout: 120 | |
browser: chrome | |
spec: cypress/e2e/* | |
config-file: cypress.config.ts | |
- uses: actions/upload-artifact@v4 | |
if: failure() | |
with: | |
name: cypress-screenshots | |
path: cypress/snapshot/actual | |
if-no-files-found: ignore # 'warn' or 'error' are also available, defaults to `warn` | |
- name: Build Caching | |
uses: actions/cache@v4 | |
with: | |
path: | | |
node_modules | |
${{ github.workspace }}/.next/cache | |
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }} | |
restore-keys: | | |
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}- | |
env: | |
POSTGRES_PRISMA_URL: postgresql://postgres:postgres@postgres:5432/proyecto-tfg | |
POSTGRES_URL_NON_POOLING: postgresql://postgres:postgres@postgres:5432/proyecto-tfg | |
ui-chrome-mobile-tests: | |
needs: build-cache | |
timeout-minutes: 15 | |
runs-on: ubuntu-latest | |
container: | |
image: cypress/browsers:node-20.18.0-chrome-129.0.6668.89-1-ff-131.0.2-edge-129.0.2792.65-1 | |
options: --user 1001 | |
strategy: | |
fail-fast: false | |
services: | |
postgres: | |
image: postgres | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install pnpm | |
uses: pnpm/action-setup@v4 | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
cache: "pnpm" | |
cache-dependency-path: ./pnpm-lock.yaml | |
- name: Build Caching | |
uses: actions/cache@v4 | |
with: | |
path: | | |
node_modules | |
${{ github.workspace }}/.next/cache | |
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }} | |
restore-keys: | | |
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}- | |
- run: pnpm install | |
- run: pnpm run ci:prisma | |
- run: pnpm run build | |
- name: "UI Tests - Chrome - Mobile" | |
uses: cypress-io/github-action@v6 | |
with: | |
config: '{"e2e":{"viewportWidth":375,"viewportHeight":667}}' | |
start: pnpm run start | |
wait-on: "http://localhost:3000" | |
wait-on-timeout: 120 | |
browser: chrome | |
spec: cypress/e2e/mobile/* | |
config-file: cypress.config.ts | |
- uses: actions/upload-artifact@v4 | |
if: failure() | |
with: | |
name: cypress-mobile-screenshots | |
path: cypress/snapshot/actual | |
if-no-files-found: ignore # 'warn' or 'error' are also available, defaults to `warn` | |
- name: Build Caching | |
uses: actions/cache@v4 | |
with: | |
path: | | |
node_modules | |
${{ github.workspace }}/.next/cache | |
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }} | |
restore-keys: | | |
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}- | |
env: | |
POSTGRES_PRISMA_URL: postgresql://postgres:postgres@postgres:5432/proyecto-tfg | |
POSTGRES_URL_NON_POOLING: postgresql://postgres:postgres@postgres:5432/proyecto-tfg | |
deploy-preview: | |
needs: [ui-chrome-desktop-tests, ui-chrome-mobile-tests] | |
runs-on: ubuntu-latest | |
environment: Production | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install pnpm | |
uses: pnpm/action-setup@v4 | |
- name: Deploy to Vercel Action | |
uses: BetaHuhn/deploy-to-vercel-action@v1 | |
with: | |
PRODUCTION: true | |
GITHUB_DEPLOYMENT_ENV: Production | |
GITHUB_TOKEN: ${{ github.token }} | |
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} | |
VERCEL_ORG_ID: ${{ secrets.ORG_ID_VERCEL }} | |
VERCEL_PROJECT_ID: ${{ secrets.PROJECT_ID_VERCEL }} |