Skip to content

Commit ea337d6

Browse files
committed
Better retrying / add quiet mode and skip bundle
1 parent 8d9290f commit ea337d6

2 files changed

Lines changed: 47 additions & 32 deletions

File tree

.github/workflows/.reusable-docker-e2e-tests.yml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,25 +79,22 @@ jobs:
7979
run: depot pull-token | docker login -u x-token --password-stdin registry.depot.dev
8080

8181
- name: Run tests on dockerised frontend
82-
uses: nick-fields/retry@v3
83-
with:
84-
shell: bash
85-
command: |
86-
cd frontend
87-
make test
88-
max_attempts: 2
89-
retry_on: error
90-
timeout_minutes: 20
91-
on_retry_command: |
92-
cd frontend
93-
docker compose down --remove-orphans || true
82+
working-directory: frontend
83+
run: make test
9484
env:
9585
opts: ${{ inputs.args }}
9686
API_IMAGE: ${{ inputs.api-image }}
9787
E2E_IMAGE: ${{ inputs.e2e-image }}
9888
E2E_CONCURRENCY: ${{ inputs.concurrency }}
89+
E2E_RETRIES: 1
9990
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
10091
GITHUB_ACTION_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
92+
timeout-minutes: 20
93+
94+
- name: Cleanup E2E services
95+
if: always()
96+
working-directory: frontend
97+
run: docker compose down --remove-orphans || true
10198

10299
- name: Copy results.json to HTML report
103100
if: always()

frontend/e2e/run-with-retry.ts

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,45 @@ async function runTeardown() {
1919
return false;
2020
}
2121

22-
try {
23-
const res = await fetch(e2eTestApi, {
24-
body: JSON.stringify({}),
25-
headers: {
26-
'Accept': 'application/json',
27-
'Content-Type': 'application/json',
28-
'X-E2E-Test-Auth-Token': token.trim(),
29-
},
30-
method: 'POST',
31-
});
22+
const maxAttempts = 3;
23+
const delayMs = 2000; // 2 seconds between attempts
3224

33-
if (res.ok) {
34-
console.log('\x1b[32m%s\x1b[0m\n', '✓ E2E teardown successful');
35-
return true;
36-
} else {
37-
console.error('\x1b[31m%s\x1b[0m\n', `✗ E2E teardown failed: ${res.status}`);
38-
return false;
25+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
26+
if (attempt > 0) {
27+
console.log(`\x1b[33m%s\x1b[0m`, `Retrying teardown (attempt ${attempt + 1}/${maxAttempts})...`);
28+
await new Promise(resolve => setTimeout(resolve, delayMs));
29+
}
30+
31+
try {
32+
const res = await fetch(e2eTestApi, {
33+
body: JSON.stringify({}),
34+
headers: {
35+
'Accept': 'application/json',
36+
'Content-Type': 'application/json',
37+
'X-E2E-Test-Auth-Token': token.trim(),
38+
},
39+
method: 'POST',
40+
});
41+
42+
if (res.ok) {
43+
console.log('\x1b[32m%s\x1b[0m\n', '✓ E2E teardown successful');
44+
return true;
45+
} else {
46+
console.error('\x1b[31m%s\x1b[0m', `✗ E2E teardown failed: ${res.status}`);
47+
if (attempt < maxAttempts - 1) {
48+
console.log(''); // newline before retry message
49+
}
50+
}
51+
} catch (error) {
52+
console.error('\x1b[31m%s\x1b[0m', `✗ E2E teardown error: ${error}`);
53+
if (attempt < maxAttempts - 1) {
54+
console.log(''); // newline before retry message
55+
}
3956
}
40-
} catch (error) {
41-
console.error('\x1b[31m%s\x1b[0m\n', `✗ E2E teardown error: ${error}`);
42-
return false;
4357
}
58+
59+
console.log('\x1b[31m%s\x1b[0m\n', `✗ E2E teardown failed after ${maxAttempts} attempts`);
60+
return false;
4461
}
4562

4663
function runPlaywright(args: string[], quietMode: boolean): boolean {
@@ -65,7 +82,8 @@ async function main() {
6582

6683
// Get additional args passed to the script (e.g., test file names, -g patterns)
6784
const extraArgs = process.argv.slice(2);
68-
const quietMode = process.env.QUIET === '1';
85+
const verboseMode = process.env.VERBOSE === '1';
86+
const quietMode = !verboseMode;
6987

7088
while (attempt <= RETRIES) {
7189
if (attempt > 0) {

0 commit comments

Comments
 (0)