Skip to content

Move PR tests to GitHub Actions #2624

Move PR tests to GitHub Actions

Move PR tests to GitHub Actions #2624

Workflow file for this run

name: CI
on:
pull_request:
env:
NODE_ENV: test
API_CLIENT_ID: approved-premises
API_CLIENT_SECRET: clientsecret
jobs:
type_checking:
name: "Type check 🔎"
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/[email protected]
- name: Setup Node.js environment
uses: actions/[email protected]
with:
node-version-file: '.node-version'
cache: 'npm'
- name: Installing dependencies
run: npm ci
- name: Pulling the latest type from the API repo
run: npm run generate-types
- name: Typechecking the code
run: npm run typecheck
linting:
name: "Linting 🔎"
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/[email protected]
- name: Setup Node.js environment
uses: actions/[email protected]
with:
node-version-file: '.node-version'
cache: 'npm'
- name: Installing dependencies
run: npm ci
- name: Running Lint checks
run: npm run lint
- name: Running shell scripts linting checks
run: npm run shellcheck
unit_test:
name: "Unit testing 🧪"
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/[email protected]
- name: Setup Node.js environment
uses: actions/[email protected]
with:
node-version-file: '.node-version'
cache: 'npm'
- name: Installing dependencies
run: npm ci
- name: Running Unit tests
run: npm run test:ci
- name: Check coverage
run: |
npx nyc report -t ./coverage --reporter=text --reporter=text-summary
npx nyc check-coverage -t ./coverage
integration_test:
name: "Integration testing 🧪"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ci_node_index: [ 0, 1, 2, 3 ]
steps:
- name: Check out code
uses: actions/[email protected]
- name: Setup Node.js environment
uses: actions/[email protected]
with:
node-version-file: '.node-version'
cache: 'npm'
- name: Installing dependencies
run: npm ci
- name: Building source
run: npm run build
- uses: dawidd6/action-download-artifact@v2
with:
#branch: main
if_no_artifact_found: 'ignore'
allow_forks: false
name: integration-test-junit-xml-reports-.*
name_is_regexp: true
path: tmp/junit-xml-reports-downloaded
continue-on-error: true
- uses: r7kamura/split-tests-by-timings@v0
id: split-tests
with:
reports: tmp/junit-xml-reports-downloaded
glob: integration_tests/tests/**/*.cy.ts
index: ${{ matrix.ci_node_index }}
total: 4
- name: Running Integration tests
run: TEST_RUN_ARGS="--spec $(echo ${{ steps.split-tests.outputs.paths }} | sed -E 's/ /,/g')" npm run test:integration
- name: Store Integration tests reports
uses: actions/upload-artifact@v4
with:
name: integration-test-junit-xml-reports-${{ matrix.ci_node_index }}
path: test_results/cypress
- name: Store Integration tests videos
uses: actions/upload-artifact@v4
with:
name: integration-tests-videos-${{ matrix.ci_node_index }}
path: integration_tests/videos
- name: Store Integration tests screenshots
uses: actions/upload-artifact@v4
with:
name: integration-tests-screenshots-${{ matrix.ci_node_index }}
path: integration_tests/screenshots