-
Notifications
You must be signed in to change notification settings - Fork 4
84 lines (78 loc) · 3 KB
/
acceptance-test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
---
name: Acceptance Test
on:
workflow_call:
inputs:
flavor:
required: true
type: string
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v9.0.1
with:
egress-policy: audit
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
# Create a GitHub Codespace and communicate the image version via a Codespace secret (should be a Codespace environment variable).
# This secret is used by devcontainer.json, as such it is a resource that should not be used concurrently.
- name: Start Codespace
run: |
set -Eeuo pipefail
gh secret set -a codespaces IMAGE_VERSION --body "pr-${{ github.event.pull_request.number }}"
echo CODESPACE_NAME="$(gh codespace create -R "${{ github.repository }}" -b "$HEAD_REF" -m basicLinux32gb --devcontainer-path ".devcontainer/${{ inputs.flavor }}-test/devcontainer.json" --idle-timeout 10m --retention-period 1h)" >> "$GITHUB_ENV"
env:
GH_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }}
HEAD_REF: ${{ github.head_ref }}
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: 20
- run: npm ci
- run: npx playwright install --with-deps
- name: Wait for Codespace to be active
run: |
set -Eeuo pipefail
MAX_WAIT_SECONDS=$((3 * 60))
SECONDS_ELAPSED=0
while true; do
STATE=$(gh codespace list --json name,state --jq ".[] | select(.name == \"$CODESPACE_NAME\") | .state")
echo "Current state: $STATE"
if [ "$STATE" == "Available" ]; then
echo "Codespace is active!"
break
fi
if [ $SECONDS_ELAPSED -ge $MAX_WAIT_SECONDS ]; then
echo "Timeout reached. Codespace is not active."
exit 1
fi
sleep 5
SECONDS_ELAPSED=$((SECONDS_ELAPSED + 5))
done
env:
GH_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }}
- run: cd test/${{ inputs.flavor }}/features && npm test
env:
GITHUB_USER: ${{ secrets.TEST_GITHUB_USER }}
GITHUB_PASSWORD: ${{ secrets.TEST_GITHUB_PASSWORD }}
GITHUB_TOTP_SECRET: ${{ secrets.TEST_GITHUB_TOTP_SECRET }}
- uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
if: always()
with:
name: playwright-artifacts
path: |
test-results/
retention-days: 10
- run: |
set -Eeuo pipefail
gh codespace delete --force --codespace "$CODESPACE_NAME"
gh secret set -a codespaces IMAGE_VERSION --body "latest"
if: always()
env:
GH_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }}