Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
a4fb94c
HOTE-541: Add playwright scripts to CI
mikeeq Feb 16, 2026
a30d19b
Add package-lock.json for tests
mikeeq Feb 16, 2026
90295cf
Add package-lock.json for tests v2
mikeeq Feb 16, 2026
212d10c
Add package-lock.json for tests v3
mikeeq Feb 16, 2026
d09eb2d
Add package-lock.json for tests v4
mikeeq Feb 16, 2026
9708df7
Add coverage report
mikeeq Feb 16, 2026
24aa08f
Add coverage report v2
mikeeq Feb 16, 2026
d3c4ee3
add lambdas eslint
mikeeq Feb 16, 2026
52b9df0
add lambdas eslint v2
mikeeq Feb 16, 2026
20dab4a
Fix all eslint issues
mikeeq Feb 16, 2026
dc515aa
remove eslint from pre-commit
mikeeq Feb 16, 2026
7821d30
Add lambdas unit tests
mikeeq Feb 16, 2026
de890a2
Add lambdas unit tests v2
mikeeq Feb 16, 2026
eb457dc
Fix test
mikeeq Feb 16, 2026
6814d14
Fix test v2
mikeeq Feb 16, 2026
d10d39b
Fix test v3
mikeeq Feb 16, 2026
5d4a509
Fix test v4
mikeeq Feb 16, 2026
b3453e8
Merge branch 'main' of github.com:NHSDigital/hometest-service into fe…
mikeeq Feb 17, 2026
cf8cdd8
cleanup
mikeeq Feb 17, 2026
7162be8
Fix sqlfluff raised issues
mikeeq Feb 17, 2026
77970a0
revert github actions changes
mikeeq Feb 17, 2026
6051576
cleanup v3
mikeeq Feb 17, 2026
e475fd9
cleanup v4
mikeeq Feb 17, 2026
501cbb6
add colored output to unit tests
mikeeq Feb 18, 2026
c7cae01
update packages
mikeeq Feb 18, 2026
80958a1
update packages v2
mikeeq Feb 18, 2026
8bf583c
update packages v3
mikeeq Feb 18, 2026
f09ed38
run tests via mise
mikeeq Feb 18, 2026
62a02f0
Add missing uuid package
mikeeq Feb 18, 2026
bca8b1c
Add tests eslint
mikeeq Feb 18, 2026
b18713d
Add tests npm deps install
mikeeq Feb 18, 2026
793692d
add additional output and remove double npm deps install
mikeeq Feb 18, 2026
c479166
fix running tests
mikeeq Feb 18, 2026
37e4c36
Add private key for nhs login
mikeeq Feb 18, 2026
58f2f8c
Add private key for nhs login v2
mikeeq Feb 18, 2026
78363d1
fix running tests v4
mikeeq Feb 18, 2026
2cacdbf
fix running tests v5
mikeeq Feb 18, 2026
cfb6c4d
Move start app just before playwright tests
mikeeq Feb 18, 2026
a59ad84
Move start app just before playwright tests v2
mikeeq Feb 18, 2026
82aefeb
run only tests on chrome
mikeeq Feb 18, 2026
7a1c1a2
run only tests on chrome v2
mikeeq Feb 18, 2026
6532271
run only tests on chrome v3
mikeeq Feb 18, 2026
6733fe9
add wait for ui
mikeeq Feb 18, 2026
b517e56
add grabbing logs
mikeeq Feb 18, 2026
c864e73
Merge branch 'main' of github.com:NHSDigital/hometest-service into fe…
mikeeq Feb 18, 2026
41de93b
Fix failing test
mikeeq Feb 18, 2026
4b2780c
Run e2e as separate pipeline
mikeeq Feb 18, 2026
894253f
Run e2e as separate pipeline v2
mikeeq Feb 18, 2026
fb53a41
Run e2e as separate pipeline v3
mikeeq Feb 18, 2026
997c557
Run it daily
mikeeq Feb 18, 2026
43f6d6d
Add junit report
mikeeq Feb 18, 2026
1d39f80
Add junit report v2
mikeeq Feb 18, 2026
26fbf9e
Add default browser
mikeeq Feb 18, 2026
3d889a7
Add default browser v2
mikeeq Feb 18, 2026
2d1cd9b
remove pr trigger
mikeeq Feb 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/actions/init-mise/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
name: "Initialize mise"
description: "Initialize mise"
runs:
using: "composite"
steps:
- name: Configure git
shell: bash
run: |
echo "::group::Configure git"
git config --global --add safe.directory '*'
echo "::endgroup::"

