-
Notifications
You must be signed in to change notification settings - Fork 1.1k
184 lines (164 loc) · 6.86 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
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
name: API integration Tests
on:
pull_request:
push:
branches:
- master
- test/*
- release-*
env:
GOPRIVATE: github.com/TykTechnologies
jobs:
test:
strategy:
matrix:
go-version: [1.16.x]
platform: [ubuntu-latest]
arch: [amd64]
node-version: [15.x]
runs-on: ${{ matrix.platform }}
steps:
- name: Set up Python 3.7
uses: actions/setup-python@v4
with:
python-version: 3.7
- name: Fix private module deps
env:
TOKEN: '${{ secrets.ORG_GH_TOKEN }}'
run: >
git config --global url."https://${TOKEN}@github.com".insteadOf "https://github.com"
- name: Checkout
uses: actions/checkout@v3
with:
path: tyk
token: ${{ secrets.ORG_GH_TOKEN }}
submodules: true
- name: Check if test framework branch exists
id: check_test_branch
env:
TOKEN: '${{ secrets.ORG_GH_TOKEN }}'
run: |
echo "branch=master" >> $GITHUB_OUTPUT
if [ ! -z "${{ github.head_ref }}" ] && git ls-remote --exit-code --heads https://${TOKEN}@github.com/TykTechnologies/tyk-automated-tests ${{ github.head_ref }}; then
echo "branch=${{ github.head_ref }}" >> $GITHUB_OUTPUT
fi
if [ ! -z "${{ github.base_ref }}" ] && git ls-remote --exit-code --heads https://${TOKEN}@github.com/TykTechnologies/tyk-automated-tests ${{ github.base_ref }}; then
echo "branch=${{ github.base_ref }}" >> $GITHUB_OUTPUT
fi
if [ ! -z "${{ github.ref }}" ] && git ls-remote --exit-code --heads https://${TOKEN}@github.com/TykTechnologies/tyk-automated-tests ${{ github.ref }}; then
echo "branch=${{ github.ref }}" >> $GITHUB_OUTPUT
fi
- name: Checkout test repository
uses: actions/checkout@v3
with:
repository: TykTechnologies/tyk-automated-tests
token: ${{ secrets.ORG_GH_TOKEN }}
path: tyk-automated-tests
ref: ${{ steps.check_test_branch.outputs.branch }}
- name: Check if dashboard branch exists
id: check_dashboard_branch
env:
TOKEN: '${{ secrets.ORG_GH_TOKEN }}'
run: |
echo "branch=master" >> $GITHUB_OUTPUT
if [ ! -z "${{ github.head_ref }}" ] && git ls-remote --exit-code --heads https://${TOKEN}@github.com/TykTechnologies/tyk-analytics ${{ github.head_ref }}; then
echo "branch=${{ github.head_ref }}" >> $GITHUB_OUTPUT
fi
if [ ! -z "${{ github.base_ref }}" ] && git ls-remote --exit-code --heads https://${TOKEN}@github.com/TykTechnologies/tyk-analytics ${{ github.base_ref }}; then
echo "branch=${{ github.base_ref }}" >> $GITHUB_OUTPUT
fi
if [ ! -z "${{ github.ref }}" ] && git ls-remote --exit-code --heads https://${TOKEN}@github.com/TykTechnologies/tyk-analytics ${{ github.ref }}; then
echo "branch=${{ github.ref }}" >> $GITHUB_OUTPUT
fi
- name: Checkout dashboard
uses: actions/checkout@v3
with:
repository: TykTechnologies/tyk-analytics
token: ${{ secrets.ORG_GH_TOKEN }}
submodules: true
path: tyk-analytics
ref: ${{ steps.check_dashboard_branch.outputs.branch }}
- name: start docker compose
run: docker-compose -f ci/ci_testing_env.yml up -d
env:
TYK_DB_LICENSEKEY: ${{secrets.DASH_LICENSE}}
DASH_REPO_PATH: /home/runner/work/tyk/tyk/tyk-analytics
GW_REPO_PATH: /home/runner/work/tyk/tyk/tyk
GOPATH: /home/runner/work/tyk/tyk
GOPRIVATE: github.com/TykTechnologies
TOKEN: ${{ secrets.ORG_GH_TOKEN }}
working-directory: tyk-automated-tests
- name: Install test dependecies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
working-directory: tyk-automated-tests
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
working-directory: tyk-automated-tests
- name: Waiting for dashboard
run: |
while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:3000/hello/)" != "200" ]]; do sleep 60 && echo "waiting for dashboard '$(date +"%T")'"; done
timeout-minutes: 15
- name: Test with pytest
id: test_execution
env:
TYK_TEST_BASE_URL: "http://localhost:3000/"
TYK_TEST_GW_URL: "https://localhost:8080/"
TYK_TEST_MONGODB: "tyk-mongo:27017"
TYK_TEST_REDIS: "tyk-redis"
TYK_TEST_DB_ADMIN: "12345"
TYK_TEST_GW_SECRET: "352d20ee67be67f6340b4c0605b044b7"
TYK_TEST_FEDERATION_HOST: federation
run: |
pytest
working-directory: tyk-automated-tests
timeout-minutes: 30
- name: Archive Integration tests report
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: api-test-report
path: ./tyk-automated-tests/reports/
- name: Notify slack
if: ${{ always() }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.GW_SLACK_WEBHOOK }}
SLACK_COLOR: ${{ job.status }}
SLACK_TITLE: "Result: ${{ steps.test_execution.outcome }}"
SLACK_USERNAME: API GW test automation
SLACK_FOOTER: "<https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|execution details>"
- name: Comment on PR
if: ${{ always() }} && github.event.issue.pull_request
uses: mshick/add-pr-comment@v1
with:
message: |
**API tests result: ${{ steps.test_execution.outcome }}** ${{ env.STATUS }}
Branch used: ${{ github.ref }}
Commit: ${{ github.event.after }} ${{ github.event.commits[0].message }}
Triggered by: ${{ github.event_name }} (@${{ github.actor }})
[Execution page](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
repo-token: ${{ secrets.ORG_GH_TOKEN }}
allow-repeats: true
env:
STATUS: "${{ steps.test_execution.outcome == 'success' && ':white_check_mark:' || ':no_entry_sign:' }}"
- name: Xray update
if: ${{ always() }} && github.event_name != 'pull_request'
run: |
./update_xray.sh
working-directory: tyk-automated-tests
env:
TEST: "QA-901"
STATUS: "${{ steps.test_execution.outcome }}"
CLIENT_ID: ${{secrets.XRAY_CLIENT_ID}}
CLIENT_SECRET: ${{secrets.XRAY_CLIENT_SECRET}}
BRANCH: ${{ github.ref }}
- name: Getting docker logs on failure
if: ${{ failure() }}
run: docker-compose -f ci/ci_testing_env.yml logs