Skip to content

Add automation

Add automation #69

Workflow file for this run

name: Integration tests
on:
pull_request:
workflow_dispatch:
inputs:
tat-tests:
description: Run these tests from tyk-automated-tests to run, added to the pytest command line
type: string
default: 'tests/dashboard_api'
tyk-version:
description: ECR docker tag to use
type: string
default: master
tyk-analytics-version:
description: ECR docker tag to use
type: string
default: master
tyk-pump-version:
description: ECR docker tag to use
type: string
default: master
tyk-sink-version:
description: ECR docker tag to use
type: string
default: master
workflow_call:
inputs:
tat-tests:
description: Run these tests from tyk-automated-tests to run, added to the pytest command line
type: string
default: 'tests/dashboard_admin_api'
tyk-version:
description: ECR docker tag to use
type: string
default: master
tyk-analytics-version:
description: ECR docker tag to use
type: string
default: master
tyk-pump-version:
description: ECR docker tag to use
type: string
default: master
tyk-sink-version:
description: ECR docker tag to use
type: string
default: master
env:
GOPRIVATE: github.com/TykTechnologies
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
jobs:
ecr-login:
name: ecr-passwd
runs-on: ubuntu-latest
outputs:
aws-ecr-pass: ${{ steps.ecr-pass.outputs.ECR_PASS }}
steps:
- uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: arn:aws:iam::754489498669:role/ecr_rw_tyk
role-session-name: cipush
aws-region: eu-central-1
- name: Get ecr password
id: ecr-pass
run: |
echo "ECR_PASS=$(aws ecr get-login-password --region eu-central-1)" >> "$GITHUB_OUTPUT"
- name: Create docker Volume
run: docker volume create myvolume
# The job id corresponds to the environment type that the tests will run on
pro:
name: tyk-automated-tests on Tyk Pro
runs-on: ubuntu-latest
needs: ecr-login
container:
image: 754489498669.dkr.ecr.eu-central-1.amazonaws.com/tyk-automated-tests:1.0.0-rc1
credentials:
username: AWS
password: ${{ needs.ecr-login.outputs.aws-ecr-pass }}
volumes:
- myvolume:/workspace
steps:
- uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: arn:aws:iam::754489498669:role/ecr_rw_tyk
role-session-name: cipush
aws-region: eu-central-1
- id: ecr
uses: aws-actions/amazon-ecr-login@v1
- uses: actions/checkout@v3
- name: Copy files to volume
run: cp -r /__w/tyk-pro/tyk-pro/auto/pro /workspace
- name: DEBUG STEP
run: |
echo "-------CURRENT DIR--------"
pwd
# echo "-------RUNNER------------"
# ls -R /home/runner/work/
# ls -R
# echo "-------GH WORKSPACE--------"
# ls -R ${{ github.workspace }}
# exit 1
# cat ${{ github.workspace }}/auto/${{ github.job }}/tyk-analytics.conf
# ls /workspace/auto/pro
# cat /workspace/auto/pro/tyk-analytics.conf
- name: env up
working-directory: auto
env:
confs_dir: /__w/tyk-pro/tyk-pro/auto/pro
run: |
echo "CONFIG DIR: $confs_dir"
echo "registry=${{ steps.ecr.outputs.registry }}
tyk_sink_image=\${registry}/tyk-sink:${{ inputs.tyk-sink-version || 'master' }}
tyk_image=\${registry}/tyk:${{ inputs.tyk-version || 'master' }}
tyk_analytics_image=\${registry}/tyk-analytics:${{ inputs.tyk-analytics-version || 'master' }}
tyk_pump_image=\${registry}/tyk-pump:${{ inputs.tyk-pump-version || 'master' }}
confs_dir=/__w/tyk-pro/tyk-pro/auto/pro" > versions.env
# bring up env
cat versions.env
docker compose -f ${{ github.job }}.yml -f deps.yml --env-file versions.env --env-file tat.env up --quiet-pull -d
- name: DEBUG STEP 2
run: |
docker inspect tyk-analytics
- name: DEBUG STEP 3
run: |
ls /__w/tyk-pro/tyk-pro/auto/pro
- name: Docker ps
shell: bash
run: docker ps
- name: Waiting for dashboard
shell: bash
run: |
while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:3000/hello/)" != "200" ]];do
sleep 60
echo "waiting for dashboard '$(date +"%T")'"
docker ps -a
docker logs tyk-analytics
done
timeout-minutes: 2
- name: Run pytest
working-directory: /app
run: |
echo "This is home: $GITHUB_WORKSPACE"
. $GITHUB_WORKSPACE/auto/test.env
pytest ${{ inputs.tat-tests }}