Skip to content

Commit 417c338

Browse files
author
Gromit
committed
Auto generated from templates by gromit
1 parent 94f4aa1 commit 417c338

File tree

3 files changed

+115
-198
lines changed

3 files changed

+115
-198
lines changed

.github/workflows/release.yml

Lines changed: 58 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ on:
2424
- 'v*'
2525
env:
2626
GOPRIVATE: github.com/TykTechnologies
27-
VARIATION: inverted
27+
VARIATION: prod-variation
2828
DOCKER_BUILD_SUMMARY: false
2929
DOCKER_BUILD_RECORD_UPLOAD: false
3030
# startsWith covers pull_request_target too
@@ -47,9 +47,9 @@ jobs:
4747
goreleaser: 'ci/goreleaser/goreleaser.yml'
4848
cgo: 1
4949
rpmvers: 'el/7 el/8 el/9 amazon/2 amazon/2023'
50-
debvers: 'ubuntu/xenial ubuntu/bionic ubuntu/focal ubuntu/jammy debian/jessie debian/buster debian/bullseye debian/bookworm'
50+
debvers: 'ubuntu/xenial ubuntu/bionic ubuntu/focal ubuntu/jammy ubuntu/noble debian/jessie debian/buster debian/bullseye debian/bookworm debian/trixie'
5151
outputs:
52-
tags: ${{ steps.ci_metadata.outputs.tags }}
52+
std_tags: ${{ steps.ci_metadata_std.outputs.tags }}
5353
commit_author: ${{ steps.set_outputs.outputs.commit_author}}
5454
steps:
5555
- name: Checkout of tyk
@@ -145,12 +145,13 @@ jobs:
145145
if: ${{ matrix.golang_cross == '1.16' }}
146146
with:
147147
mask-password: 'true'
148-
- name: Docker metadata for CI
149-
id: ci_metadata
148+
- name: Docker metadata for std CI
149+
id: ci_metadata_std
150150
if: ${{ matrix.golang_cross == '1.16' }}
151151
uses: docker/metadata-action@v5
152152
with:
153-
images: ${{ steps.ecr.outputs.registry }}/tyk
153+
images: |
154+
${{ steps.ecr.outputs.registry }}/tyk
154155
flavor: |
155156
latest=false
156157
tags: |
@@ -160,48 +161,57 @@ jobs:
160161
type=semver,pattern={{major}},prefix=v
161162
type=semver,pattern={{major}}.{{minor}},prefix=v
162163
type=semver,pattern={{version}},prefix=v
163-
- name: push image to CI
164+
- name: push std image to CI
164165
if: ${{ matrix.golang_cross == '1.16' }}
165166
uses: docker/build-push-action@v6
166167
with:
167168
context: "dist"
168-
platforms: linux/amd64,linux/arm64
169+
platforms: linux/amd64,linux/arm64,linux/s390x
169170
file: ci/Dockerfile.std
170171
provenance: mode=max
171172
sbom: true
172173
push: true
173174
cache-from: type=gha
174175
cache-to: type=gha,mode=max
175-
tags: ${{ steps.ci_metadata.outputs.tags }}
176-
labels: ${{ steps.tag_metadata.outputs.labels }}
176+
tags: ${{ steps.ci_metadata_std.outputs.tags }}
177+
labels: ${{ steps.ci_metadata_std.outputs.labels }}
178+
build-args: |
179+
BUILD_PACKAGE_NAME=tyk-gateway
177180
- name: Docker metadata for tag push
178-
id: tag_metadata
181+
id: tag_metadata_std
179182
uses: docker/metadata-action@v5
180183
with:
181184
images: |
182-
tykio/tyk-gateway
183185
docker.tyk.io/tyk-gateway/tyk-gateway
186+
187+
tykio/tyk-gateway
184188
flavor: |
185189
latest=false
186190
prefix=v
187191
tags: |
188192
type=semver,pattern={{major}}.{{minor}}
189193
type=semver,pattern={{version}}
190-
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"
191-
- name: push image to prod
194+
labels: |
195+
org.opencontainers.image.title=Tyk Gateway
196+
org.opencontainers.image.description=Tyk Open Source API Gateway written in Go, supporting REST, GraphQL, TCP and gRPC protocols
197+
org.opencontainers.image.vendor=tyk.io
198+
org.opencontainers.image.version=${{ github.ref_name }}
199+
- name: push std image to prod
192200
if: ${{ matrix.golang_cross == '1.16' }}
193201
uses: docker/build-push-action@v6
194202
with:
195203
context: "dist"
196-
platforms: linux/amd64,linux/arm64
204+
platforms: linux/amd64,linux/arm64,linux/s390x
197205
file: ci/Dockerfile.std
198206
provenance: mode=max
199207
sbom: true
200208
cache-from: type=gha
201209
cache-to: type=gha,mode=max
202210
push: ${{ startsWith(github.ref, 'refs/tags') }}
203-
tags: ${{ steps.tag_metadata.outputs.tags }}
204-
labels: ${{ steps.tag_metadata.outputs.labels }}
211+
tags: ${{ steps.tag_metadata_std.outputs.tags }}
212+
labels: ${{ steps.tag_metadata_std.outputs.labels }}
213+
build-args: |
214+
BUILD_PACKAGE_NAME=tyk-gateway
205215
- name: save deb
206216
uses: actions/upload-artifact@v4
207217
if: ${{ matrix.golang_cross == '1.16' }}
@@ -232,16 +242,13 @@ jobs:
232242
pump: ${{ steps.params.outputs.pump }}
233243
sink: ${{ steps.params.outputs.sink }}
234244
steps:
235-
- name: set params
245+
- name: Set test parameters
246+
uses: TykTechnologies/github-actions/.github/actions/tests/test-controller@main
236247
id: params
237-
shell: bash
238-
run: |
239-
set -eo pipefail
240-
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"
241-
if ! [[ $VARIATION =~ prod ]] ;then
242-
echo "::warning file=.github/workflows/release.yml,line=24,col=1,endColumn=8::Using non-prod variation"
243-
echo "### :warning: You are using VARIATION=${VARIATION} in test-controller-api" >> $GITHUB_STEP_SUMMARY
244-
fi
248+
with:
249+
variation: ${{ env.VARIATION }}
250+
base_ref: ${{ env.BASE_REF }}
251+
test_type: api
245252
api-tests:
246253
needs:
247254
- test-controller-api
@@ -281,155 +288,35 @@ jobs:
281288
limit-access-to-actor: true
282289
# Only ${{ github.actor }} has access
283290
# See https://github.com/mxschmitt/action-tmate#use-registered-public-ssh-keys
284-
- name: fetch env from tyk-pro
285-
env:
286-
GH_TOKEN: ${{ github.token }}
287-
run: |
288-
gh release download --repo github.com/tyklabs/tyk-pro --archive tar.gz -O env.tgz
289-
mkdir auto && tar --strip-components=1 -C auto -xzvf env.tgz
290-
- name: env up
291-
shell: bash
292-
working-directory: auto
291+
- name: Fetch environment from tyk-pro
292+
uses: TykTechnologies/github-actions/.github/actions/tests/checkout-tyk-pro@main
293+
with:
294+
org_gh_token: ${{ github.token }}
295+
- name: Set up test environment
296+
uses: TykTechnologies/github-actions/.github/actions/tests/env-up@main
293297
id: env_up
294-
env:
295-
pull_policy: 'if_not_present'
296-
GH_TOKEN: ${{ secrets.ORG_GH_TOKEN }}
298+
with:
299+
base_ref: ${{ env.BASE_REF }}
300+
tags: ${{ needs.goreleaser.outputs.ee_tags || needs.goreleaser.outputs.std_tags || format('{0}/tyk-ee:master', steps.ecr.outputs.registry) }}
301+
github_token: ${{ secrets.ORG_GH_TOKEN }}
297302
TYK_DB_LICENSEKEY: ${{ secrets.DASH_LICENSE }}
298303
TYK_MDCB_LICENSE: ${{ secrets.MDCB_LICENSE }}
299-
run: |
300-
match_tag=${{steps.ecr.outputs.registry}}/tyk:$BASE_REF
301-
tags=(${{ needs.goreleaser.outputs.tags }})
302-
set -eaxo pipefail
303-
docker run -q --rm -v ~/.docker/config.json:/root/.docker/config.json tykio/gromit policy match ${tags[0]} ${match_tag} 2>versions.env
304-
echo '# alfa and beta have to come after the override
305-
tyk_alfa_image=$tyk_image
306-
tyk_beta_image=$tyk_image
307-
ECR=${{steps.ecr.outputs.registry}}
308-
tyk_pump_image=${{matrix.pump}}
309-
310-
tyk_sink_image=${{matrix.sink}}
311-
confs_dir=./pro-ha
312-
env_file=local.env' >> versions.env
313-
cat ./confs/${{ matrix.envfiles.config }}.env local-${{ matrix.envfiles.db }}.env > local.env
314-
echo "::group::versions"
315-
cat versions.env local.env
316-
echo "::endgroup::"
317-
# bring up env, the project name is important
318-
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
319-
./dash-bootstrap.sh http://localhost:3000
320-
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
321-
echo "$(cat pytest.env | grep USER_API_SECRET)" >> $GITHUB_OUTPUT
322-
echo "ts=$(date +%s%N)" >> $GITHUB_OUTPUT
323-
- uses: actions/checkout@v4
304+
- name: Choose test code branch
305+
uses: TykTechnologies/github-actions/.github/actions/tests/choose-test-branch@main
324306
with:
325-
repository: TykTechnologies/tyk-analytics
326-
path: tyk-analytics
327-
token: ${{ secrets.ORG_GH_TOKEN }}
328-
fetch-depth: 0
329-
sparse-checkout: tests/api
330-
- name: Choosing test code branch
331-
working-directory: tyk-analytics/tests/api
332-
run: |
333-
if [[ ${{ github.event_name }} == "release" ]]; then
334-
echo "Checking out release tag..."
335-
TAG_NAME=${{ github.event.release.tag_name }}
336-
git checkout "$TAG_NAME"
337-
fi
338-
if [[ ${{ github.event_name }} == "pull_request" ]]; then
339-
PR_BRANCH=${{ github.event.pull_request.head.ref }}
340-
TARGET_BRANCH=${{ github.event.pull_request.base.ref }}
341-
echo "Looking for PR_BRANCH:$PR_BRANCH or TARGET_BRANCH:$TARGET_BRANCH..."
342-
if git rev-parse --verify "origin/$PR_BRANCH" >/dev/null 2>&1; then
343-
echo "PR branch $PR_BRANCH exists. Checking out..."
344-
git checkout "$PR_BRANCH"
345-
elif git rev-parse --verify "origin/$TARGET_BRANCH" >/dev/null 2>&1; then
346-
echo "Target branch $TARGET_BRANCH exists. Checking out..."
347-
git checkout "$TARGET_BRANCH"
348-
fi
349-
fi
350-
if [[ ${{ github.event_name }} == "push" ]]; then
351-
PUSH_BRANCH=${{ github.ref_name }}
352-
echo "Looking for PUSH_BRANCH:$PUSH_BRANCH..."
353-
if git rev-parse --verify "origin/$PUSH_BRANCH" >/dev/null 2>&1; then
354-
echo "Push branch $PUSH_BRANCH exists. Checking out..."
355-
git checkout "$PUSH_BRANCH"
356-
fi
357-
fi
358-
echo "Current commit: $(git rev-parse HEAD)"
359-
- uses: actions/setup-python@v5
360-
with:
361-
cache: 'pip'
362-
python-version: '3.11'
307+
test_folder: api
308+
org_gh_token: ${{ secrets.ORG_GH_TOKEN }}
363309
- name: Run API tests
310+
uses: TykTechnologies/github-actions/.github/actions/tests/api-tests@main
364311
id: test_execution
365-
working-directory: tyk-analytics/tests/api
366-
run: |
367-
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"
368-
pip install -r requirements.txt
369-
cat >pytest.env <<-EOF
370-
TYK_TEST_BASE_URL=http://localhost:3000/
371-
TYK_TEST_GW_URL=https://localhost:8080/
372-
TYK_TEST_GW_1_ALFA_URL=https://localhost:8181/
373-
TYK_TEST_GW_1_BETA_URL=https://localhost:8182/
374-
TYK_TEST_GW_2_ALFA_URL=https://localhost:8281/
375-
TYK_TEST_GW_2_BETA_URL=https://localhost:8282/
376-
TYK_TEST_MONGODB=localhost:27017
377-
TYK_TEST_REDIS=localhost
378-
TYK_TEST_DB_ADMIN=12345
379-
TYK_TEST_GW_SECRET=352d20ee67be67f6340b4c0605b044b7
380-
TYK_TEST_DB_NAME=tyk_analytics
381-
TYK_TEST_FEDERATION_HOST=federation
382-
TYK_TEST_GRAPHQL_FAKER_HOST=graphql-faker
383-
GATEWAY_CONTAINER_NAME=tyk
384-
USER_API_SECRET=${{ steps.env_up.outputs.USER_API_SECRET }}
385-
EOF
386-
env $(cat pytest.env | xargs) $pytest -m "${{ matrix.envfiles.apimarkers }}"
387-
- name: Generate metadata and upload test reports
388-
id: metadata_report
312+
with:
313+
user_api_secret: ${{ steps.env_up.outputs.USER_API_SECRET }}
314+
- name: Generate test reports and collect logs
315+
uses: TykTechnologies/github-actions/.github/actions/tests/reporting@main
389316
if: always() && (steps.test_execution.conclusion != 'skipped')
390-
env:
391-
REPORT_NAME: ${{ github.repository }}_${{ github.run_id }}_${{ github.run_attempt }}-${{steps.env_up.outputs.ts}}
392-
METADATA_REPORT_PATH: metadata.toml
393-
run: |
394-
# Generate metadata report
395-
set -eo pipefail
396-
echo "[metadata]
397-
repo = ${{ github.repository }}
398-
branch = ${{ github.ref }}
399-
commit = ${{ github.sha }}
400-
test_suite_version = $BASE_REF
401-
test_suite_name = ${{ github.job }}
402-
test_suite_run = ${{ github.run_id }}-${{ github.run_attempt }}
403-
db = ${{ matrix.envfiles.db }}
404-
conf = ${{ matrix.envfiles.config }}
405-
cache = ${{ matrix.envfiles.cache }}
406-
pump_compatibility = ${{ matrix.pump }}
407-
sink_compatibility = ${{ matrix.sink }}
408-
" | tee ${METADATA_REPORT_PATH}
409-
aws s3 cp ${XUNIT_REPORT_PATH} s3://assets.dev.tyk.technology/testreports/${REPORT_NAME#*/}.xml
410-
aws s3 cp ${METADATA_REPORT_PATH} s3://assets.dev.tyk.technology/testreports/${REPORT_NAME#*/}.metadata.toml
411-
- name: Docker logs for all components
412-
if: failure() && (steps.test_execution.outcome != 'success' || steps.env_up.outcome != 'success')
413-
working-directory: auto
414-
env:
415-
pull_policy: 'if_not_present'
416-
GH_TOKEN: ${{ secrets.ORG_GH_TOKEN }}
417-
TYK_DB_LICENSEKEY: ${{ secrets.DASH_LICENSE }}
418-
TYK_MDCB_LICENSE: ${{ secrets.MDCB_LICENSE }}
419-
ECR: ${{ steps.ecr.outputs.registry }}
420-
run: |
421-
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
422-
echo "::group::DockerLogs"
423-
cat ${{ github.workspace }}/docker-compose.log
424-
echo "::endgroup::"
425-
- name: Upload compose logs
426-
uses: actions/upload-artifact@v4
427-
if: failure() && (steps.test_execution.outcome != 'success' || steps.env_up.outcome != 'success')
428317
with:
429-
name: docker-compose-logs-${{ github.job }}-${{ matrix.envfiles.db }}-${{ matrix.envfiles.conf }}-${{ github.run_id }}
430-
path: ${{ github.workspace }}/docker-compose.log
431-
retention-days: 3
432-
overwrite: true
318+
report_xml: 'true'
319+
execution_status: ${{ steps.test_execution.outcome }}
433320
test-controller-distros:
434321
if: github.event.pull_request.draft == false
435322
needs:
@@ -503,9 +390,11 @@ jobs:
503390
load: true
504391
- name: Test the built container image with api functionality test.
505392
run: |
506-
docker run -d -p8080:8080 --network ${{ job.container.network }} --rm test-${{ matrix.distro }}-${{ matrix.arch }}
393+
docker run -d -p8080:8080 --name=test --platform linux/${{ matrix.arch }} --network ${{ job.container.network }} --rm test-${{ matrix.distro }}-${{ matrix.arch }}
507394
sleep 2
508395
./ci/tests/api-functionality/api_test.sh
396+
sleep 2
397+
docker stop test || true
509398
upgrade-rpm:
510399
services:
511400
httpbin.org:
@@ -560,7 +449,7 @@ jobs:
560449
tags: test-${{ matrix.distro }}-${{ matrix.arch }}
561450
load: true
562451
- name: Test the built container image with api functionality test.
563-
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"
452+
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"
564453
sbom:
565454
needs: goreleaser
566455
uses: TykTechnologies/github-actions/.github/workflows/sbom.yaml@main

ci/Dockerfile.std

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Generated by: gromit policy
22

3-
FROM debian:bookworm-slim
3+
FROM debian:trixie-slim
44
ARG TARGETARCH
5+
ARG BUILD_PACKAGE_NAME
56

67
ENV DEBIAN_FRONTEND=noninteractive
78

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

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

2829
ARG PORTS
2930

0 commit comments

Comments
 (0)