Vizzuality/landgriffon

View on GitHub
.github/workflows/testing-client.yml

Summary

Maintainability
Test Coverage
name: Client Tests

on:
  push:
    paths:
      - 'client/**'
      - '.github/workflows/testing-client.yml'

  workflow_dispatch:

env:
  NODE_ENV: production

jobs:
  testing-client:
    name: Running client tests
    runs-on: ubuntu-22.04
    timeout-minutes: 30
    if: ${{ github.ref_name != 'test' }}
    strategy:
      fail-fast: false
    defaults:
      run:
        working-directory: ${{github.workspace}}/client
    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Use Node.js 18.13
        uses: actions/setup-node@v3
        with:
          node-version-file: 'client/.nvmrc'
          cache: 'yarn'
          cache-dependency-path: client/yarn.lock

      - name: Install dependencies
        run: yarn install --immutable

      - name: Cypress run
        uses: cypress-io/github-action@v5
        with:
          record: true
          working-directory: client
          install: false
          build: yarn build
          start: yarn start
          browser: chrome
          wait-on: http://localhost:3000/auth/signin
          config-file: cypress.config.ts
          command-prefix: yarn dlx
          command: "yarn test:e2e"
        env:
          NEXT_PUBLIC_API_URL: ${{ secrets.CYPRESS_API_URL }}
          NEXT_TELEMETRY_DISABLED: 1
          NEXTAUTH_URL: http://localhost:3000
          NEXTAUTH_SECRET: nyanpony
          CYPRESS_USERNAME: ${{ secrets.CYPRESS_USERNAME }}
          CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }}
          CYPRESS_API_URL: ${{ secrets.CYPRESS_API_URL }}
          # pass GitHub token to detect new build vs re-run build
          GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
          DEBUG: "cypress:server:args"

      - uses: actions/upload-artifact@v3
        if: failure()
        with:
          name: cypress-screenshots
          path: ${{github.workspace}}/client/cypress/screenshots