From 0d06e7beaccfe1b7273ef58bf782e9ce1e629644 Mon Sep 17 00:00:00 2001 From: Gromit Date: Thu, 18 Jul 2024 07:11:43 +0000 Subject: [PATCH] Auto generated from templates by gromit --- .github/workflows/release.yml | 130 +++++++++++----------------------- 1 file changed, 43 insertions(+), 87 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d67c5ca94e47..69c89caa47a2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -138,7 +138,7 @@ jobs: type=semver,pattern={{version}},prefix=v - name: push image to CI if: ${{ matrix.golang_cross == '1.21-bullseye' }} - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 with: context: "dist" platforms: linux/amd64,linux/arm64 @@ -167,7 +167,7 @@ jobs: labels: "org.opencontainers.image.title=tyk-gateway \norg.opencontainers.image.description=Tyk Open Source API Gateway written in Go, supporting REST, GraphQL, TCP and gRPC protocols\norg.opencontainers.image.vendor=tyk.io\norg.opencontainers.image.version=${{ github.ref_name }}\n" - name: build multiarch image if: ${{ matrix.golang_cross == '1.21-bullseye' }} - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 with: context: "dist" platforms: linux/amd64,linux/arm64 @@ -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 }} @@ -207,28 +208,19 @@ 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/$BASE_REF/${{ github.event_name}}/api" - curl="curl -s --retry 5 --retry-delay 10 --fail-with-body --retry-all-errors" - echo "pump<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_pump_image=${{matrix.pump}} - 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 - - name: Run tests - working-directory: auto + run: "match_tag=${{steps.ecr.outputs.registry}}/tyk:$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_pump_image=${{matrix.pump}}\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 API tests 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] @@ -364,11 +319,11 @@ 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: @@ -376,33 +331,39 @@ jobs: 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 + test-controller-distros: + needs: + - goreleaser + runs-on: ubuntu-latest + outputs: + deb: ${{ steps.params.outputs.deb }} + rpm: ${{ steps.params.outputs.rpm }} + steps: + - name: set params + id: params + shell: bash + env: + # 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 + curl -s --retry 5 --retry-delay 10 --fail-with-body "http://tui.internal.dev.tyk.technology/v2/$VARIATION/tyk/$BASE_REF/${{ github.event_name}}/api/Distros.gho" | tee -a "$GITHUB_OUTPUT" + [[ $VARIATION =~ test ]] && echo "::warning file=release.yml,line=100,col=5,endColumn=7::Using test variation" upgrade-deb: services: httpbin.org: image: kennethreitz/httpbin runs-on: ubuntu-latest - needs: goreleaser + needs: + - test-controller-distros strategy: fail-fast: false matrix: arch: - amd64 - arm64 - distro: - - ubuntu:xenial - - ubuntu:bionic - - ubuntu:focal - - ubuntu:jammy - - debian:bullseye - - debian:bookworm + distro: ${{ fromJson(needs.test-controller-distros.outputs.deb) }} steps: - uses: actions/checkout@v4 with: @@ -425,7 +386,7 @@ jobs: CMD ["/opt/tyk-gateway/tyk", "--conf", "/opt/tyk-gateway/tyk.conf"] ' > Dockerfile - name: install on ${{ matrix.distro }} - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 with: context: "." platforms: linux/${{ matrix.arch }} @@ -447,12 +408,7 @@ jobs: strategy: fail-fast: false matrix: - distro: - - amazonlinux:2023 - - registry.access.redhat.com/ubi8/ubi - - registry.access.redhat.com/ubi9/ubi - - amazonlinux:2 - - registry.access.redhat.com/ubi7/ubi + distro: ${{ fromJson(needs.test-controller-distros.outputs.rpm) }} steps: - uses: actions/checkout@v4 with: @@ -476,7 +432,7 @@ jobs: CMD ["/opt/tyk-gateway/tyk", "--conf", "/opt/tyk-gateway/tyk.conf"] ' > Dockerfile - name: install on ${{ matrix.distro }} - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 with: context: "." file: Dockerfile