Add automation #81
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: 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 shared docker Volumes for DinD | |
run: | | |
docker volume create confs_volume | |
docker volume create gw_certs_volume | |
docker volume create graphql_volume | |
# 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: | |
- confs_volume:/confs | |
- gw_certs_volume:/certs | |
- graphql_volume:/graphql | |
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 shared volumes | |
run: | | |
cp -r $GITHUB_WORKSPACE/auto/pro/* /confs | |
cp -r /app/ci/certs/* /certs | |
cp -r /app/ci/graphql-faker/* /graphql | |
- name: env up | |
working-directory: auto | |
# env: | |
# confs_dir: /__w/tyk-pro/tyk-pro/auto/pro | |
run: | | |
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' }}" > 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: Docker ps | |
if: ${{failure()}} | |
run: docker ps | |
- name: Docker Compose logs | |
if: ${{failure()}} | |
working-directory: auto | |
run: docker compose -f ${{ github.job }}.yml -f deps.yml --env-file versions.env --env-file tat.env logs | |
# - 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: 5 | |
- name: Run pytest | |
working-directory: /app | |
run: | | |
echo "This is home: $GITHUB_WORKSPACE" | |
. $GITHUB_WORKSPACE/auto/test.env | |
pytest ${{ inputs.tat-tests }} |