Update api-tests.yml #7995
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: API integration Tests | |
on: | |
pull_request: | |
push: | |
branches: | |
- master | |
- test/* | |
- release-* | |
env: | |
GOPRIVATE: github.com/TykTechnologies | |
TYK_TEST_FEDERATION_HOST: federation | |
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@v2 | |
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 test framework | |
uses: actions/checkout@v2 | |
with: | |
path: tyk-automated-tests | |
token: ${{ secrets.ORG_GH_TOKEN }} | |
submodules: true | |
- name: Check if dashboard branch exists | |
id: check_test_branch | |
env: | |
TOKEN: '${{ secrets.ORG_GH_TOKEN }}' | |
run: | | |
echo "::set-output name=branch::master" | |
if [ ! -z "${{ github.head_ref }}" ] && git ls-remote --exit-code --heads https://${TOKEN}@github.com/TykTechnologies/tyk-analytics ${{ github.head_ref }}; then | |
echo "::set-output name=branch::${{ github.head_ref }}" | |
fi | |
if [ ! -z "${{ github.base_ref }}" ] && git ls-remote --exit-code --heads https://${TOKEN}@github.com/TykTechnologies/tyk-analytics ${{ github.base_ref }}; then | |
echo "::set-output name=branch::${{ github.base_ref }}" | |
fi | |
if [ ! -z "${{ github.ref }}" ] && git ls-remote --exit-code --heads https://${TOKEN}@github.com/TykTechnologies/tyk-analytics ${{ github.ref }}; then | |
echo "::set-output name=branch::${{ github.ref }}" | |
fi | |
- name: Checkout dashboard | |
uses: actions/checkout@v2 | |
with: | |
repository: TykTechnologies/tyk-analytics | |
token: ${{ secrets.ORG_GH_TOKEN }} | |
submodules: true | |
path: tyk-analytics | |
ref: ${{ steps.check_test_branch.outputs.branch }} | |
- name: Check if GW branch exists | |
id: check_GW_branch | |
env: | |
TOKEN: '${{ secrets.ORG_GH_TOKEN }}' | |
run: | | |
echo "::set-output name=branch::master" | |
if git ls-remote --exit-code --heads https://${TOKEN}@github.com/TykTechnologies/tyk ${{ github.base_ref }}; then | |
echo "::set-output name=branch::${{ github.base_ref }}" | |
fi | |
if git ls-remote --exit-code --heads https://${TOKEN}@github.com/TykTechnologies/tyk ${{ github.head_ref }}; then | |
echo "::set-output name=branch::${{ github.head_ref }}" | |
fi | |
if git ls-remote --exit-code --heads https://${TOKEN}@github.com/TykTechnologies/tyk ${{ github.ref }}; then | |
echo "::set-output name=branch::${{ github.ref }}" | |
fi | |
echo "Branch from dash: ${branch}" | |
- name: Checkout GW repository | |
uses: actions/checkout@v2 | |
with: | |
repository: TykTechnologies/tyk | |
path: tyk | |
token: ${{ secrets.ORG_GH_TOKEN }} | |
submodules: true | |
ref: ${{ steps.check_GW_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-automated-tests/tyk-automated-tests/tyk-analytics | |
GW_REPO_PATH: /home/runner/work/tyk-automated-tests/tyk-automated-tests/tyk | |
GOPATH: /home/runner/work/tyk-automated-tests/tyk-automated-tests | |
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: "localhost" | |
TYK_TEST_DB_ADMIN: "12345" | |
TYK_TEST_GW_SECRET: "352d20ee67be67f6340b4c0605b044b7" | |
TYK_TEST_FEDERATION_HOST: federation | |
TYK_TEST_GRAPHQL_FAKER_HOST: graphql-faker | |
TYK_TEST_RESTCOUNTRIES_HOST: restcountries | |
run: | | |
pytest | |
working-directory: tyk-automated-tests | |
- name: Archive Integration tests report | |
if: ${{ always() }} | |
uses: actions/upload-artifact@v2 | |
with: | |
name: api-test-report | |
path: ./tyk-automated-tests/reports/ | |
- 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: Getting dashboard logs on failure | |
if: ${{ failure() }} | |
run: docker logs tyk-dashboard | |
- name: Getting gateway logs on failure | |
if: ${{ failure() }} | |
run: docker logs tyk-gateway |