- name: Install mise
uses: jdx/mise-action@v3
with:
cache: true
install: true

- name: Cache node_modules
uses: actions/cache@v5
with:
path: |
node_modules
ui/node_modules
lambdas/node_modules
tests/node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
node-modules-${{ runner.os }}-

- name: Install npm dependencies
shell: bash
run: |
echo "::group::Install npm dependencies"
mise run install-npm
echo "::endgroup::"
17 changes: 0 additions & 17 deletions .github/actions/perform-pre-commit/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,6 @@ description: "Perform pre-commit checks"
runs:
using: "composite"
steps:
- name: Configure git
shell: bash
run: |
echo "::group::Configure git"
git config --global --add safe.directory '*'
echo "::endgroup::"

- name: Install mise
uses: jdx/mise-action@v3
with:
cache: true
install: true

- name: Cache pre-commit hooks
uses: actions/cache@v5
with:
Expand All @@ -32,10 +19,6 @@ runs:
mise exec -- pre-commit install --install-hooks
echo "::endgroup::"

echo "::group::Install npm dependencies"
mise run install-npm
echo "::endgroup::"

- name: Run pre-commit
shell: bash
run: |
Expand Down
17 changes: 4 additions & 13 deletions .github/actions/run-npm-tests/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,11 @@ inputs:
runs:
using: "composite"
steps:
- name: "Setup Node.js"
uses: actions/setup-node@v6
with:
node-version: "${{ inputs.nodejs-version }}"
cache: npm
cache-dependency-path: ${{ inputs.working-directory }}/package-lock.json

- name: "Install dependencies"
shell: bash
run: npm --prefix ${{ inputs.working-directory }} ci

- name: "Run test suite"
shell: bash
run: npm --prefix ${{ inputs.working-directory }} run test -- --ci
run: mise exec -- npm --prefix ${{ inputs.working-directory }} run test -- --ci
env:
FORCE_COLOR: true

- name: "Upload test results"
uses: actions/upload-artifact@v4
Expand All @@ -57,7 +48,7 @@ runs:
retention-days: 30

- name: "Test Report"
uses: dorny/test-reporter@v1
uses: dorny/test-reporter@v2
if: always()
with:
name: "${{ inputs.test-name }}"
Expand Down
168 changes: 168 additions & 0 deletions .github/workflows/playwright-e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
---
name: "Playwright E2E Tests"

on:
schedule:
- cron: '0 2 * * *' # Every day at 2am UTC
workflow_dispatch:
inputs:
browser:
description: "Browser to run tests on"
required: false
default: "chromium"
type: choice
options:
- chromium
- firefox
- webkit
- all
test_filter:
description: "Test filter pattern (e.g., 'HomeTest' or leave empty for all)"
required: false
default: ""
type: string

jobs:
test-playwright:
name: "Playwright E2E tests"
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: "Checkout code"
uses: actions/checkout@v6

- name: "Install mise"
uses: jdx/mise-action@v3
with:
install: true
cache: true

- name: "Install Playwright browsers"
working-directory: tests
run: npx playwright install --with-deps

- name: "Create nhs login private key file"
run: |
mkdir -p local-environment/infra/resources/secrets
cat > local-environment/infra/resources/secrets/nhs-login-private-key.pem << 'EOF'
${{ secrets.NHS_LOGIN_PRIVATE_KEY }}
EOF

