Skip to content

Further exclusion of Pages directory used in Page Objects #97

Further exclusion of Pages directory used in Page Objects

Further exclusion of Pages directory used in Page Objects #97

Workflow file for this run

name: Test
on: [push, pull_request]
jobs:
Setup:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/[email protected]
with:
node-version: ${{ matrix.node-version }}
- name: Node.js modules cache
uses: actions/cache@v4
id: modules-cache
with:
path: |
~/.cache/Cypress
${{ github.workspace }}/node_modules
${{ github.workspace }}/backend/node_modules
${{ github.workspace }}/frontend/node_modules
key: ${{ runner.os }}-${{ matrix.node-version }}-modules-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
if: steps.modules-cache.outputs.cache-hit != 'true'
run: npm install
- name: Check for uncomitted changes
run: git diff --exit-code
Lint:
needs: Setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Restore cache
uses: actions/cache@v4
with:
path: |
~/.cache/Cypress
${{ github.workspace }}/node_modules
${{ github.workspace }}/backend/node_modules
${{ github.workspace }}/frontend/node_modules
key: ${{ runner.os }}-18.x-modules-${{ hashFiles('**/package-lock.json') }}
- name: Run linting and formatting checks
run: npm run test:fix
Unit-Tests:
needs: Setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Restore cache
uses: actions/cache@v4
with:
path: |
~/.cache/Cypress
${{ github.workspace }}/node_modules
${{ github.workspace }}/backend/node_modules
${{ github.workspace }}/frontend/node_modules
key: ${{ runner.os }}-18.x-modules-${{ hashFiles('**/package-lock.json') }}
- name: Run unit tests with coverage
run: |
npm run test:frontend:unit-coverage
mkdir -p ./frontend/coverage
if [ -d "./frontend/jest-coverage" ]; then
cp -R ./frontend/jest-coverage/* ./frontend/coverage/
elif [ -d "./jest-coverage" ]; then
cp -R ./jest-coverage/* ./frontend/coverage/
fi
- name: List coverage directory
run: ls -R ./frontend/coverage
- name: Upload unit test coverage
uses: actions/upload-artifact@v4
with:
name: unit-coverage
path: ./frontend/coverage
if-no-files-found: error
Get-Test-Groups:
runs-on: ubuntu-latest
outputs:
test-groups: ${{ steps.set-groups.outputs.test-groups }}
steps:
- uses: actions/checkout@v4
- id: set-groups
shell: bash
run: |
set -x # Enable debug mode to see each command
echo "Checking directory structure..."
ls -la frontend/src/__tests__/cypress/cypress/tests/ || echo "Base test directory not found"
if [ -d "frontend/src/__tests__/cypress/cypress/tests/mocked" ]; then
echo "Found mocked tests directory"
# Get directories and create JSON array - force compact output with -c
DIRS=$(cd frontend/src/__tests__/cypress/cypress/tests/mocked && \
find . -maxdepth 1 -mindepth 1 -type d -printf "%f\n" | \
jq -R . | jq -c -s .)
# Output in the correct format for GitHub Actions
echo "test-groups=$DIRS" >> "$GITHUB_OUTPUT"
echo "Generated test groups:"
cat "$GITHUB_OUTPUT"
else
echo "No mocked tests directory found, using default"
echo "test-groups=[\"default\"]" >> "$GITHUB_OUTPUT"
fi
Cypress-Mock-Tests:
needs: [Setup, Get-Test-Groups, Unit-Tests, Lint]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test-group: ${{ fromJson(needs.Get-Test-Groups.outputs.test-groups) }}
steps:
- uses: actions/checkout@v4
- name: Restore cache
uses: actions/cache@v4
with:
path: |
~/.cache/Cypress
${{ github.workspace }}/node_modules
${{ github.workspace }}/backend/node_modules
${{ github.workspace }}/frontend/node_modules
key: ${{ runner.os }}-18.x-modules-${{ hashFiles('**/package-lock.json') }}
- name: Run Cypress Mock tests
run: |
if [ "${{ matrix.test-group }}" == "default" ]; then
npm run test:cypress-ci
else
npm run test:cypress-ci -- --spec "src/__tests__/cypress/cypress/tests/mocked/${{ matrix.test-group }}/**/*"
fi
working-directory: ./frontend
- name: Upload Cypress Mock results
uses: actions/upload-artifact@v4
with:
name: cypress-results-${{ matrix.test-group }}
path: ./frontend/src/__tests__/cypress/results/mocked
Combine-Results-and-Upload:
needs: [Unit-Tests, Cypress-Mock-Tests]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: all-artifacts
- name: Combine coverage reports
run: |
mkdir -p ./frontend/coverage
cp -R all-artifacts/unit-coverage/* ./frontend/coverage/
find all-artifacts -type d \( -name "__mocks__" -o -name "__tests__" -o -name "pages" \) -prune -o \
-name "*.json" -o -name "*.lcov" | while read file; do
cp "$file" ./frontend/coverage/ || true
done
- name: Upload combined results
uses: actions/upload-artifact@v4
with:
name: combined-test-results
path: ./frontend/coverage/
- name: Upload coverage to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
name: frontend
directory: ./frontend/coverage
verbose: true
- uses: actions/upload-artifact@v4
if: always()
with:
name: cypress-results
path: ./frontend/src/__tests__/cypress/results/