-
Notifications
You must be signed in to change notification settings - Fork 17
157 lines (141 loc) · 5.94 KB
/
e2e.yml
File metadata and controls
157 lines (141 loc) · 5.94 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
name: End-to-end testing
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
pull-requests: write
jobs:
docker:
# If the workflow was triggered by anything other than a pull_request event
# (e.g., push, workflow_dispatch, schedule, pull_request_target),
# github.event_name != 'pull_request' is true.
# github.event.pull_request is only populated on pull_request events.
# It is true when the PR is not a draft (i.e., “Ready for review”).
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false
runs-on: ubuntu-latest
env:
REPORT_LOCAL_DIR: test-reports
REPORT_LOCAL_FILE: wasm-e2e-report.html
WASM_REPORT_JSON_FILE: wasm.json
GRATE_REPORT_JSON_FILE: grates.json
REPORT_HTML_IN_REPORTS: report.html
COMMENT_LOCAL_FILE: e2e_comment.md
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
# First attempt at build
- name: Build e2e (attempt 1)
id: build_e2e_try1
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0
with:
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
file: Docker/Dockerfile.e2e
tags: e2e:latest
outputs: type=local,dest=${{ env.REPORT_LOCAL_DIR }}
# Small backoff if it failed
- name: Backoff (after try 1)
if: steps.build_e2e_try1.outcome == 'failure'
run: sleep 15
# Second attempt
- name: Build e2e (attempt 2)
id: build_e2e_try2
if: steps.build_e2e_try1.outcome == 'failure'
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0
with:
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
file: Docker/Dockerfile.e2e
tags: e2e:latest
outputs: type=local,dest=${{ env.REPORT_LOCAL_DIR }}
# Slightly Longer Backoff if it failed again
- name: Backoff (after try 2)
if: steps.build_e2e_try2.outcome == 'failure'
run: sleep 30
# Third and final attempt
- name: Build e2e (attempt 3)
id: build_e2e_try3
if: steps.build_e2e_try2.outcome == 'failure'
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0
with:
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
file: Docker/Dockerfile.e2e
tags: e2e:latest
outputs: type=local,dest=${{ env.REPORT_LOCAL_DIR }}
- name: Read test status
id: e2e
run: |
STATUS_FILE="${{ env.REPORT_LOCAL_DIR }}/e2e_status"
echo "Checking status file at: $STATUS_FILE"
echo "----- File contents (if any) -----"
if [[ -f "$STATUS_FILE" ]]; then
cat "$STATUS_FILE"
# export to step output AND job env
cat "$STATUS_FILE" >> "$GITHUB_OUTPUT" # writes E2E_STATUS=pass|fail
cat "$STATUS_FILE" >> "$GITHUB_ENV"
else
echo "(none)"
echo "E2E_STATUS=fail" >> "$GITHUB_OUTPUT"
echo "E2E_STATUS=fail" >> "$GITHUB_ENV"
echo "::warning file=$STATUS_FILE::Status file missing, defaulting to fail"
fi
echo "----------------------------------"
- name: Upload HTML report artifact to report
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f
with:
name: wasm-e2e-report
path: |
${{ env.REPORT_LOCAL_DIR }}/reports/${{ env.REPORT_HTML_IN_REPORTS }}
${{ env.REPORT_LOCAL_DIR }}/${{ env.REPORT_LOCAL_FILE }}
if-no-files-found: error
retention-days: 7
- name: Upload wasm JSON report artifact
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f
with:
name: wasm-e2e-json
path: ${{ env.REPORT_LOCAL_DIR }}/reports/${{ env.WASM_REPORT_JSON_FILE }}
if-no-files-found: error
retention-days: 7
- name: Upload grate JSON report artifact
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f
with:
name: grate-e2e-json
path: ${{ env.REPORT_LOCAL_DIR }}/reports/${{ env.GRATE_REPORT_JSON_FILE }}
if-no-files-found: error
retention-days: 7
- name: Upload unified runner HTML report artifact
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f
with:
name: wasm-e2e-unified-html
path: |
${{ env.REPORT_LOCAL_DIR }}/reports/${{ env.REPORT_HTML_IN_REPORTS }}
${{ env.REPORT_LOCAL_DIR }}/${{ env.REPORT_LOCAL_FILE }}
if-no-files-found: error
retention-days: 7
- name: Post PR comment
# Run only on branch PRs, not on fork PRs
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd
with:
script: |
const fs = require('fs');
const path = `${process.env.REPORT_LOCAL_DIR}/${process.env.COMMENT_LOCAL_FILE}`;
const body = fs.readFileSync(path, 'utf8');
const { owner, repo } = context.repo;
const issue_number = context.issue.number;
await github.rest.issues.createComment({ owner, repo, issue_number, body });
- name: Fail if tests failed
if: steps.e2e.outputs.E2E_STATUS == 'fail'
run: |
echo "Tests failed; failing job after posting the report/comment."
exit 1