- name: "Create credentials file"
working-directory: tests
run: |
cat > credentials.ts << 'EOF'
export const userPasswordGeneric = '${{ secrets.PLAYWRIGHT_PASSWORD }}';
export const OTP = '${{ secrets.PLAYWRIGHT_OTP }}';
EOF

- name: "Start the application"
run: |
npm run start

- name: "Show application status"
run: |
docker compose -f local-environment/docker-compose.yml ps
docker logs ui

- name: "Get terraform outputs"
id: terraform
run: |
UI_URL=$(terraform -chdir=local-environment/infra output -raw ui_url)
API_URL=$(terraform -chdir=local-environment/infra output -raw api_base_url)
echo "ui_url=$UI_URL" >> $GITHUB_OUTPUT
echo "api_base_url=$API_URL" >> $GITHUB_OUTPUT
echo "UI URL: $UI_URL"
echo "API URL: $API_URL"

- name: "Wait for UI to be reachable"
run: |
UI_URL="${{ steps.terraform.outputs.ui_url }}"
echo "Waiting for UI to be reachable at $UI_URL..."
timeout=120
elapsed=0
until curl -sf "$UI_URL" > /dev/null 2>&1; do
if [ $elapsed -ge $timeout ]; then
echo "Timeout: UI not reachable after ${timeout}s"
docker logs ui
exit 1
fi
echo "Waiting... (${elapsed}s)"
sleep 5
elapsed=$((elapsed + 5))
done
echo "UI is reachable!"

- name: "Run Playwright tests"
working-directory: tests
run: |
BROWSER="${{ inputs.browser }}"
BROWSER="${BROWSER:-chromium}"
FILTER="${{ inputs.test_filter }}"

# Build the command
CMD="npx playwright test"

# Add browser project
if [ "$BROWSER" != "all" ]; then
CMD="$CMD --project=$BROWSER"
fi

# Add filter if provided
if [ -n "$FILTER" ]; then
CMD="$CMD --grep \"$FILTER\""
fi

echo "Running: $CMD"
eval $CMD
env:
CI: true
FORCE_COLOR: true
UI_BASE_URL: ${{ steps.terraform.outputs.ui_url }}
API_BASE_URL: ${{ steps.terraform.outputs.api_base_url }}

- name: "Grab docker compose logs"
run: |
for service in $(docker compose -f local-environment/docker-compose.yml ps --services); do
docker compose -f local-environment/docker-compose.yml logs "$service" > "tests/testResults/docker-compose-${service}.log" 2>&1
done
if: always()

- name: "Publish Test Results"
uses: dorny/test-reporter@v2
if: always()
with:
name: Playwright Test Results
path: tests/testResults/junit-results.xml
reporter: java-junit
fail-on-error: false

- name: "Generate Job Summary"
if: always()
run: |
echo "## Playwright Test Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ -f tests/testResults/junit-results.xml ]; then
TESTS=$(grep -oP 'tests="\K[0-9]+' tests/testResults/junit-results.xml | head -1)
FAILURES=$(grep -oP 'failures="\K[0-9]+' tests/testResults/junit-results.xml | head -1)
ERRORS=$(grep -oP 'errors="\K[0-9]+' tests/testResults/junit-results.xml | head -1)
TIME=$(grep -oP 'time="\K[0-9.]+' tests/testResults/junit-results.xml | head -1)
PASSED=$((TESTS - FAILURES - ERRORS))
echo "| Metric | Value |" >> $GITHUB_STEP_SUMMARY
echo "|--------|-------|" >> $GITHUB_STEP_SUMMARY
echo "| Total Tests | $TESTS |" >> $GITHUB_STEP_SUMMARY
echo "| :white_check_mark: Passed | $PASSED |" >> $GITHUB_STEP_SUMMARY
echo "| :x: Failed | $FAILURES |" >> $GITHUB_STEP_SUMMARY
echo "| :warning: Errors | $ERRORS |" >> $GITHUB_STEP_SUMMARY
echo "| :stopwatch: Duration | ${TIME}s |" >> $GITHUB_STEP_SUMMARY
else
echo ":warning: No test results found" >> $GITHUB_STEP_SUMMARY
fi

