Skip to content

Bump the hapi group across 1 directory with 3 updates #1331

Bump the hapi group across 1 directory with 3 updates

Bump the hapi group across 1 directory with 3 updates #1331

name: Acceptance Tests
on:
pull_request:
types: [opened, synchronize, reopened, converted_to_draft, ready_for_review]
branches:
- main
push:
branches:
- main
workflow_dispatch:
concurrency:
group: acceptance-tests-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
permissions:
checks: write
pull-requests: write
jobs:
acceptance-tests:
name: E2E Acceptance Tests
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout PR code
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: 'npm'
- name: Checkout forms-development-tools
uses: actions/checkout@v6
with:
repository: DEFRA/forms-development-tools
path: forms-development-tools
- name: Checkout forms-acceptance-tests
uses: actions/checkout@v6
with:
repository: DEFRA/forms-acceptance-tests
path: forms-acceptance-tests
- name: Start test harness
shell: bash
run: |
cd forms-development-tools/test-harness
echo "LOCALSTACK_HOST=localstack" > .env
echo "FEATURE_FLAG_PUBLISH_AUDIT_EVENTS=true" >> .env
touch secrets.env
./run-harness.sh exclude=forms-designer
- name: Build forms-designer
shell: bash
run: |
npm ci
cp designer/.automated-tests.env designer/.env
echo "=== Configuration ===" > test-logs.txt
cat designer/.env >> test-logs.txt
npm run build
- name: Start forms-designer
shell: bash
run: |
npm run dev > designer.log 2>&1 &
echo "DESIGNER_PID=$!" >> $GITHUB_ENV
- name: Wait for forms-designer to start
shell: bash
run: |
echo "Waiting for forms-designer to start..."
MAX_ATTEMPTS=30
ATTEMPT=0
while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do
if curl --output /dev/null --silent --head --fail http://localhost:3000/health; then
echo "✅ Forms-designer is ready!"
break
fi
ATTEMPT=$((ATTEMPT + 1))
echo "Attempt $ATTEMPT/$MAX_ATTEMPTS..."
sleep 2
done
if [ $ATTEMPT -eq $MAX_ATTEMPTS ]; then
echo "❌ Forms-designer failed to start"
tail -50 designer.log
exit 1
fi
- name: Run acceptance tests
id: acceptance-tests
shell: bash
run: |
cd forms-acceptance-tests
npm ci
npm run test:playwright
- name: Generate report
if: always()
shell: bash
run: |
cd forms-acceptance-tests
npm run report || true
- name: Collect logs
if: always()
shell: bash
run: |
append_container_info() {
local label="$1"
local pattern="$2"
local container_id
container_id="$(docker ps -aqf "name=${pattern}" | head -n 1)"
echo "=== ${label} logs ===" >> test-logs.txt
if [ -n "$container_id" ]; then
docker logs "$container_id" >> test-logs.txt 2>&1 || true
else
echo "Container not found" >> test-logs.txt
fi
echo "=== ${label} env vars ===" >> test-logs.txt
if [ -n "$container_id" ]; then
docker exec "$container_id" env >> test-logs.txt 2>&1 || true
else
echo "Container not found" >> test-logs.txt
fi
echo "" >> test-logs.txt
}
echo "=== Test Results ===" >> test-logs.txt
echo "" >> test-logs.txt
if [ -f forms-acceptance-tests/test-results/.last-run.json ]; then
cat forms-acceptance-tests/test-results/.last-run.json >> test-logs.txt
fi
echo "" >> test-logs.txt
echo "=== Forms-Designer Logs ===" >> test-logs.txt
if [ -f designer.log ]; then
cat designer.log >> test-logs.txt
fi
echo "" >> test-logs.txt
echo "=== Docker Containers ===" >> test-logs.txt
docker ps -a >> test-logs.txt || true
echo "=== forms-manager logs ===" >> test-logs.txt
MANAGER_ID=`docker ps -a | grep forms-manager | awk '{print $1}'`
docker logs $MANAGER_ID >> test-logs.txt || true
echo "=== forms-manager env vars ===" >> test-logs.txt
docker exec $MANAGER_ID env >> test-logs.txt || true
echo "=== forms-submission-api logs ===" >> test-logs.txt
SUBMISSION_ID=`docker ps -a | grep forms-submission-api | awk '{print $1}'`
docker logs $SUBMISSION_ID >> test-logs.txt || true
echo "=== forms-submission-api env vars ===" >> test-logs.txt
docker exec $SUBMISSION_ID env >> test-logs.txt || true
echo "=== forms-notify-listener logs ===" >> test-logs.txt
NOTIFY_ID=`docker ps -a | grep forms-notify-listener | awk '{print $1}'`
docker logs $NOTIFY_ID >> test-logs.txt || true
echo "=== forms-notify-listener env vars ===" >> test-logs.txt
docker exec $NOTIFY_ID env >> test-logs.txt || true
echo "=== forms-sharepoint-listener logs ===" >> test-logs.txt
SHAREPOINT_ID=`docker ps -a | grep forms-sharepoint-listener | awk '{print $1}'`
docker logs $SHAREPOINT_ID >> test-logs.txt || true
echo "=== forms-sharepoint-listener env vars ===" >> test-logs.txt
docker exec $SHAREPOINT_ID env >> test-logs.txt || true
echo "=== forms-audit-api logs ===" >> test-logs.txt
AUDIT_ID=`docker ps -a | grep forms-audit-api | awk '{print $1}'`
docker logs $AUDIT_ID >> test-logs.txt || true
echo "=== forms-audit-api env vars ===" >> test-logs.txt
docker exec $AUDIT_ID env >> test-logs.txt || true
echo "=== forms-runner logs ===" >> test-logs.txt
RUNNER_ID=`docker ps -a | grep forms-runner | awk '{print $1}'`
docker logs $RUNNER_ID >> test-logs.txt || true
echo "=== forms-runner env vars ===" >> test-logs.txt
docker exec $RUNNER_ID env >> test-logs.txt || true
echo "=== wiremock logs ===" >> test-logs.txt
WIREMOCK_ID=`docker ps -a | grep wiremock | awk '{print $1}'`
docker logs $WIREMOCK_ID >> test-logs.txt || true
echo "=== wiremock env vars ===" >> test-logs.txt
docker exec $WIREMOCK_ID env >> test-logs.txt || true
- name: Upload test report
if: always()
uses: actions/upload-artifact@v4
with:
name: acceptance-test-report
path: forms-acceptance-tests/allure-report
if-no-files-found: ignore
- name: Upload logs
if: always()
uses: actions/upload-artifact@v4
with:
name: test-logs
path: test-logs.txt
if-no-files-found: ignore
- name: Comment PR with results
if: github.event_name == 'pull_request' && always()
uses: actions/github-script@v7
with:
script: |
// Find existing bot comment
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('🧪 Acceptance Test Results')
);
const testOutcome = '${{ steps.acceptance-tests.outcome }}';
const testsPassed = testOutcome === 'success';
const testsRan = testOutcome === 'success' || testOutcome === 'failure';
if (testsPassed) {
// Tests passed - delete any existing failure comment
if (botComment) {
await github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
});
}
} else if (testsRan) {
// Tests ran but failed - create or update comment
const runUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
const body = `## 🧪 Acceptance Test Results\n\n` +
`### ❌ Some acceptance tests failed\n\n` +
`[View Details](${runUrl})`;
if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: body
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body
});
}
}
// If tests were skipped (testsRan is false), don't post any comment
- name: Cleanup
if: always()
shell: bash
run: |
if [ ! -z "$DESIGNER_PID" ]; then
kill $DESIGNER_PID || true
fi