forked from IntersectMBO/govtool
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_integration_playwright.yml
More file actions
243 lines (215 loc) · 8.33 KB
/
test_integration_playwright.yml
File metadata and controls
243 lines (215 loc) · 8.33 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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
name: Integration Test [Playwright]
permissions:
contents: read
checks: write
statuses: write
on:
workflow_dispatch:
inputs:
deployment:
required: true
type: choice
default: "p80-z6b8d2f7a-ze34e4cb2-gtw.z937eb260.rustrocks.fr"
options:
- "sanchogov.tools"
- "staging.govtool.byron.network"
- "govtool.cardanoapi.io"
- "p80-z6b8d2f7a-ze34e4cb2-gtw.z937eb260.rustrocks.fr"
- "preview.gov.tools"
- "gov.tools"
- "p80-z78acf3c2-zded6a792-gtw.z937eb260.rustrocks.fr"
- "govtool-preview.cardanoapi.io"
network:
required: true
type: choice
default: "preview"
options:
- "sanchonet"
- "preview"
- "mainnet"
- "preprod"
workflow_run:
workflows: ["Check and Build QA"]
types: [completed]
branches:
- test
- infra/test-chores
schedule:
- cron: "0 0 * * *" # 12AM UTC
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
integration-tests:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' || github.event.schedule }}
outputs:
start_time: ${{ steps.set-pending-status.outputs.timestamp }}
status: ${{ steps.run-test.outcome }}
defaults:
run:
working-directory: tests/govtool-frontend/playwright
steps:
- uses: actions/checkout@v4
with:
ref: ${{ env.COMMIT_SHA }}
- name: Set pending commit status
if: ${{ !github.event.schedule }}
id: set-pending-status
run: |
echo "timestamp=$(date +%s)" >> $GITHUB_OUTPUT
curl -X POST -H "Authorization: Bearer ${{ github.token }}" \
-H "Accept: application/vnd.github+json" \
https://api.github.com/repos/${{ github.repository }}/statuses/${{ env.COMMIT_SHA }} \
-d "{\"state\": \"pending\", \"context\": \"Playwright Tests : ${{env.HOST_URL}}\", \"target_url\": \"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}"
- uses: actions/setup-node@v4
with:
node-version: "18"
cache: "npm"
cache-dependency-path: "./tests/govtool-frontend/playwright/package-lock.json"
- name: Install dependencies
run: npm ci
- name: Cache Playwright browsers
id: cache-playwright-browsers
uses: actions/cache@v4
with:
path: |
~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-browsers
- name: Install Playwright browsers if not cached
if: steps.cache-playwright-browsers.outputs.cache-hit != 'true'
run: npx playwright install --with-deps
- name: Initial delay 5 mins
run: sleep 300
- name: Run tests
id: run-test
run: |
mkdir -p ./lib/_mock
chmod +w ./lib/_mock
npm run generate-wallets
# Set API keys based on the network
if [[ "${{ env.NETWORK }}" == "preprod" ]]; then
export BLOCKFROST_API_KEY="${{ secrets.BLOCKFROST_API_KEY_PREPROD }}"
elif [[ "${{ env.NETWORK }}" == "sanchonet" ]]; then
export BLOCKFROST_API_KEY="${{ secrets.BLOCKFROST_API_KEY_SANCHONET }}"
elif [[ "${{ env.NETWORK }}" == "preview" ]]; then
export BLOCKFROST_API_KEY="${{ secrets.BLOCKFROST_API_KEY_PREVIEW }}"
else
export BLOCKFROST_API_KEY="${{ secrets.BLOCKFROST_API_KEY_MAINNET }}"
fi
# Set schedule workflow variable
if [[ "$GITHUB_EVENT_NAME" == "schedule" ]]; then
export SCHEDULED_WORKFLOW="true"
fi
npm run test:headless
- name: Upload report
uses: actions/upload-artifact@v4
if: always()
with:
name: allure-results
path: tests/govtool-frontend/playwright/allure-results
- name: Upload lock logs
uses: actions/upload-artifact@v4
if: always()
with:
name: lock-logs
path: tests/govtool-frontend/playwright/lock_logs.txt
env:
DOCS_URL: ${{ vars.DOCS_URL }}
KUBER_API_KEY: ${{secrets.KUBER_API_KEY}}
NETWORK: ${{ inputs.network || vars.NETWORK }}
TEST_WORKERS: ${{vars.TEST_WORKERS}}
CI: ${{vars.CI}}
FAUCET_ADDRESS: ${{vars.FAUCET_ADDRESS}}
CARDANOAPI_METADATA_URL: ${{vars.CARDANOAPI_METADATA_URL}}
FAUCET_PAYMENT_PRIVATE: ${{secrets.FAUCET_PAYMENT_PRIVATE}}
FAUCET_STAKE_PRIVATE: ${{secrets.FAUCET_STAKE_PRIVATE}}
publish-report:
runs-on: ubuntu-latest
if: always() && needs.integration-tests.result != 'skipped'
needs: integration-tests
outputs:
report_number: ${{ steps.report-details.outputs.report_number }}
group_name: ${{ steps.set-deployment-url.outputs.group_name }}
steps:
- uses: actions/checkout@v4
- name: Download report
uses: actions/download-artifact@v4
with:
name: allure-results
path: allure-results
- name: Get Allure history
uses: actions/checkout@v4
continue-on-error: true
with:
ref: gh-pages
path: gh-pages
repository: ${{vars.GH_PAGES}}
ssh-key: ${{ secrets.DEPLOY_KEY }}
- name: Set Deployment Environment
id: set-deployment-url
run: |
chmod +x .github/scripts/set_deployment_environment.sh
.github/scripts/set_deployment_environment.sh
- name: Remove oldest report to save space
if: ${{success()}}
run: |
chmod +x .github/scripts/remove_oldest_report.sh
.github/scripts/remove_oldest_report.sh
- name: Generate report details
id: report-details
run: |
chmod +x .github/scripts/generate_report_details.sh
.github/scripts/generate_report_details.sh
- name: Build report
uses: simple-elf/allure-report-action@master
if: always()
id: allure-report
with:
allure_results: allure-results
gh_pages: gh-pages/${{steps.set-deployment-url.outputs.group_name}}/${{env.REPORT_NAME}}
allure_report: allure-report
allure_history: allure-history
keep_reports: 2000
report_url: ${{steps.report-details.outputs.report_url}}
github_run_num: ${{steps.report-details.outputs.report_number}}
- name: Generate Latest Report
run: |
chmod +x .github/scripts/generate_latest_report_redirect.sh
.github/scripts/generate_latest_report_redirect.sh ${{steps.report-details.outputs.report_number}}
- name: Deploy report to Github Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
ssh-key: ${{ secrets.DEPLOY_KEY }}
repository-name: ${{vars.GH_PAGES}}
branch: gh-pages
folder: build
target-folder: ${{steps.set-deployment-url.outputs.group_name}}/${{ env.REPORT_NAME }}
publish-status:
runs-on: ubuntu-latest
if: always() && needs.integration-tests.result != 'skipped'
needs: [integration-tests, publish-report]
steps:
- uses: actions/checkout@v4
- name: Download results
uses: actions/download-artifact@v4
with:
name: allure-results
path: allure-results
- name: Set Commit Status
if: always() && !github.event.schedule
run: |
chmod +x .github/scripts/set_commit_status.sh
.github/scripts/set_commit_status.sh
env:
START_TIME: ${{ needs.integration-tests.outputs.start_time }}
TEST_STATUS: ${{ needs.integration-tests.outputs.status }}
REPORT_NUMBER: ${{ needs.publish-report.outputs.report_number }}
GITHUB_TOKEN: ${{ github.token }}
GROUP_NAME: ${{ needs.publish-report.outputs.group_name }}
env:
HOST_URL: https://${{ github.event.schedule && 'preview.gov.tools' || (inputs.deployment || 'p80-z6b8d2f7a-ze34e4cb2-gtw.z937eb260.rustrocks.fr') }}
DEPLOYMENT: ${{ github.event.schedule && 'preview.gov.tools' || inputs.deployment || 'p80-z6b8d2f7a-ze34e4cb2-gtw.z937eb260.rustrocks.fr'}}
REPORT_NAME: ${{ github.event.schedule && 'nightly-'}}govtool-frontend
GH_PAGES: ${{vars.GH_PAGES}}
COMMIT_SHA: ${{ github.event.workflow_run.head_sha || github.sha }}