- name: "Upload test results"
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: tests/testResults/
retention-days: 30
2 changes: 2 additions & 0 deletions .github/workflows/stage-1-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Initialize mise
uses: ./.github/actions/init-mise
- name: Run pre-commit checks
uses: ./.github/actions/perform-pre-commit
82 changes: 82 additions & 0 deletions .github/workflows/stage-2-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ jobs:
steps:
- name: "Checkout code"
uses: actions/checkout@v6
- name: Initialize mise
uses: ./.github/actions/init-mise
- name: "Run UI tests"
uses: ./.github/actions/run-npm-tests
with:
Expand All @@ -58,6 +60,8 @@ jobs:
steps:
- name: "Checkout code"
uses: actions/checkout@v6
- name: Initialize mise
uses: ./.github/actions/init-mise
- name: "Run Lambda tests"
uses: ./.github/actions/run-npm-tests
with:
Expand All @@ -78,6 +82,84 @@ jobs:
- name: "Save the coverage check result"
run: |
echo "Nothing to save"

# test-playwright:
# name: "Playwright E2E tests"
# needs: [test-unit-ui, test-unit-lambda]
# runs-on: ubuntu-latest
# timeout-minutes: 30
# steps:
# - name: "Checkout code"
# uses: actions/checkout@v6
# - name: "Install mise"
# uses: jdx/mise-action@v3
# with:
# install: true
# cache: true
# - name: "Install Playwright browsers"
# working-directory: tests
# run: npx playwright install --with-deps
# - name: "Create nhs login private key file"
# run: |
# mkdir -p local-environment/infra/resources/secrets
# cat > local-environment/infra/resources/secrets/nhs-login-private-key.pem << 'EOF'
# ${{ secrets.NHS_LOGIN_PRIVATE_KEY }}
# EOF
# - name: "Create credentials file"
# working-directory: tests
# run: |
# cat > credentials.ts << 'EOF'
# export const userPasswordGeneric = '${{ secrets.PLAYWRIGHT_PASSWORD }}';
# export const OTP = '${{ secrets.PLAYWRIGHT_OTP }}';
# EOF
# - name: "Start the application"
# run: |
# npm run start

# - name: "Show application status"
# run: |
# docker compose -f local-environment/docker-compose.yml ps
# docker logs ui

# - name: "Wait for UI to be reachable"
# run: |
# echo "Waiting for UI to be reachable at http://localhost:3000..."
# timeout=120
# elapsed=0
# until curl -sf http://localhost:3000 > /dev/null 2>&1; do
# if [ $elapsed -ge $timeout ]; then
# echo "Timeout: UI not reachable after ${timeout}s"
# docker logs ui
# exit 1
# fi
# echo "Waiting... (${elapsed}s)"
# sleep 5
# elapsed=$((elapsed + 5))
# done
# echo "UI is reachable!"

# - name: "Run Playwright tests"
# # working-directory: tests
# run: npm run test:playwright
# env:
# CI: true
# # BASE_URL: ${{ vars.TEST_BASE_URL }}
# FORCE_COLOR: true
# - name: "Grab docker compose logs"
# run: |
# for service in $(docker compose -f local-environment/docker-compose.yml ps --services); do
# docker compose -f local-environment/docker-compose.yml logs "$service" > "tests/testResults/docker-compose-${service}.log" 2>&1
# done
# if: always()

# - name: "Upload test results"
# uses: actions/upload-artifact@v4
# if: always()
# with:
# name: playwright-report
# path: tests/testResults/
# retention-days: 30

perform-static-analysis:
name: "Perform static analysis"
needs: [test-unit-ui, test-unit-lambda]
Expand Down
Loading
Loading