-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (124 loc) · 5.03 KB
/
report_test.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
136
137
138
139
140
141
name: Test Action
on:
pull_request:
push:
branches: ['main']
workflow_dispatch:
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the changed files back to the repository.
contents: write
# required by https://github.com/thollander/actions-comment-pull-request
pull-requests: write
# Allow only one job per PR or branch
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true # cancel jobs in progress
jobs:
test:
timeout-minutes: 180
runs-on: ubuntu-latest
name: Build, Test, Report
steps:
# To use this repository's private action,
# you must check out the repository
- uses: actions/checkout@v3
- run: npm ci --no-fund --no-audit --no-progress
- run: npm run checks
- run: npm run build
- name: Make sure dist was commited before push
run: |
git status -s -uno
[ $(git status -s -uno | wc -l | bc ) != "0" ] && exit 1 || echo OK
- run: npx playwright install --with-deps chromium
- name: Lighthouse
run: npm run lighthouse
- name: Update screenshots in PRs
if: github.event_name == 'pull_request'
run: npm run e2e -- --update-snapshots
- name: git commit and push
if: github.event_name == 'pull_request'
uses: mgrybyk-org/git-commit-pull-push-action@v1
with:
branch: ${{ github.head_ref }}
commit_message: Update screenshots
add_args: 'tests/**/*.png'
- name: Do not update screenshots if not PR
if: github.event_name != 'pull_request'
run: npm run e2e
- name: Checkout gh-pages
uses: actions/checkout@v3
if: always()
continue-on-error: true
with:
ref: gh-pages # branch name
path: gh-pages-dir # checkout path
- name: Allure Report Action
uses: mgrybyk-org/allure-report-branch-js-action@v1
if: always()
continue-on-error: true
id: allure
with:
report_id: 'self-test'
gh_pages: 'gh-pages-dir'
report_dir: 'allure-results'
list_dirs: ${{ github.ref == 'refs/heads/main' }}
branch_cleanup_enabled: ${{ github.ref == 'refs/heads/main' }}
max_reports: 9
- name: generate csv report data
if: ${{ always() && steps.allure.outputs.report_url }}
run: |
mkdir -p test-results
outFile=test-results/Allure_Trend.csv
echo Passed,Failed,Total > $outFile
echo ${{ steps.allure.outputs.test_result_passed }},${{ steps.allure.outputs.test_result_failed }},${{ steps.allure.outputs.test_result_total }} >> $outFile
- name: Local HTML Report
if: always()
uses: ./ # Uses an action in the root directory
id: html-1
with:
report_id: 'Lighthouse Report'
gh_pages: 'gh-pages-dir'
report_dir: 'lighthouse-html'
list_dirs: ${{ github.ref == 'refs/heads/main' }}
branch_cleanup_enabled: ${{ github.ref == 'refs/heads/main' }}
max_reports: 9
- name: Local Chart Report (single)
if: ${{ always() && steps.allure.outputs.report_url }}
uses: ./
id: chart-2
with:
report_id: 'Allure Trend Report'
gh_pages: 'gh-pages-dir'
report_dir: 'test-results/Allure_Trend.csv'
list_dirs: ${{ github.ref == 'refs/heads/main' }}
report_type: csv
max_reports: 9
- name: Local Chart Report (multiple)
if: ${{ always() && steps.allure.outputs.report_url }}
uses: ./
id: chart-3
with:
report_id: 'Lighthouse Trend Report'
gh_pages: 'gh-pages-dir'
report_dir: 'lighthouse-csv'
list_dirs: ${{ github.ref == 'refs/heads/main' }}
report_type: csv
max_reports: 9
- name: Git Commit and Push Action
uses: mgrybyk-org/git-commit-pull-push-action@v1
if: always()
with:
repository: gh-pages-dir
branch: gh-pages
pull_args: --rebase -X ours
- name: Comment PR with Allure Report link
if: ${{ always() && github.event_name == 'pull_request' && (steps.allure.outputs.report_url || steps.html-1.outputs.report_url || steps.chart-2.outputs.report_url) }}
continue-on-error: true
uses: thollander/actions-comment-pull-request@v2
with:
message: |
[HTML Report](${{ steps.html-1.outputs.report_url }}) | [Allure Trend (single csv)](${{ steps.chart-2.outputs.report_url }})
[Lighthouse Trend Report (mutliple csv)](${{ steps.chart-3.outputs.report_url }})
${{ steps.allure.outputs.test_result_icon }} [Allure Report](${{ steps.allure.outputs.report_url }}) | ${{ steps.allure.outputs.test_result_passed }}/${{ steps.allure.outputs.test_result_failed }}/${{ steps.allure.outputs.test_result_total }} | [History](${{ steps.allure.outputs.report_history_url }})
comment_tag: test_reports
mode: recreate