-
-
Notifications
You must be signed in to change notification settings - Fork 1
135 lines (116 loc) · 4.92 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
123
124
125
126
127
128
129
130
131
132
133
134
135
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: 20
COMMENT_TAG: 'playwright-report-link'
defaults:
run:
working-directory: e2e-test
steps:
- name: Checkout
uses: namespacelabs/nscloud-checkout-action@v5
- name: Setup cache
uses: namespacelabs/nscloud-cache-action@v1
with:
path: |
~/.npm
~/.cache/ms-playwright
./node_modules
- name: Stop apt cleaning cache
run: rm /etc/apt/apt.conf.d/docker-clean
- uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4
with:
node-version: '${{env.NODE_VERSION}}'
- name: Install playwright deps
run: |
npm ci
npx playwright install --with-deps
- name: list apt cache
run: |
ls -lah /etc/apt/apt.conf.d/
echo '-----'
ls -lah /var/cache/apt
echo '-----'
tree /var/cache/apt || echo 'treeless'
- name: Breakpoint if tests failed
uses: namespacelabs/breakpoint-action@v0
with:
duration: 10m
authorized-users: annervisser
- 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 logs | 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@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@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@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@v0
with:
name: playwright-html-report
path: e2e-test/playwright-report
retention-days: 5