-
-
Notifications
You must be signed in to change notification settings - Fork 2
205 lines (183 loc) · 7.2 KB
/
Copy pathe2e-pull_request.yml
File metadata and controls
205 lines (183 loc) · 7.2 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
name: E2E Screenshot Tests Pull Request
on:
pull_request:
types: [opened, synchronize, closed]
permissions:
contents: read
jobs:
test:
if: github.event.action != 'closed'
timeout-minutes: 10
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include:
- ionic-major: 8
ionic-version: 8.8.19
- ionic-major: 9
ionic-version: 9.0.0
container:
image: mcr.microsoft.com/playwright:v1.58.2-noble
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: 24
- uses: actions/cache@v5
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- if: matrix.ionic-major == 8
run: npm install --no-save --package-lock=false @ionic/angular@${{ matrix.ionic-version }} @ionic/core@${{ matrix.ionic-version }}
- run: npm run build
- run: npm ci
working-directory: './demo'
- if: matrix.ionic-major == 8
run: npm install --no-save --package-lock=false @ionic/angular@${{ matrix.ionic-version }} @ionic/core@${{ matrix.ionic-version }}
working-directory: './demo'
- name: Run Playwright tests
run: PLAYWRIGHT_JSON_OUTPUT_NAME=e2e/screenshot.spec.ts-ionic${{ matrix.ionic-major }}.json npm run test:e2e -- --reporter=json,html
working-directory: ./demo
env:
IONIC_MAJOR: ${{ matrix.ionic-major }}
- name: Upload test results
uses: actions/upload-artifact@v5
if: always()
with:
name: playwright-report-ionic${{ matrix.ionic-major }}
path: demo/playwright-report/
retention-days: 3
- name: Upload screenshots on failure
uses: actions/upload-artifact@v5
if: failure()
with:
name: test-results-ionic${{ matrix.ionic-major }}
path: demo/test-results/
retention-days: 3
- name: Upload Ionic 9 JSON report artifact
uses: actions/upload-artifact@v5
if: always() && matrix.ionic-major == 9
with:
name: json-report-${{ github.event.pull_request.number }}
path: demo/e2e/screenshot.spec.ts-ionic9.json
retention-days: 3
- name: Upload Ionic 9 HTML report artifact
uses: actions/upload-artifact@v5
if: always() && matrix.ionic-major == 9
with:
name: html-report-${{ github.event.pull_request.number }}
path: demo/playwright-report/
retention-days: 30
comment-results:
needs: test
if: >-
always() &&
github.event.action != 'closed' &&
github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Download JSON report
uses: actions/download-artifact@v5
with:
name: json-report-${{ github.event.pull_request.number }}
path: report
- name: Comment PR with Ionic 9 test results
uses: daun/playwright-report-comment@v3
with:
report-file: report/screenshot.spec.ts-ionic9.json
job-summary: true
custom-info: 'This detailed result covers Ionic 9 only. Ionic 8 runs against the same screenshots in a separate matrix job; check the [workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for both results. To update the screenshots, comment with `/update-screenshots`.'
deploy-report:
needs: test
if: >-
always() &&
github.event.action != 'closed' &&
github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Download HTML report
uses: actions/download-artifact@v5
with:
name: html-report-${{ github.event.pull_request.number }}
path: playwright-report
- name: Checkout gh-pages
uses: actions/checkout@v5
with:
ref: gh-pages
path: gh-pages
continue-on-error: true
- name: Prepare GitHub Pages directory
run: |
# gh-pagesディレクトリが存在しない場合は作成
if [ ! -d "gh-pages" ]; then
mkdir -p gh-pages
fi
# PR用のディレクトリを作成(既存の場合は削除して再作成)
rm -rf gh-pages/pr-${{ github.event.pull_request.number }}
mkdir -p gh-pages/pr-${{ github.event.pull_request.number }}
cp -r playwright-report/* gh-pages/pr-${{ github.event.pull_request.number }}/
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./gh-pages
keep_files: true
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
commit_message: 'Update test report for PR #${{ github.event.pull_request.number }}'
- name: Comment PR with report link
uses: actions/github-script@v7
if: always()
with:
script: |
const prNumber = context.payload.pull_request.number;
const reportUrl = `https://${context.repo.owner}.github.io/${context.repo.repo}/pr-${prNumber}/`;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: `📊 **Ionic 9 Playwright Test Report**\n\nView the detailed Ionic 9 report: ${reportUrl}\n\nIonic 8 runs against the same screenshots in a separate matrix job. View both results in the [workflow run](${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}).`
});
cleanup-report:
if: >-
github.event.action == 'closed' &&
github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout gh-pages
uses: actions/checkout@v5
with:
ref: gh-pages
path: gh-pages
continue-on-error: true
- name: Remove PR report directory
run: |
if [ -d "gh-pages/pr-${{ github.event.pull_request.number }}" ]; then
rm -rf gh-pages/pr-${{ github.event.pull_request.number }}
echo "Removed report directory for PR #${{ github.event.pull_request.number }}"
else
echo "No report directory found for PR #${{ github.event.pull_request.number }}"
fi
- name: Deploy to GitHub Pages
if: hashFiles('gh-pages/**') != ''
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./gh-pages
keep_files: true
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
commit_message: 'Remove test report for closed PR #${{ github.event.pull_request.number }}'