-
-
Notifications
You must be signed in to change notification settings - Fork 1
122 lines (105 loc) · 4.86 KB
/
e2e.yml
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
name: E2E Tests
on:
push:
branches: ['trunk']
pull_request:
permissions:
contents: read
jobs:
e2e:
name: Run E2E test
runs-on: namespace-profile-playwright
env:
# renovate: datasource=node-version depName=node
NODE_VERSION: 22
COMMENT_TAG: 'playwright-report-link'
defaults:
run:
working-directory: e2e-test
steps:
- name: Checkout
uses: namespacelabs/nscloud-checkout-action@b8c45d632ce8118a5a0a51eb75a57cfccc74b8fa # v5
- name: Setup cache
uses: namespacelabs/nscloud-cache-action@f23fbf3b586540a96f4f5849a5e04c7e56e1e804 # v1
with:
path: |
~/.npm
~/.cache/ms-playwright
./node_modules
/var/cache/apt
- name: Stop apt cleaning cache
run: sudo rm /etc/apt/apt.conf.d/docker-clean
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
with:
node-version: '${{env.NODE_VERSION}}'
- name: Install playwright deps
run: |
npm ci
npx playwright install --with-deps
- name: Run e2e tests
id: run-e2e-tests
env:
PW_WORKERS: '100%'
run: ../bin/e2e
- name: Output docker compose logs
if: ${{ !cancelled() }}
run: docker compose --ansi=never logs --timestamps | tee playwright-report/docker.log
- name: Upload HTML report to S3
if: ${{ !cancelled() }}
id: upload-html-report-to-s3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.PW_REPORTS_BUCKET_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.PW_REPORTS_BUCKET_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: 'auto'
TIGRIS_ENDPOINT: 'https://fly.storage.tigris.dev'
BUCKET_NAME: 'pr-cli-playwright-reports'
BUCKET_PUBLIC_ENDPOINT: 'https://pr-cli-playwright-reports.fly.storage.tigris.dev'
run: |
CONTEXT="${{ github.event.pull_request.number || github.event.issue.number || github.sha }}"
S3_FOLDER="$(date +%Y%m%d)-$CONTEXT-$(uuidgen | cut -c1-8)"
echo "::debug::Folder: $S3_FOLDER"
LOCAL_FOLDER="playwright-report"
REPORT_URL="$BUCKET_PUBLIC_ENDPOINT/$S3_FOLDER"
echo "::notice::Playwright report: $REPORT_URL/index.html"
echo "REPORT_URL=$REPORT_URL" >> "$GITHUB_OUTPUT"
# Add PR number to title in index.html
sed -i -r "s%<title>(.*)</title>%<title>pr $CONTEXT - \1</title>%" "$LOCAL_FOLDER/index.html"
aws s3 cp --endpoint-url "$TIGRIS_ENDPOINT" \
"$LOCAL_FOLDER" "s3://$BUCKET_NAME/$S3_FOLDER" \
--recursive \
--no-progress
# Generate a GH_TOKEN for the PW Comment App
# This allows commenting on PRs from forks
# and adds a profile picture and name to the comments
- name: Generate a token
if: ${{ github.event_name == 'pull_request' && !cancelled() }}
id: generate-comment-app-token
uses: actions/create-github-app-token@5d869da34e18e7287c1daad50e0b8ea0f506ce69 # v1
with:
app-id: ${{ vars.PW_REPORTS_COMMENT_APP_ID }}
private-key: ${{ secrets.PW_REPORTS_COMMENT_APP_PRIVATE_KEY }}
- name: Comment link to HTML report
if: ${{ !cancelled() && steps.generate-comment-app-token.outcome == 'success' && steps.upload-html-report-to-s3.outcome == 'success' }}
uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3
with:
message: |
${{ steps.run-e2e-tests.outcome == 'success' && ':white_check_mark: Playwright tests passed' || ':x: Playwright tests failed' }}
[🎭 Report](${{ steps.upload-html-report-to-s3.outputs.REPORT_URL }}/index.html)
[🐋 Docker logs](${{ steps.upload-html-report-to-s3.outputs.REPORT_URL }}/docker.log)
comment-tag: ${{ env.COMMENT_TAG }}
create-if-not-exists: '${{ steps.run-e2e-tests.outcome }}' # Don't post comment for success, but update if commented before
github-token: ${{ steps.generate-comment-app-token.outputs.token }}
- name: Comment link to HTML report (On failure)
if: ${{ !cancelled() && steps.generate-comment-app-token.outcome == 'success' && steps.upload-html-report-to-s3.outcome == 'failure'}}
uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3
with:
message: 🎭 Latest playwright run was cancelled or failed
comment-tag: ${{ env.COMMENT_TAG }}
github-token: ${{ steps.generate-comment-app-token.outputs.token }}
- name: Store HTML report as GitHub Artifact
if: ${{ !cancelled() }}
uses: namespace-actions/upload-artifact@bdeb0013794f0f483d9ae61cab524090ccc41016 # v0
with:
name: playwright-html-report
path: e2e-test/playwright-report
retention-days: 5