-
Notifications
You must be signed in to change notification settings - Fork 16
148 lines (134 loc) · 5.06 KB
/
system_tests.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
142
143
144
145
146
147
148
name: Run system tests
on:
workflow_dispatch:
push:
branches:
- 'dev'
schedule:
- cron: '0 6 * * *' # 9:00 GMT+3
pull_request:
paths:
- 'tests/**'
env:
CI: true
jobs:
system-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: install docker compose
run: sudo apt-get install -y docker-compose
- name: Build compose
run: docker-compose up -d
- name: ⚙️ Install dependencies
uses: ./.github/workflows/install-pnpm
- name: Get installed Playwright version
id: playwright-version
run: |
PLAYWRIGHT_VERSION=$(node -e "console.log(require('yaml').parse(require('fs').readFileSync('./pnpm-lock.yaml', 'utf8')).importers['.'].devDependencies['@playwright/test'].version)")
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV
- name: Cache playwright binaries
uses: actions/cache@v3
id: playwright-cache
with:
path: |
~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}
- run: npx playwright install --with-deps
if: steps.playwright-cache.outputs.cache-hit != 'true'
- name: Run Playwright tests
if: github.event_name != 'schedule'
run: npx playwright test --grep @regress
- name: Run Playwright tests for schedule event
if: github.event_name == 'schedule'
run: npx playwright test --grep @fee-test
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
publish_report:
name: Publish HTML Report
if: success() || needs.system-tests.result == 'failure'
needs: [system-tests]
runs-on: ubuntu-latest
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 }}
steps:
- name: Checkout GitHub Pages Branch
uses: actions/checkout@v2
with:
repository: novasamatech/spektr-reports
ref: main
token: ${{ secrets.CREATE_TAG_PAT }}
- name: Set Git User
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Download zipped HTML report
uses: actions/download-artifact@v4
with:
name: playwright-report
path: ${{ env.HTML_REPORT_URL_PATH }}
- 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
run: |
FULL_HTML_REPORT_URL=https://novasamatech.github.io/spektr-reports/$HTML_REPORT_URL_PATH
echo "::notice title=📋 Published Playwright Test Report::$FULL_HTML_REPORT_URL"
echo "FULL_HTML_REPORT_URL<<EOF" >> $GITHUB_ENV
echo "$FULL_HTML_REPORT_URL" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- run: |
if [ "${{ github.event_name }}" = "schedule" ]; then
COMMIT_INFO="Branch: dev"
RUN_TYPE_INFO="🤑 Fee loading"
else
COMMIT_INFO="Commit: [${{ github.sha }}](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }})"
RUN_TYPE_INFO="✔ Regression"
fi
echo "COMMIT_INFO<<EOF" >> $GITHUB_ENV
echo "$COMMIT_INFO" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
echo "RUN_TYPE_INFO<<EOF" >> $GITHUB_ENV
echo "$RUN_TYPE_INFO" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
shell: bash
- name: Set Status
run: |
if [[ "${{ needs.system-tests.result }}" == 'failure' ]]; then
echo "STATUS=❌" >> $GITHUB_ENV
else
echo "STATUS=✅" >> $GITHUB_ENV
fi
- name: Notify Telegram channel
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: markdown
message: |
📋 Playwright Test Report Published
URL: ${{ env.FULL_HTML_REPORT_URL }}
Run type: ${{ env.RUN_TYPE_INFO }}
Status: ${{ env.STATUS }}
${{ env.COMMIT_INFO }}