Skip to content

[SYSE-372 release-5-lts] Implement custom rules for enterprise artifacts in package promotion #6941

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: release-5-lts
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
229 changes: 60 additions & 169 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ on:
- 'v*'
env:
GOPRIVATE: github.com/TykTechnologies
VARIATION: inverted
VARIATION: prod-variation
DOCKER_BUILD_SUMMARY: false
DOCKER_BUILD_RECORD_UPLOAD: false
# startsWith covers pull_request_target too
Expand All @@ -47,9 +47,9 @@ jobs:
goreleaser: 'ci/goreleaser/goreleaser.yml'
cgo: 1
rpmvers: 'el/7 el/8 el/9 amazon/2 amazon/2023'
debvers: 'ubuntu/xenial ubuntu/bionic ubuntu/focal ubuntu/jammy debian/jessie debian/buster debian/bullseye debian/bookworm'
debvers: 'ubuntu/xenial ubuntu/bionic ubuntu/focal ubuntu/jammy ubuntu/noble debian/jessie debian/buster debian/bullseye debian/bookworm debian/trixie'
outputs:
tags: ${{ steps.ci_metadata.outputs.tags }}
std_tags: ${{ steps.ci_metadata_std.outputs.tags }}
commit_author: ${{ steps.set_outputs.outputs.commit_author}}
steps:
- name: Checkout of tyk
Expand Down Expand Up @@ -145,12 +145,13 @@ jobs:
if: ${{ matrix.golang_cross == '1.16' }}
with:
mask-password: 'true'
- name: Docker metadata for CI
id: ci_metadata
- name: Docker metadata for std CI
id: ci_metadata_std
if: ${{ matrix.golang_cross == '1.16' }}
uses: docker/metadata-action@v5
with:
images: ${{ steps.ecr.outputs.registry }}/tyk
images: |
${{ steps.ecr.outputs.registry }}/tyk
flavor: |
latest=false
tags: |
Expand All @@ -160,48 +161,57 @@ jobs:
type=semver,pattern={{major}},prefix=v
type=semver,pattern={{major}}.{{minor}},prefix=v
type=semver,pattern={{version}},prefix=v
- name: push image to CI
- name: push std image to CI
if: ${{ matrix.golang_cross == '1.16' }}
uses: docker/build-push-action@v6
with:
context: "dist"
platforms: linux/amd64,linux/arm64
platforms: linux/amd64,linux/arm64,linux/s390x
file: ci/Dockerfile.std
provenance: mode=max
sbom: true
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.ci_metadata.outputs.tags }}
labels: ${{ steps.tag_metadata.outputs.labels }}
tags: ${{ steps.ci_metadata_std.outputs.tags }}
labels: ${{ steps.ci_metadata_std.outputs.labels }}
build-args: |
BUILD_PACKAGE_NAME=tyk-gateway
- name: Docker metadata for tag push
id: tag_metadata
id: tag_metadata_std
uses: docker/metadata-action@v5
with:
images: |
tykio/tyk-gateway
docker.tyk.io/tyk-gateway/tyk-gateway

tykio/tyk-gateway
flavor: |
latest=false
prefix=v
tags: |
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{version}}
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: push image to prod
labels: |
org.opencontainers.image.title=Tyk Gateway
org.opencontainers.image.description=Tyk Open Source API Gateway written in Go, supporting REST, GraphQL, TCP and gRPC protocols
org.opencontainers.image.vendor=tyk.io
org.opencontainers.image.version=${{ github.ref_name }}
- name: push std image to prod
if: ${{ matrix.golang_cross == '1.16' }}
uses: docker/build-push-action@v6
with:
context: "dist"
platforms: linux/amd64,linux/arm64
platforms: linux/amd64,linux/arm64,linux/s390x
file: ci/Dockerfile.std
provenance: mode=max
sbom: true
cache-from: type=gha
cache-to: type=gha,mode=max
push: ${{ startsWith(github.ref, 'refs/tags') }}
tags: ${{ steps.tag_metadata.outputs.tags }}
labels: ${{ steps.tag_metadata.outputs.labels }}
tags: ${{ steps.tag_metadata_std.outputs.tags }}
labels: ${{ steps.tag_metadata_std.outputs.labels }}
build-args: |
BUILD_PACKAGE_NAME=tyk-gateway
- name: save deb
uses: actions/upload-artifact@v4
if: ${{ matrix.golang_cross == '1.16' }}
Expand Down Expand Up @@ -232,16 +242,13 @@ jobs:
pump: ${{ steps.params.outputs.pump }}
sink: ${{ steps.params.outputs.sink }}
steps:
- name: set params
- name: Set test parameters
uses: TykTechnologies/github-actions/.github/actions/tests/test-controller@main
id: params
shell: bash
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.gho" | tee -a "$GITHUB_OUTPUT"
if ! [[ $VARIATION =~ prod ]] ;then
echo "::warning file=.github/workflows/release.yml,line=24,col=1,endColumn=8::Using non-prod variation"
echo "### :warning: You are using VARIATION=${VARIATION} in test-controller-api" >> $GITHUB_STEP_SUMMARY
fi
with:
variation: ${{ env.VARIATION }}
base_ref: ${{ env.BASE_REF }}
test_type: api
api-tests:
needs:
- test-controller-api
Expand Down Expand Up @@ -281,155 +288,37 @@ jobs:
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-pro
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release download --repo github.com/tyklabs/tyk-pro --archive tar.gz -O env.tgz
mkdir auto && tar --strip-components=1 -C auto -xzvf env.tgz
- name: env up
shell: bash
working-directory: auto
- name: Fetch environment from tyk-pro
uses: TykTechnologies/github-actions/.github/actions/tests/checkout-tyk-pro@main
with:
org_gh_token: ${{ github.token }}
- name: Set up test environment
uses: TykTechnologies/github-actions/.github/actions/tests/env-up@main
timeout-minutes: 5
id: env_up
env:
pull_policy: 'if_not_present'
GH_TOKEN: ${{ secrets.ORG_GH_TOKEN }}
with:
base_ref: ${{ env.BASE_REF }}
tags: ${{ needs.goreleaser.outputs.ee_tags || needs.goreleaser.outputs.std_tags || format('{0}/tyk-ee:master', steps.ecr.outputs.registry) }}
github_token: ${{ secrets.ORG_GH_TOKEN }}
TYK_DB_LICENSEKEY: ${{ secrets.DASH_LICENSE }}
TYK_MDCB_LICENSE: ${{ secrets.MDCB_LICENSE }}
run: |
match_tag=${{steps.ecr.outputs.registry}}/tyk:$BASE_REF
tags=(${{ needs.goreleaser.outputs.tags }})
set -eaxo pipefail
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_pump_image=${{matrix.pump}}

