Skip to content

Commit 0ff1d1d

Browse files
authored
chore: Update e2e test runs (#49)
* Update actions * Run tests if labeled * Add NEXT_TEST_JOB * ignore scripts for faster install * Show test results in summary and fail action if errors
1 parent 8c9532d commit 0ff1d1d

File tree

1 file changed

+27
-14
lines changed

1 file changed

+27
-14
lines changed

Diff for: .github/workflows/test-e2e.yml

+27-14
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: run e2e tests
22

33
on:
44
workflow_dispatch:
5+
pull_request:
6+
types: [opened, synchronize, reopened, labeled]
57

68
env:
79
NODE_VERSION: 18.16.1
@@ -10,6 +12,7 @@ env:
1012
NEXT_VERSION: netlify-testing
1113
NEXT_TEST_MODE: deploy
1214
NEXT_E2E_TEST_TIMEOUT: 600000
15+
NEXT_TEST_JOB: true
1316
TEST_CONCURRENCY: 8
1417
NEXT_TELEMETRY_DISABLED: 1
1518
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
@@ -20,6 +23,7 @@ env:
2023

2124
jobs:
2225
test-e2e:
26+
if: ${{ github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'run-e2e-tests') }}
2327
name: test e2e
2428
runs-on: ubuntu-latest
2529
timeout-minutes: 25
@@ -35,6 +39,8 @@ jobs:
3539
test/e2e/favicon-short-circuit/favicon-short-circuit.test.ts
3640
3741
steps:
42+
- name: 'Setup jq'
43+
uses: dcarbone/[email protected]
3844
- name: get github token
3945
uses: navikt/github-app-token-generator@v1
4046
id: token
@@ -44,20 +50,20 @@ jobs:
4450
repo: ${{ env.NEXT_REPO }}
4551

4652
- name: checkout next.js repo
47-
uses: actions/checkout@v3
53+
uses: actions/checkout@v4
4854
with:
4955
repository: ${{ env.NEXT_REPO }}
5056
token: ${{ steps.token.outputs.token }}
5157
ref: ${{ env.NEXT_VERSION }}
5258
path: ${{ env.next-path }}
5359

5460
- name: checkout runtime repo
55-
uses: actions/checkout@v3
61+
uses: actions/checkout@v4
5662
with:
5763
path: ${{ env.runtime-path }}
5864

5965
- name: setup node
60-
uses: actions/setup-node@v3
66+
uses: actions/setup-node@v4
6167
with:
6268
node-version: ${{ env.NODE_VERSION }}
6369

@@ -97,7 +103,7 @@ jobs:
97103
working-directory: ${{ env.next-path }}
98104

99105
- name: install runtime
100-
run: npm install
106+
run: npm install --ignore-scripts
101107
working-directory: ${{ env.runtime-path }}
102108

103109
- name: build runtime
@@ -121,13 +127,20 @@ jobs:
121127
NEXT_EXTERNAL_TESTS_FILTERS: ./tests.json
122128
run: node run-tests.js -g ${{ matrix.group }}/5 -c ${TEST_CONCURRENCY} --type e2e
123129
working-directory: ${{ env.next-path }}
124-
125-
validate-tests:
126-
name: validate tests
127-
needs: [test-e2e]
128-
runs-on: ubuntu-latest
129-
steps:
130-
- run: exit 1
131-
if:
132-
${{ always() && (contains(needs.*.result, 'failure') || contains(needs.*.result,
133-
'skipped') || contains(needs.*.result, 'cancelled')) }}
130+
- name: Test results
131+
working-directory: ${{ env.next-path }}
132+
run: |
133+
for file in `ls test/e2e/**/*.results.json`; do
134+
test_name=$(echo $file | sed -e 's/test\/e2e\/\(.*\/.*\).results.json/\1/')
135+
echo "<details>" >> $GITHUB_STEP_SUMMARY
136+
echo "<summary>:x: Test failed: <code>${test_name}</code></summary>" >> $GITHUB_STEP_SUMMARY
137+
echo "<pre><code>" >> $GITHUB_STEP_SUMMARY
138+
cat $file | jq -r '.testResults[].message'>> $GITHUB_STEP_SUMMARY
139+
echo "</code></pre>" >> $GITHUB_STEP_SUMMARY
140+
echo "</details>" >> $GITHUB_STEP_SUMMARY
141+
failed=true
142+
done
143+
if [ "$failed" = true ] ; then
144+
echo "Failed tests. Please see action summary for details."
145+
exit 1
146+
fi

0 commit comments

Comments
 (0)