-
Notifications
You must be signed in to change notification settings - Fork 1
106 lines (97 loc) · 4.08 KB
/
publish-integration-tests-report.yaml
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
on:
# Workflow dispatch is used for manual triggers
workflow_dispatch:
# Workflow call is used for called from another workflow
workflow_call:
inputs:
dm_cli_version:
description: 'DM CLI version used in test'
required: true
type: string
dmss_version:
description: 'DMSS version used in test'
required: true
type: string
job_version:
description: 'Job version used in test'
required: true
type: string
update_readme:
description: 'If true, update README.md with test details'
required: false
default: false
type: boolean
jobs:
publish_report:
name: Publish HTML Report
# using always() is not ideal here, because it would also run if the workflow was cancelled
runs-on: ubuntu-latest
concurrency:
group: publish-integration-tests-report-publish_report
continue-on-error: true
env:
# Unique URL path for each workflow run attempt
HTML_REPORT_URL_PATH: reports/${{ github.ref_name }}/${{ github.run_id }}/${{ github.run_attempt }}
outputs:
report_url: ${{ steps.report-url.outputs.report_url }}
steps:
- name: Checkout GitHub Pages Branch
uses: actions/checkout@v3
with:
ref: gh-pages
- name: Set Git User
# see: https://github.com/actions/checkout/issues/13#issuecomment-724415212
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Download zipped HTML report
uses: actions/download-artifact@v3
with:
name: playwright-report
path: ${{ env.HTML_REPORT_URL_PATH }}
- name: Add entry to README.md
if: inputs.update_readme
run: |
echo "* ${{ github.event.head_commit.message }} (${{ github.event.repository.updated_at}})" >> README.md
echo " * [Integration tests](https://equinor.github.io/dm-core-packages/$HTML_REPORT_URL_PATH)" >> README.md
echo " * **DMSS VERSION**: ${{ inputs.dmss_version }}" >> README.md
echo " * **DM CLI VERSION**: ${{ inputs.dm_cli_version }}" >> README.md
echo " * **JOB VERSION**: ${{ inputs.job_version }}" >> README.md
- name: Push HTML Report
timeout-minutes: 3
# commit report, then try push-rebase-loop until it's able to merge the HTML report to the gh-pages branch
# this is necessary when this job is running at least twice at the same time (e.g. through two pushes at the same time)
run: |
git add .
git commit -m "workflow: add HTML report for run-id ${{ github.run_id }} (attempt: ${{ github.run_attempt }})"
while true; do
git pull --rebase
if [ $? -ne 0 ]; then
echo "Failed to rebase. Please review manually."
exit 1
fi
git push
if [ $? -eq 0 ]; then
echo "Successfully pushed HTML report to repo."
exit 0
fi
done
- name: Output Report URL as Worfklow Annotation
id: report-url
run: |
FULL_HTML_REPORT_URL=https://equinor.github.io/dm-core-packages/$HTML_REPORT_URL_PATH
echo "report_url=$FULL_HTML_REPORT_URL" >> "$GITHUB_OUTPUT"
echo "::notice title=📋 Published Playwright Test Report::$FULL_HTML_REPORT_URL"
add-summary:
name: Add summary
needs: publish_report
if: ${{ ! cancelled() }}
runs-on: ubuntu-latest
steps:
- name: Write to workflow job summary
run: |
echo "### Integration tests summary! :rocket:" >> $GITHUB_STEP_SUMMARY
echo "[Link to integration tests report](${{ needs.publish_report.outputs.report_url }})" >> $GITHUB_STEP_SUMMARY
echo "- **DMSS VERSION**: ${{ inputs.dmss_version }}" >> $GITHUB_STEP_SUMMARY
echo "- **DM CLI VERSION**: ${{ inputs.dm_cli_version }}" >> $GITHUB_STEP_SUMMARY
echo "- **JOB VERSION**: ${{ inputs.job_version }}" >> $GITHUB_STEP_SUMMARY