Repository navigation
254 lines (225 loc) · 10.3 KB
/
Copy pathprecommit-e2e-tests.yml
File metadata and controls
254 lines (225 loc) · 10.3 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
---
name: Precommit E2E Tests
on:
workflow_dispatch:
inputs:
reason:
description: Why this test run was started
required: false
type: string
grep:
type: string
description: Define which tests to run, the given value will be passed to the `--grep` flag of playwright
usePublicRspack:
type: boolean
description: Package the public Rspack build for this manual precommit run
default: false
pull_request:
types: [labeled, opened, synchronize, reopened]
schedule:
- cron: '17 8,20 * * *'
timezone: Europe/Berlin
# Concurrency is limited per event per branch as each event uses a different environment and we want to cancel runs if the same branch receives new commits.
# The reused workflow precommit-slot-run.yml already enforces concurrency limits per environment so e.g. two PRs can't run on the same env at the same time.
concurrency:
group: precommit-crit-flows-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: true
permissions: {}
jobs:
build:
name: Build and package Webapp
if: ${{ github.repository == 'wireapp/wire-webapp' && (github.event_name != 'pull_request' || (github.event.pull_request.head.repo.full_name == github.repository && contains(github.event.pull_request.labels.*.name, 'run-e2e'))) }}
runs-on: ubuntu-26.04
timeout-minutes: 20
permissions:
contents: read
outputs:
build_artifact: ${{ env.BUILD_ARTIFACT }}
env_name: ${{ steps.slot.outputs.env_name }}
expected_version: ${{ steps.package.outputs.expected_version }}
expected_commit: ${{ steps.package.outputs.expected_commit }}
env:
BUILD_DIR: apps/server/dist/s3/
BUILD_ARTIFACT: ebs.zip
WIRE_WEBAPP_CONFIGURATION: development
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
persist-credentials: false
fetch-depth: 0
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f
with:
node-version-file: '.nvmrc'
cache: 'npm'
- run: npm clean-install && npx just setup
- id: package
env:
EVENT_NAME: ${{ github.event_name }}
USE_PUBLIC_RSPACK: ${{ inputs.usePublicRspack }}
WIRE_WEBAPP_BUILD_COMMIT: ${{ github.event.pull_request.head.sha || github.sha }}
run: |
short_commit_sha="${WIRE_WEBAPP_BUILD_COMMIT::7}"
expected_version="dev-${short_commit_sha}"
if [[ "${EVENT_NAME}" == "workflow_dispatch" && "${USE_PUBLIC_RSPACK}" == "true" ]]; then
WIRE_WEBAPP_BUILD_VERSION="${expected_version}" \
npx just package-server-public
else
WIRE_WEBAPP_BUILD_VERSION="${expected_version}" \
npx just package-server-internal
fi
{
echo "expected_version=${expected_version}"
echo "expected_commit=${WIRE_WEBAPP_BUILD_COMMIT}"
} >> "$GITHUB_OUTPUT"
- name: Validate deployment package
env:
BUILD_ARTIFACT_PATH: ${{ env.BUILD_DIR }}${{ env.BUILD_ARTIFACT }}
EXPECTED_COMMIT: ${{ steps.package.outputs.expected_commit }}
EXPECTED_VERSION: ${{ steps.package.outputs.expected_version }}
run: |
set -euo pipefail
test -f "$BUILD_ARTIFACT_PATH"
unzip -tq "$BUILD_ARTIFACT_PATH"
npx just validate-build-artifact
archive_entries="$(unzip -Z1 "$BUILD_ARTIFACT_PATH")"
required_entry_scripts=(
static/min/app.js
static/min/auth.js
static/min/checkBrowser.js
static/min/runtime.js
static/min/vendor.js
static/min/dexie.js
)
for entry_script_path in "${required_entry_scripts[@]}"; do
if ! grep -Fqx -- "$entry_script_path" <<< "$archive_entries"; then
echo "Deployment package is missing required entry script: $entry_script_path" >&2
exit 1
fi
done
deployment_runtime="$(unzip -p "$BUILD_ARTIFACT_PATH" static/min/runtime.js)"
if ! grep -Fq 'rspackChunk_wireapp_webapp' <<< "$deployment_runtime"; then
echo "Deployment package does not contain the Rspack runtime fingerprint." >&2
exit 1
fi
if grep -Fq 'webpackChunk_wireapp_webapp' <<< "$deployment_runtime"; then
echo "Deployment package contains the Webpack runtime fingerprint." >&2
exit 1
fi
- name: Compute target EB environment
id: slot
env:
EVENT_NAME: ${{ github.event_name }}
run: |
if [[ "$EVENT_NAME" == "pull_request" ]]; then
# If the PR was labelled with "run-e2e" execute the workflow against a third environment
echo "env_name=wire-webapp-precommit-3" >> "$GITHUB_OUTPUT"
elif [[ "$EVENT_NAME" == "workflow_dispatch" ]]; then
# Keep manual runs away from the scheduled critical-flow slot.
echo "env_name=wire-webapp-precommit-2" >> "$GITHUB_OUTPUT"
else
echo "env_name=wire-webapp-precommit-1" >> "$GITHUB_OUTPUT"
fi
- name: Log target EB environment
env:
ENV_NAME: ${{ steps.slot.outputs.env_name }}
run: |
echo "Selected precommit environment: $ENV_NAME"
echo "Selected precommit URL: https://$ENV_NAME.zinfra.io/"
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
with:
name: build-artifact
path: ${{ env.BUILD_DIR }}${{ env.BUILD_ARTIFACT }}
deploy_and_run_e2e:
name: Deploy to precommit and run E2E
if: ${{ success() && github.repository == 'wireapp/wire-webapp' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }}
needs: [build]
permissions:
contents: read
uses: $/.github/workflows/precommit-slot-run.yml
with:
env_name: ${{ needs.build.outputs.env_name }}
teamManagementUrl: https://wire-teams-staging.zinfra.io/login/
grep: ${{ github.event_name == 'workflow_dispatch' && inputs.grep || '' }}
expectedVersion: ${{ needs.build.outputs.expected_version }}
expectedCommit: ${{ needs.build.outputs.expected_commit }}
expectedBackendRest: https://staging-nginz-https.zinfra.io/
expectedBackendWs: wss://staging-nginz-ssl.zinfra.io/
notify_deployoholics_on_failure: ${{ github.event_name == 'schedule' }}
secrets:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
WEBTEAM_AWS_ACCESS_KEY_ID: ${{ secrets.WEBTEAM_AWS_ACCESS_KEY_ID }}
WEBTEAM_AWS_SECRET_ACCESS_KEY: ${{ secrets.WEBTEAM_AWS_SECRET_ACCESS_KEY }}
WIRE_DEPLOYOHOLICS_WEBHOOK_URL: ${{ secrets.WIRE_DEPLOYOHOLICS_WEBHOOK_URL }}
WIRE_DEPLOYOHOLICS_TOKEN: ${{ secrets.WIRE_DEPLOYOHOLICS_TOKEN }}
run_e2e_tests:
name: Playwright Critical Flow
if: ${{ always() && github.repository == 'wireapp/wire-webapp' && (github.event_name != 'pull_request' || (github.event.pull_request.head.repo.full_name == github.repository && contains(github.event.pull_request.labels.*.name, 'run-e2e'))) }}
needs: [deploy_and_run_e2e]
runs-on: ubuntu-26.04
timeout-minutes: 5
permissions: {}
steps:
- name: Report Status
env:
DEPLOY_AND_RUN_E2E_RESULT: ${{ needs.deploy_and_run_e2e.result }}
run: |
echo "E2E tests completed with status - $DEPLOY_AND_RUN_E2E_RESULT"
if [ "$DEPLOY_AND_RUN_E2E_RESULT" != "success" ]; then
echo "Playwright Critical Flow failed because the upstream E2E workflow did not succeed."
exit 1
fi
e2e-report:
name: Generate test summary
needs: [build, deploy_and_run_e2e]
if: ${{ always() && github.repository == 'wireapp/wire-webapp' && (github.event_name == 'workflow_dispatch' || github.event_name == 'schedule') }}
runs-on: ubuntu-26.04
timeout-minutes: 10
permissions: {}
steps:
- name: Download report
if: ${{ needs.deploy_and_run_e2e.outputs.reportArtifactId != '' }}
continue-on-error: true
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
with:
artifact-ids: ${{ needs.deploy_and_run_e2e.outputs.reportArtifactId }}
path: apps/webapp/playwright-report
- name: Write step summary
env:
BACKEND_URL: https://staging-nginz-https.zinfra.io/
DEPLOY_AND_RUN_E2E_RESULT: ${{ needs.deploy_and_run_e2e.result }}
ENV_NAME: ${{ needs.build.outputs.env_name }}
PRECOMMIT_URL: ${{ needs.deploy_and_run_e2e.outputs.precommit_url }}
REPORT_URL: ${{ needs.deploy_and_run_e2e.outputs.reportUrl }}
WORKFLOW_DISPATCH_REASON: ${{ inputs.reason }}
run: |
{
echo "## Playwright E2E Test Summary"
echo ""
echo "- Environment: \`$ENV_NAME\`"
echo "- Webapp URL: $PRECOMMIT_URL"
echo "- Backend URL: $BACKEND_URL"
echo "- Result: \`$DEPLOY_AND_RUN_E2E_RESULT\`"
} >> "$GITHUB_STEP_SUMMARY"
if [[ -n "$WORKFLOW_DISPATCH_REASON" ]]; then
echo "- Manual run reason: $WORKFLOW_DISPATCH_REASON" >> "$GITHUB_STEP_SUMMARY"
fi
if [[ -n "$REPORT_URL" ]]; then
echo "- Report artifact: $REPORT_URL" >> "$GITHUB_STEP_SUMMARY"
else
echo "- Report artifact: unavailable" >> "$GITHUB_STEP_SUMMARY"
fi
REPORT_FILE="apps/webapp/playwright-report/report.json"
if [[ ! -f "$REPORT_FILE" ]]; then
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "No Playwright report summary is available." >> "$GITHUB_STEP_SUMMARY"
exit 0
fi
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "### Failure Summary" >> "$GITHUB_STEP_SUMMARY"
FAILED_TESTS="$(jq -r '[.. | objects | select(has("specs") and (.specs | length > 0)) | .title as $suite | .specs[] | .title as $title | .tests[] | select(.status == "unexpected") | "- " + $suite + " > " + $title] | unique | .[]?' "$REPORT_FILE" || true)"
if [[ -n "$FAILED_TESTS" ]]; then
echo "$FAILED_TESTS" >> "$GITHUB_STEP_SUMMARY"
else
echo "No failed tests found in the report." >> "$GITHUB_STEP_SUMMARY"
fi