-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (66 loc) · 2.48 KB
/
api-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
name: API-tests
on:
push:
branches:
- main
schedule:
- cron: '0 5,7,11,14 * * *'
workflow_dispatch:
inputs:
url:
description: 'Specify URL to run tests against'
required: true
default: 'https://atb-staging.api.mittatb.no'
waitSeconds:
description: 'Seconds to wait before test run'
required: true
default: '0'
jobs:
api-test:
name: API-tests
runs-on: ubuntu-latest
# As default, wait 0 sec for manual triggered and 300 sec for push (wait for new deploy)
steps:
- name: Set variables
env:
DEFAULT_URL: 'https://atb-staging.api.mittatb.no'
DEFAULT_WAIT_SECONDS: '300'
run: |
echo "INPUT_URL=${{ github.event.inputs.url || env.DEFAULT_URL }}" >> $GITHUB_ENV
echo "INPUT_WAIT_SECONDS=${{ github.event.inputs.waitSeconds || env.DEFAULT_WAIT_SECONDS }}" >> $GITHUB_ENV
- name: Sleep given seconds to wait for deploy
run: sleep ${{ env.INPUT_WAIT_SECONDS }}s
shell: bash
- name: Checkout
uses: actions/checkout@v4
with:
ref: main
- name: Install k6
run: |
curl https://github.com/grafana/k6/releases/download/v0.40.0/k6-v0.40.0-linux-amd64.tar.gz -L | tar xvz --strip-components 1
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install dependencies
run: |
cd test && yarn install
- name: Bundle with webpack
run: |
cd test && yarn webpack
- name: Run API tests
run: ./k6 run test/dist/k6.js --env host=${{ env.INPUT_URL }} --env runFrom=root --log-output=stdout --log-format=raw | tee test/dist/results/junitLog.txt
- name: Create JUnit from checks
run: python python-tools/apiCheckToJUnit/apiCheckToJUnit.py --file junitLog.txt --folder dist/results
working-directory: test
- name: Create combined JUnit
run: python python-tools/combineJUnit/combineJUnit.py --files junit_bff.xml,junitFromChecks.xml --folder dist/results --addTime true
working-directory: test
- name: Upload test report json
uses: actions/upload-artifact@v4
with:
name: junit-results
path: ./test/dist/results/combinedJUnit.xml
retention-days: 5
- name: Re-run API tests
run: ./k6 run test/dist/k6.js --env host=${{ env.INPUT_URL }} --env runFrom=root --env printJUnit=false --quiet