Skip to content

💚

💚 #65

Workflow file for this run

name: code-workflow
on:
push:
branches-ignore:
- main
# 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
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-prev:
needs: [ui-chrome-desktop-tests, ui-chrome-mobile-tests]
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
- run: pnpm install -P
- run: pnpm run ci:prisma
- run: pnpm run build
- uses: amondnet/vercel-action@v25
if: startsWith(github.ref, 'refs/heads/m4/preview/')
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
vercel-org-id: ${{ secrets.ORG_ID}}
vercel-project-id: ${{ secrets.PROJECT_ID}}