Skip to content

Commit 8d09bbe

Browse files
authored
chore(ci): add serialized precommit workflow with crit flow tests (#19449)
- Add serialized precommit deploy and critical flow tests - Remove old precommit and critical flow triggers - Exclude dependabot PRs from triggering precommit workflow - Pin sticky-pull-request-comment and 1password actions to SHAs (SonarQube warnings) - Force WEBAPP_URL to precommit.zinfra.io in e2e tests to avoid TLS mismatch - Clarify comment on WEBAPP_URL override source
1 parent 3ccf813 commit 8d09bbe

File tree

3 files changed

+189
-8
lines changed

3 files changed

+189
-8
lines changed

.github/workflows/playwright-crit-flow-tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: Playwright Critical Flow Tests
22

3-
on:
4-
pull_request:
5-
# we want to run the CI on every PR targetting those branches
6-
branches: [dev]
3+
#on:
4+
# pull_request:
5+
# # we want to run the CI on every PR targetting those branches
6+
# branches: [dev]
77

88
jobs:
99
smoke-tests:
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
name: precommit
2+
3+
on:
4+
pull_request:
5+
branches: [dev]
6+
branches-ignore:
7+
- 'dependabot/**' # skip all Dependabot PRs
8+
9+
# One at a time lane for the shared precommit environment
10+
concurrency:
11+
group: precommit-deploy
12+
cancel-in-progress: false # queue newer runs
13+
14+
jobs:
15+
build:
16+
runs-on: buildjet-8vcpu-ubuntu-2204
17+
timeout-minutes: 20
18+
19+
outputs:
20+
unit_tests_report: ${{ env.UNIT_TEST_REPORT_FILE }}
21+
build_artifact: ${{ env.BUILD_ARTIFACT }}
22+
total_additions: ${{ steps.check_additions.outputs.total_additions }}
23+
24+
env:
25+
BUILD_DIR: server/dist/s3/
26+
BUILD_ARTIFACT: ebs.zip
27+
COMMIT_URL: ${{ github.event.head_commit.url }}
28+
COMMITTER: ${{ github.event.head_commit.committer.name }}
29+
CHANGELOG_FILE: ./changelog.md
30+
UNIT_TEST_REPORT_FILE: ./unit-tests.log
31+
32+
steps:
33+
- uses: actions/checkout@v4
34+
with:
35+
fetch-depth: 0
36+
ref: ${{ github.event.pull_request.head.sha }}
37+
38+
- uses: actions/setup-node@v4
39+
with:
40+
node-version: 18.16.x
41+
cache: yarn
42+
43+
- run: yarn --immutable
44+
- run: yarn configure
45+
- run: yarn build:prod
46+
47+
- uses: actions/upload-artifact@v4
48+
with:
49+
name: build-artifact
50+
path: ${{ env.BUILD_DIR }}${{ env.BUILD_ARTIFACT }}
51+
52+
- name: Check total PR additions
53+
id: check_additions
54+
run: |
55+
total_additions=$(gh api -H "Accept: application/vnd.github.v3+json" \
56+
"repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}" \
57+
| jq -r '.additions')
58+
test -n "$total_additions" -a "$total_additions" != null
59+
echo "Found total additions: $total_additions"
60+
echo "total_additions=$total_additions" >> "$GITHUB_OUTPUT"
61+
env:
62+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
64+
deploy_to_aws:
65+
name: Deploy to precommit
66+
runs-on: ubuntu-latest
67+
needs: [build]
68+
timeout-minutes: 25
69+
70+
outputs:
71+
precommit_url: ${{ steps.fetch_url.outputs.url }}
72+
73+
steps:
74+
- uses: actions/download-artifact@v4
75+
with:
76+
name: build-artifact
77+
78+
- name: Deploy to precommit environment
79+
id: deploy
80+
uses: einaregilsson/beanstalk-deploy@27edd8a0ebe8656ac70654372c73f06f7e9a1027 # v22
81+
with:
82+
application_name: Webapp
83+
aws_access_key: ${{ secrets.WEBTEAM_AWS_ACCESS_KEY_ID }}
84+
aws_secret_key: ${{ secrets.WEBTEAM_AWS_SECRET_ACCESS_KEY }}
85+
deployment_package: ${{ needs.build.outputs.build_artifact }}
86+
environment_name: wire-webapp-precommit
87+
region: eu-central-1
88+
use_existing_version_if_available: true
89+
version_description: ${{ github.sha }}
90+
version_label: ${{ github.run_id }}
91+
wait_for_deployment: true # ✅ wait until EB is green
92+
93+
- name: Fetch precommit URL
94+
id: fetch_url
95+
run: |
96+
URL=$(aws elasticbeanstalk describe-environments \
97+
--region eu-central-1 \
98+
--environment-names wire-webapp-precommit \
99+
--query "Environments[0].CNAME" --output text)
100+
echo "url=https://$URL" >> "$GITHUB_OUTPUT"
101+
env:
102+
AWS_ACCESS_KEY_ID: ${{ secrets.WEBTEAM_AWS_ACCESS_KEY_ID }}
103+
AWS_SECRET_ACCESS_KEY: ${{ secrets.WEBTEAM_AWS_SECRET_ACCESS_KEY }}
104+
AWS_DEFAULT_REGION: eu-central-1
105+
106+
- name: Deployment Status
107+
if: ${{ always() }}
108+
run: |
109+
if [[ "${{ steps.deploy.outcome }}" == "success" ]]; then
110+
echo "✅ Deployment completed successfully"
111+
else
112+
echo "❌ Deployment failed"; exit 1
113+
fi
114+
115+
e2e_crit_flow:
116+
name: Playwright Critical Flow (precommit)
117+
runs-on: [self-hosted, Linux, X64, office]
118+
needs: [deploy_to_aws]
119+
timeout-minutes: 35
120+
if: github.repository == 'wireapp/wire-webapp'
121+
122+
steps:
123+
- uses: actions/checkout@v4
124+
with:
125+
ref: ${{ github.event.pull_request.head.sha }}
126+
127+
- uses: actions/setup-node@v4
128+
with:
129+
node-version: 18.16.x
130+
cache: yarn
131+
132+
- run: yarn --immutable
133+
- run: yarn playwright install --with-deps && yarn playwright install chrome
134+
- uses: 1password/install-cli-action@143a85f84a90555d121cde2ff5872e393a47ab9f
135+
136+
- name: Generate env file
137+
run: op inject -i test/e2e_tests/.env.tpl -o test/e2e_tests/.env
138+
env:
139+
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
140+
141+
# Log which URL will be used for tests (deploy output vs fallback) and probe if env responds
142+
- name: Show target URL + quick probe
143+
run: |
144+
echo "Using precommit URL: https://wire-webapp-precommit.zinfra.io/"
145+
curl -s -o /dev/null -w "HTTP %{http_code}\n" https://wire-webapp-precommit.zinfra.io/
146+
147+
- name: Run critical flow tests
148+
env:
149+
# TODO: remove hardcoded precommit env in the future when ephemeral PR envs will exist
150+
# Overrides URL from .env file
151+
WEBAPP_URL: https://wire-webapp-precommit.zinfra.io/
152+
run: yarn e2e-test --grep "@crit-flow-web"
153+
154+
- name: Upload test report
155+
if: always()
156+
uses: actions/upload-artifact@v4
157+
with:
158+
name: playwright-report
159+
path: playwright-report/
160+
161+
- name: Generate PR comment
162+
if: always()
163+
id: generate_comment
164+
run: |
165+
node test/e2e_tests/scripts/create-playwright-report-summary.js
166+
COMMENT=$(cat playwright-report-summary.txt)
167+
echo "comment<<EOF" >> $GITHUB_OUTPUT
168+
echo "$COMMENT" >> $GITHUB_OUTPUT
169+
echo "EOF" >> $GITHUB_OUTPUT
170+
171+
- name: Comment on PR
172+
if: always()
173+
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405
174+
with:
175+
header: playwright-summary
176+
message: |
177+
🔗 [Download Full Report Artifact](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
178+
179+
${{ steps.generate_comment.outputs.comment }}
180+
env:
181+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/precommit.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: precommit
22

3-
on:
4-
pull_request:
5-
# we want to run the CI on every PR targetting those branches
6-
branches: [dev]
3+
#on:
4+
# pull_request:
5+
# # we want to run the CI on every PR targetting those branches
6+
# branches: [dev]
77

88
concurrency:
99
group: precommit-deploy

0 commit comments

Comments
 (0)