undergroundwires/privacy.sexy

View on GitHub
.github/workflows/tests.e2e.yaml

Summary

Maintainability
Test Coverage
name: e2e-tests

on:
  push:
  pull_request:

jobs:
  run-tests:
    strategy:
      matrix:
        os: [macos, ubuntu, windows]
      fail-fast: false # So it still runs on other OSes if one of them fails
    runs-on: ${{ matrix.os }}-latest
    steps:
      -
        name: Checkout
        uses: actions/checkout@v4
      -
        name: Setup node
        uses: ./.github/actions/setup-node
      -
        name: Install dependencies
        uses: ./.github/actions/npm-install-dependencies
      -
        name: Run e2e tests
        run: npm run test:cy:run
      -
        name: Output artifact directories
        id: artifacts
        if: always() # Run even if previous steps fail because test run video is always captured
        shell: bash
        run: |-
          declare -r dirs_json_file='cypress-dirs.json'
          if [ ! -f "${dirs_json_file}" ]; then
            echo "${dirs_json_file} does not exist"
            exit 1
          fi

          SCREENSHOTS_DIR=$(jq -r '.screenshots' "${dirs_json_file}")
          VIDEOS_DIR=$(jq -r '.videos' "${dirs_json_file}")

          for dir in "${SCREENSHOTS_DIR}" "${VIDEOS_DIR}"; do
            if [ "${dir}" = 'null' ] || [ -z "${dir}" ]; then
              echo "One or more directories are null or not specified in cypress-dirs.json"
              exit 1
            fi
          done

          echo "SCREENSHOTS_DIR=${SCREENSHOTS_DIR}" >> "${GITHUB_OUTPUT}"
          echo "VIDEOS_DIR=${VIDEOS_DIR}" >> "${GITHUB_OUTPUT}"
      -
        name: Upload screenshots
        if: failure() # Run only if previous steps fail because screenshots will be generated only if E2E test failed
        uses: ./.github/actions/upload-artifact
        with:
          name: e2e-screenshots-${{ matrix.os }}
          path: ${{ steps.artifacts.outputs.SCREENSHOTS_DIR }}
      -
        name: Upload videos
        if: always() # Run even if previous steps fail because test run video is always captured
        uses: ./.github/actions/upload-artifact
        with:
          name: e2e-videos-${{ matrix.os }}
          path: ${{ steps.artifacts.outputs.VIDEOS_DIR }}