Skip to content

Commit

Permalink
test new workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ermirizio committed Jul 13, 2023
1 parent acf6c2f commit 0ee4dac
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 80 deletions.
79 changes: 26 additions & 53 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,47 +55,9 @@ permissions:
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
Expand All @@ -104,22 +66,35 @@ jobs:
role-session-name: cipush
aws-region: eu-central-1

- id: ecr
uses: aws-actions/amazon-ecr-login@v1
- uses: aws-actions/amazon-ecr-login@v1
id: ecr

- uses: actions/checkout@v3

- name: Copy files to shared volumes

- name: env up
working-directory: auto
env:
confs_dir: /__w/tyk-pro/tyk-pro/auto/pro
run: |
cp -r $GITHUB_WORKSPACE/auto/pro/* /confs
cp -r /app/ci/certs/* /certs
cp -r /app/ci/graphql-faker/* /graphql
echo "registry=${{ steps.ecr.outputs.registry }}
tyk_sink_image=\${registry}/tyk-sink:${{ inputs.tyk-sink-version || 'v2.1.1' }}
tyk_image=\${registry}/tyk:${{ inputs.tyk-version || 'v4.3.4' }}
tyk_analytics_image=\${registry}/tyk-analytics:${{ inputs.tyk-analytics-version || 'v4.3.3' }}
tyk_pump_image=\${registry}/tyk-pump:${{ inputs.tyk-pump-version || 'v1.7.0' }}" > 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: env up
working-directory: auto
# env:
# confs_dir: /__w/tyk-pro/tyk-pro/auto/pro
env:
confs_dir: /__w/tyk-pro/tyk-pro/auto/pro
graphql_data: /__w/tyk-pro/tyk-pro/compose/volumes/test/graphql-faker
certs_dir: /__w/tyk-pro/tyk-pro/compose/volumes/gw/certs
run: |
ls $confs_dir
ls $graphql_data
ls $certs_dir
echo "registry=${{ steps.ecr.outputs.registry }}
tyk_sink_image=\${registry}/tyk-sink:${{ inputs.tyk-sink-version || 'v2.1.1' }}
tyk_image=\${registry}/tyk:${{ inputs.tyk-version || 'v4.3.4' }}
Expand All @@ -132,11 +107,11 @@ jobs:
- name: Docker ps
if: ${{always()}}
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
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
Expand All @@ -147,14 +122,12 @@ jobs:
docker ps -a
docker logs tyk-analytics
done
timeout-minutes: 15
timeout-minutes: 15

- name: Run pytest
working-directory: /app
run: |
echo "Curl dashboard"
ls
. $GITHUB_WORKSPACE/auto/test.env
echo "this are env vars"
env
pytest tests/gateway_api
docker run ${{ steps.ecr.outputs.registry }}/tyk-automated-tests:1.0.0-rc1 pytest /app/tests/gateway_api
9 changes: 2 additions & 7 deletions auto/deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ services:
container_name: graphql-faker
image: apisguru/graphql-faker:latest
volumes:
- graphql_volume:/workdir/
# - ${graphql_data}:/workdir/faker-schema.graphql
- ${graphql_data}:/workdir/faker-schema.graphql
command: "faker-schema.graphql"
ports:
- "9002:9002"
Expand All @@ -86,8 +85,4 @@ services:
redis:
condition: service_healthy
mongo:
condition: service_healthy

volumes:
graphql_volume:
external: true
condition: service_healthy
20 changes: 5 additions & 15 deletions auto/pro.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ services:
env_file:
- tyk.env
volumes:
# - ${certs_dir}:/etc/ssl/certs
- gw_certs_volume:/etc/ssl/certs/
# - ${confs_dir}:/conf/
- confs_volume:/conf/
- ${certs_dir}:/etc/ssl/certs
- ${confs_dir}:/conf/
ports:
- "6000:6000"
- "8003:8003"
Expand All @@ -25,8 +23,7 @@ services:
container_name: tyk-analytics
image: ${tyk_analytics_image}
volumes:
# - ${confs_dir}:/conf/
- confs_volume:/conf/
- ${confs_dir}:/conf/
ports:
- "3000:3000"
- "5000:5000"
Expand All @@ -40,8 +37,7 @@ services:
container_name: tyk-pump
image: ${tyk_pump_image}
volumes:
# - ${confs_dir}:/conf/
- confs_volume:/conf
- ${confs_dir}:/conf/
ports:
- "8061:8061"
env_file:
Expand Down Expand Up @@ -72,10 +68,4 @@ services:
image: hello-world:linux
depends_on:
gateway-checker:
condition: service_healthy

volumes:
confs_volume:
external: true
gw_certs_volume:
external: true
condition: service_healthy
10 changes: 5 additions & 5 deletions auto/test.env
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
TYK_TEST_BASE_URL=http://localhost:3000/
TYK_TEST_GW_URL=https://localhost:8080/
TYK_TEST_MONGODB=localhost:27017
TYK_TEST_REDIS=localhost
TYK_TEST_BASE_URL=http://tyk-analytics:3000/
TYK_TEST_GW_URL=https://tyk:8080/
TYK_TEST_MONGODB=mongo:27017
TYK_TEST_REDIS=redis
TYK_TEST_DB_ADMIN=12345
TYK_TEST_GW_SECRET=352d20ee67be67f6340b4c0605b044b7
TYK_TEST_DB_NAME=tyk_analytics
TYK_TEST_FEDERATION_HOST=federation
TYK_TEST_GRAPHQL_FAKER_HOST=graphql-faker
TYK_TEST_GRAPHQL_FAKER_SCHEMA_PATH=test-data/graphql-faker/faker-schema.graphql
TYK_TEST_GRAPHQL_FAKER_SCHEMA_PATH=test-data/graphql-faker/faker-schema.graphql

0 comments on commit 0ee4dac

Please sign in to comment.