tyk_sink_image=${{matrix.sink}}
confs_dir=./pro-ha
env_file=local.env' >> versions.env
cat ./confs/${{ matrix.envfiles.config }}.env local-${{ matrix.envfiles.db }}.env > local.env
echo "::group::versions"
cat versions.env local.env
echo "::endgroup::"
# 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
echo "$(cat pytest.env | grep USER_API_SECRET)" >> $GITHUB_OUTPUT
echo "ts=$(date +%s%N)" >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
- name: Choose test code branch
uses: TykTechnologies/github-actions/.github/actions/tests/choose-test-branch@main
with:
repository: TykTechnologies/tyk-analytics
path: tyk-analytics
token: ${{ secrets.ORG_GH_TOKEN }}
fetch-depth: 0
sparse-checkout: tests/api
- name: Choosing test code branch
working-directory: tyk-analytics/tests/api
run: |
if [[ ${{ github.event_name }} == "release" ]]; then
echo "Checking out release tag..."
TAG_NAME=${{ github.event.release.tag_name }}
git checkout "$TAG_NAME"
fi
if [[ ${{ github.event_name }} == "pull_request" ]]; then
PR_BRANCH=${{ github.event.pull_request.head.ref }}
TARGET_BRANCH=${{ github.event.pull_request.base.ref }}
echo "Looking for PR_BRANCH:$PR_BRANCH or TARGET_BRANCH:$TARGET_BRANCH..."
if git rev-parse --verify "origin/$PR_BRANCH" >/dev/null 2>&1; then
echo "PR branch $PR_BRANCH exists. Checking out..."
git checkout "$PR_BRANCH"
elif git rev-parse --verify "origin/$TARGET_BRANCH" >/dev/null 2>&1; then
echo "Target branch $TARGET_BRANCH exists. Checking out..."
git checkout "$TARGET_BRANCH"
fi
fi
if [[ ${{ github.event_name }} == "push" ]]; then
PUSH_BRANCH=${{ github.ref_name }}
echo "Looking for PUSH_BRANCH:$PUSH_BRANCH..."
if git rev-parse --verify "origin/$PUSH_BRANCH" >/dev/null 2>&1; then
echo "Push branch $PUSH_BRANCH exists. Checking out..."
git checkout "$PUSH_BRANCH"
fi
fi
echo "Current commit: $(git rev-parse HEAD)"
- uses: actions/setup-python@v5
with:
cache: 'pip'
python-version: '3.11'
test_folder: api
org_gh_token: ${{ secrets.ORG_GH_TOKEN }}
- name: Run API tests
uses: TykTechnologies/github-actions/.github/actions/tests/api-tests@main
timeout-minutes: 30
id: test_execution
working-directory: tyk-analytics/tests/api
run: |
pytest="pytest --ci --random-order --force-flaky --no-success-flaky-report --maxfail=3 --junitxml=${XUNIT_REPORT_PATH} --cache-clear --ignore=./tests/mdcb -v --log-cli-level=ERROR"
pip install -r requirements.txt
cat >pytest.env <<-EOF
TYK_TEST_BASE_URL=http://localhost:3000/
TYK_TEST_GW_URL=https://localhost:8080/
TYK_TEST_GW_1_ALFA_URL=https://localhost:8181/
TYK_TEST_GW_1_BETA_URL=https://localhost:8182/
TYK_TEST_GW_2_ALFA_URL=https://localhost:8281/
TYK_TEST_GW_2_BETA_URL=https://localhost:8282/
TYK_TEST_MONGODB=localhost:27017
TYK_TEST_REDIS=localhost
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
GATEWAY_CONTAINER_NAME=tyk
USER_API_SECRET=${{ steps.env_up.outputs.USER_API_SECRET }}
EOF
env $(cat pytest.env | xargs) $pytest -m "${{ matrix.envfiles.apimarkers }}"
- name: Generate metadata and upload test reports
id: metadata_report
with:
user_api_secret: ${{ steps.env_up.outputs.USER_API_SECRET }}
- name: Generate test reports and collect logs
uses: TykTechnologies/github-actions/.github/actions/tests/reporting@main
if: always() && (steps.test_execution.conclusion != 'skipped')
env:
REPORT_NAME: ${{ github.repository }}_${{ github.run_id }}_${{ github.run_attempt }}-${{steps.env_up.outputs.ts}}
METADATA_REPORT_PATH: metadata.toml
run: |
# Generate metadata report
set -eo pipefail
echo "[metadata]
repo = ${{ github.repository }}
branch = ${{ github.ref }}
commit = ${{ github.sha }}
test_suite_version = $BASE_REF
test_suite_name = ${{ github.job }}
test_suite_run = ${{ github.run_id }}-${{ github.run_attempt }}
db = ${{ matrix.envfiles.db }}
conf = ${{ matrix.envfiles.config }}
cache = ${{ matrix.envfiles.cache }}
pump_compatibility = ${{ matrix.pump }}
sink_compatibility = ${{ matrix.sink }}
" | tee ${METADATA_REPORT_PATH}
aws s3 cp ${XUNIT_REPORT_PATH} s3://assets.dev.tyk.technology/testreports/${REPORT_NAME#*/}.xml
aws s3 cp ${METADATA_REPORT_PATH} s3://assets.dev.tyk.technology/testreports/${REPORT_NAME#*/}.metadata.toml
- name: Docker logs for all components
if: failure() && (steps.test_execution.outcome != 'success' || steps.env_up.outcome != 'success')
working-directory: auto
env:
pull_policy: 'if_not_present'
GH_TOKEN: ${{ secrets.ORG_GH_TOKEN }}
TYK_DB_LICENSEKEY: ${{ secrets.DASH_LICENSE }}
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
echo "::group::DockerLogs"
cat ${{ github.workspace }}/docker-compose.log
echo "::endgroup::"
- 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
report_xml: 'true'
execution_status: ${{ steps.test_execution.outcome }}
test-controller-distros:
if: github.event.pull_request.draft == false
needs:
Expand Down Expand Up @@ -503,9 +392,11 @@ jobs:
load: true
- name: Test the built container image with api functionality test.
run: |
docker run -d -p8080:8080 --network ${{ job.container.network }} --rm test-${{ matrix.distro }}-${{ matrix.arch }}
docker run -d -p8080:8080 --name=test --platform linux/${{ matrix.arch }} --network ${{ job.container.network }} --rm test-${{ matrix.distro }}-${{ matrix.arch }}
sleep 2
./ci/tests/api-functionality/api_test.sh
sleep 2
docker stop test || true
upgrade-rpm:
services:
httpbin.org:
Expand Down Expand Up @@ -560,7 +451,7 @@ jobs:
tags: test-${{ matrix.distro }}-${{ matrix.arch }}
load: true
- name: Test the built container image with api functionality test.
run: "docker run -d -p8080:8080 --network ${{ job.container.network }} --rm test-${{ matrix.distro }}-${{ matrix.arch }}\nsleep 2\n./ci/tests/api-functionality/api_test.sh \n"
run: "docker run -d -p8080:8080 --name=test --platform linux/${{ matrix.arch }} --network ${{ job.container.network }} --rm test-${{ matrix.distro }}-${{ matrix.arch }}\nsleep 2\n./ci/tests/api-functionality/api_test.sh\nsleep 2\ndocker stop test || true \n"
sbom:
needs: goreleaser
uses: TykTechnologies/github-actions/.github/workflows/sbom.yaml@main
Expand Down
7 changes: 4 additions & 3 deletions ci/Dockerfile.std
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Generated by: gromit policy

FROM debian:bookworm-slim
FROM debian:trixie-slim
ARG TARGETARCH
ARG BUILD_PACKAGE_NAME

ENV DEBIAN_FRONTEND=noninteractive

Expand All @@ -22,8 +23,8 @@ RUN rm -rf /root/.cache \
&& find /usr/lib -type f -name '*.a' -o -name '*.o' -delete

# Comment this to test in dev
COPY *${TARGETARCH}.deb /
RUN rm -f /*fips*.deb && dpkg -i /tyk-gateway*${TARGETARCH}.deb && rm /*.deb
COPY ${BUILD_PACKAGE_NAME}_*${TARGETARCH}.deb /
RUN dpkg -i /${BUILD_PACKAGE_NAME}*${TARGETARCH}.deb && rm /*.deb

ARG PORTS

Expand Down
Loading
Loading