Skip to content

Commit

Permalink
Auto generated from templates by gromit
Browse files Browse the repository at this point in the history
  • Loading branch information
Gromit committed Jul 17, 2024
1 parent 63c7616 commit 1b25c48
Showing 1 changed file with 19 additions and 62 deletions.
81 changes: 19 additions & 62 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ jobs:
type=semver,pattern={{version}},prefix=v
- name: push image to CI
if: ${{ matrix.golang_cross == '1.21-bookworm' }}
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
context: "dist"
platforms: linux/amd64,linux/arm64
Expand Down Expand Up @@ -167,7 +167,7 @@ jobs:
labels: "org.opencontainers.image.title=tyk-pump (distroless) \norg.opencontainers.image.description=Tyk Analytics Pump to move analytics data from Redis to any supported back end (multiple back ends can be written to at once).\norg.opencontainers.image.vendor=tyk.io\norg.opencontainers.image.version=${{ github.ref_name }}\n"
- name: build multiarch image
if: ${{ matrix.golang_cross == '1.21-bookworm' }}
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
context: "dist"
platforms: linux/amd64,linux/arm64
Expand Down Expand Up @@ -196,7 +196,8 @@ jobs:
dist/*.rpm
!dist/*PAYG*.rpm
test-controller-api:
needs: goreleaser
needs:
- goreleaser
runs-on: ubuntu-latest
outputs:
envfiles: ${{ steps.params.outputs.envfiles }}
Expand All @@ -207,12 +208,13 @@ jobs:
id: params
shell: bash
env:
# Cover pull_request_target too
# startsWith covers pull_request_target too
BASE_REF: ${{startsWith(github.event_name, 'pull_request') && github.base_ref || github.ref_name}}
VARIATION: test
run: |
set -eo pipefail
endpoint="http://tui.internal.dev.tyk.technology/api/tyk-pump/$BASE_REF/${{ github.event_name}}/api"
curl="curl -s --retry 5 --retry-delay 10 --fail-with-body --retry-all-errors"
endpoint="http://tui.internal.dev.tyk.technology/v2/$VARIATION/tyk-pump/$BASE_REF/${{ github.event_name}}/api"
curl="curl -s --retry 5 --retry-delay 10 --fail-with-body"
echo "pump<<EOF
$($curl ${endpoint}/Pump)
EOF
Expand All @@ -222,13 +224,12 @@ jobs:
envfiles<<EOF
$($curl ${endpoint}/EnvFiles)
EOF" | tee -a "$GITHUB_OUTPUT"
[[ $VARIATION =~ test ]] && echo "::warning file=release.yml,line=100,col=5,endColumn=7::Using test variation"
api-tests:
needs:
- goreleaser
- test-controller-api
runs-on: ubuntu-latest-m-2
env:
METADATA_REPORT_PATH: /tmp/metadata.toml
XUNIT_REPORT_PATH: ${{ github.workspace }}/reports/pytest-report.xml
permissions:
id-token: write # This is required for requesting the Github JWT
Expand All @@ -238,9 +239,6 @@ jobs:
matrix:
envfiles: ${{ fromJson(needs.test-controller-api.outputs.envfiles) }}
sink: ${{ fromJson(needs.test-controller-api.outputs.sink) }}
include:
- db: postgres15
markers: "and not sql"
steps:
- uses: aws-actions/configure-aws-credentials@v4
with:
Expand All @@ -251,14 +249,14 @@ jobs:
uses: aws-actions/amazon-ecr-login@v2
with:
mask-password: 'true'
# Only ${{ github.actor }} has access
# See https://github.com/mxschmitt/action-tmate#use-registered-public-ssh-keys
- name: Setup tmate session only in debug mode
uses: mxschmitt/action-tmate@v3
if: runner.debug == '1'
with:
detached: true
limit-access-to-actor: true
# Only ${{ github.actor }} has access
# See https://github.com/mxschmitt/action-tmate#use-registered-public-ssh-keys
- name: fetch env from tyk-ci
env:
GH_TOKEN: ${{ github.token }}
Expand All @@ -275,53 +273,20 @@ jobs:
TYK_DB_LICENSEKEY: ${{ secrets.DASH_LICENSE }}
TYK_MDCB_LICENSE: ${{ secrets.MDCB_LICENSE }}
BASE_REF: ${{startsWith(github.event_name, 'pull_request') && github.base_ref || github.ref_name}}
run: |
match_tag=${{steps.ecr.outputs.registry}}/$REPO:$BASE_REF
tags=(${{ needs.goreleaser.outputs.tags }})
docker run -q --rm -v ~/.docker/config.json:/root/.docker/config.json tykio/gromit policy match ${tags[0]} ${match_tag} 2>versions.env
echo '# alfa and beta have to come after the override
tyk_alfa_image=$tyk_image
tyk_beta_image=$tyk_image
ECR=${{steps.ecr.outputs.registry}}
tyk_sink_image=${{matrix.sink}}
confs_dir=./pro-ha
env_file=local-${{ matrix.envfiles.db }}.env' >> versions.env
echo "::group::versions"
cat versions.env
echo "::endgroup::"
# Add Tyk component config variations to $env_file
cat confs/${{ matrix.envfiles.config }}.env >> local-${{ matrix.envfiles.db }}.env
# bring up env, the project name is important
docker compose -p auto -f pro-ha.yml -f deps_pro-ha.yml -f ${{ matrix.envfiles.db }}.yml -f ${{ matrix.envfiles.cache }}.yml --env-file versions.env --profile master-datacenter up --quiet-pull -d
./dash-bootstrap.sh http://localhost:3000
docker compose -p auto -f pro-ha.yml -f deps_pro-ha.yml -f ${{ matrix.envfiles.db }}.yml -f ${{ matrix.envfiles.cache }}.yml --env-file versions.env --profile slave-datacenter up --quiet-pull -d
run: "match_tag=${{steps.ecr.outputs.registry}}/tyk-pump:$BASE_REF\ntags=(${{ needs.goreleaser.outputs.tags }})\ndocker run -q --rm -v ~/.docker/config.json:/root/.docker/config.json tykio/gromit policy match ${tags[0]} ${match_tag} 2>versions.env\necho '# alfa and beta have to come after the override\ntyk_alfa_image=$tyk_image\ntyk_beta_image=$tyk_image\nECR=${{steps.ecr.outputs.registry}}\ntyk_sink_image=${{matrix.sink}}\nconfs_dir=./pro-ha\nenv_file=local.env' >> versions.env\necho \"::group::versions\"\ncat versions.env\necho \"::endgroup::\"\n# Add Tyk component config variations to $env_file\ncat confs/${{ matrix.envfiles.config }}.env >> local.env\n# bring up env, the project name is important\ndocker compose -p auto -f pro-ha.yml -f deps_pro-ha.yml -f ${{ matrix.envfiles.db }}.yml -f ${{ matrix.envfiles.cache }}.yml --env-file versions.env --profile master-datacenter up --quiet-pull -d\n./dash-bootstrap.sh http://localhost:3000\ndocker compose -p auto -f pro-ha.yml -f deps_pro-ha.yml -f ${{ matrix.envfiles.db }}.yml -f ${{ matrix.envfiles.cache }}.yml --env-file versions.env --profile slave-datacenter up --quiet-pull -d \n"
- name: Run tests
working-directory: auto
id: test_execution
env:
# Cover pull_request_target too
BASE_REF: ${{startsWith(github.event_name, 'pull_request') && github.base_ref || github.ref_name }}
run: |
# Generate report id
echo "id=$(date +%s%N)" >> $GITHUB_OUTPUT
# Run tests
set -o pipefail
echo "### API tests ${{ matrix.envfiles.db }} ${{ matrix.envfiles.conf }}" >> $GITHUB_STEP_SUMMARY
if docker run --rm --network auto_default --env-file pytest.env -v ${{ github.workspace }}/reports:/app/reports \
${{ steps.ecr.outputs.registry }}/tyk-automated-tests:$BASE_REF \
pytest -c pytest_ci.ini --junitxml=./${XUNIT_REPORT_PATH#"${{ github.workspace }}"} --ci -m "not local and not dind ${{ matrix.markers }}" | tee tests.out; then
echo "All tests passed!" >> $GITHUB_STEP_SUMMARY
else
echo "::error title=API tests ${{ matrix.envfiles.db }} ${{ matrix.envfiles.conf }}::Test execution failed"
cat tests.out >> $GITHUB_STEP_SUMMARY
exit 1
fi
- name: Generate metadata
run: "# Generate report id\necho \"id=$(date +%s%N)\" >> $GITHUB_OUTPUT\ncommon_cmd=\"\"\ncmd=\"docker run --rm --network auto_default --env-file pytest.env -v ${{ github.workspace }}/reports:/app/reports\n ${{ steps.ecr.outputs.registry }}/tyk-automated-tests:$BASE_REF\n pytest -c pytest_ci.ini --junitxml=./${XUNIT_REPORT_PATH --ci -m ${{ matrix.envfiles.apimarkers }} | tee tests.out\" \n# Run tests\nset -o pipefail\necho \"### API tests ${{ matrix.envfiles.db }} ${{ matrix.envfiles.conf }}\" >> $GITHUB_STEP_SUMMARY\nif $cmd; then\n echo \"All tests passed!\" >> $GITHUB_STEP_SUMMARY\nelse\n echo \"::error title=API tests ${{ matrix.envfiles.db }} ${{ matrix.envfiles.conf }}::Test execution failed\"\n cat tests.out >> $GITHUB_STEP_SUMMARY\n exit 1\nfi \n"
- name: Generate metadata and upload test reports
if: always() && steps.test_execution.outcome != 'skipped'
id: metadata_report
env:
BASE_REF: ${{startsWith(github.event_name, 'pull_request') && github.base_ref || github.ref}}
REPORT_NAME: ${{ github.repository }}_${{ github.run_id }}_${{ github.run_attempt }}-${{steps.test_execution.outputs.id}}
METADATA_REPORT_PATH: /tmp/metadata.toml
run: |
# Generate metadata report
echo "[metadata]
Expand Down Expand Up @@ -357,26 +322,18 @@ jobs:
TYK_MDCB_LICENSE: ${{ secrets.MDCB_LICENSE }}
ECR: ${{ steps.ecr.outputs.registry }}
run: |
docker compose -p auto -f pro-ha.yml -f deps_pro-ha.yml -f ${{ matrix.envfiles.db }}.yml -f ${{ matrix.envfiles.cache }}.yml --env-file versions.env --profile all logs | sort > ${{ github.workspace }}/docker-compose.log
docker compose -p auto -f pro-ha.yml -f deps_pro-ha.yml -f ${{ matrix.envfiles.db }}.yml -f ${{ matrix.envfiles.cache }}.yml --env-file versions.env --profile all logs | sort > ${{ github.workspace }}/docker-compose.log
echo "::group::DockerLogs"
cat ${{ github.workspace }}/docker-compose.log
echo "::endgroup::"
- name: Upload Artifact
- name: Upload compose logs
uses: actions/upload-artifact@v4
if: failure() && (steps.test_execution.outcome != 'success' || steps.env_up.outcome != 'success')
with:
name: docker-compose-logs-${{ github.job }}-${{ matrix.envfiles.db }}-${{ matrix.envfiles.conf }}-${{ github.run_id }}
path: ${{ github.workspace }}/docker-compose.log
retention-days: 3
overwrite: true
- name: Archive Integration tests report
if: always()
uses: actions/upload-artifact@v4
with:
name: api-test-report-${{ matrix.envfiles.db }}-${{ matrix.envfiles.conf }}-${{ github.run_id }}
retention-days: 3
path: ${{ github.workspace }}/reports
overwrite: true
upgrade-deb:
services:
httpbin.org:
Expand Down Expand Up @@ -415,7 +372,7 @@ jobs:
RUN dpkg -i tyk-pump.deb
' > Dockerfile
- name: install on ${{ matrix.distro }}
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
context: "."
platforms: linux/${{ matrix.arch }}
Expand Down Expand Up @@ -456,7 +413,7 @@ jobs:
RUN rpm -Uvh --force tyk-pump.rpm
' > Dockerfile
- name: install on ${{ matrix.distro }}
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
context: "."
file: Dockerfile
Expand Down

0 comments on commit 1b25c48

Please sign in to comment.