24
24
- ' v*'
25
25
env :
26
26
GOPRIVATE : github.com/TykTechnologies
27
- VARIATION : inverted
27
+ VARIATION : prod-variation
28
28
DOCKER_BUILD_SUMMARY : false
29
29
DOCKER_BUILD_RECORD_UPLOAD : false
30
30
# startsWith covers pull_request_target too
47
47
goreleaser : ' ci/goreleaser/goreleaser.yml'
48
48
cgo : 1
49
49
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 '
51
51
outputs :
52
- tags : ${{ steps.ci_metadata .outputs.tags }}
52
+ std_tags : ${{ steps.ci_metadata_std .outputs.tags }}
53
53
commit_author : ${{ steps.set_outputs.outputs.commit_author}}
54
54
steps :
55
55
- name : Checkout of tyk
@@ -145,12 +145,13 @@ jobs:
145
145
if : ${{ matrix.golang_cross == '1.16' }}
146
146
with :
147
147
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
150
150
if : ${{ matrix.golang_cross == '1.16' }}
151
151
uses : docker/metadata-action@v5
152
152
with :
153
- images : ${{ steps.ecr.outputs.registry }}/tyk
153
+ images : |
154
+ ${{ steps.ecr.outputs.registry }}/tyk
154
155
flavor : |
155
156
latest=false
156
157
tags : |
@@ -160,48 +161,57 @@ jobs:
160
161
type=semver,pattern={{major}},prefix=v
161
162
type=semver,pattern={{major}}.{{minor}},prefix=v
162
163
type=semver,pattern={{version}},prefix=v
163
- - name : push image to CI
164
+ - name : push std image to CI
164
165
if : ${{ matrix.golang_cross == '1.16' }}
165
166
uses : docker/build-push-action@v6
166
167
with :
167
168
context : " dist"
168
- platforms : linux/amd64,linux/arm64
169
+ platforms : linux/amd64,linux/arm64,linux/s390x
169
170
file : ci/Dockerfile.std
170
171
provenance : mode=max
171
172
sbom : true
172
173
push : true
173
174
cache-from : type=gha
174
175
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
177
180
- name : Docker metadata for tag push
178
- id : tag_metadata
181
+ id : tag_metadata_std
179
182
uses : docker/metadata-action@v5
180
183
with :
181
184
images : |
182
- tykio/tyk-gateway
183
185
docker.tyk.io/tyk-gateway/tyk-gateway
186
+
187
+ tykio/tyk-gateway
184
188
flavor : |
185
189
latest=false
186
190
prefix=v
187
191
tags : |
188
192
type=semver,pattern={{major}}.{{minor}}
189
193
type=semver,pattern={{version}}
190
- labels : " org.opencontainers.image.title=tyk-gateway \n org.opencontainers.image.description=Tyk Open Source API Gateway written in Go, supporting REST, GraphQL, TCP and gRPC protocols\n org.opencontainers.image.vendor=tyk.io\n org.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
192
200
if : ${{ matrix.golang_cross == '1.16' }}
193
201
uses : docker/build-push-action@v6
194
202
with :
195
203
context : " dist"
196
- platforms : linux/amd64,linux/arm64
204
+ platforms : linux/amd64,linux/arm64,linux/s390x
197
205
file : ci/Dockerfile.std
198
206
provenance : mode=max
199
207
sbom : true
200
208
cache-from : type=gha
201
209
cache-to : type=gha,mode=max
202
210
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
205
215
- name : save deb
206
216
uses : actions/upload-artifact@v4
207
217
if : ${{ matrix.golang_cross == '1.16' }}
@@ -232,16 +242,13 @@ jobs:
232
242
pump : ${{ steps.params.outputs.pump }}
233
243
sink : ${{ steps.params.outputs.sink }}
234
244
steps :
235
- - name : set params
245
+ - name : Set test parameters
246
+ uses : TykTechnologies/github-actions/.github/actions/tests/test-controller@main
236
247
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
245
252
api-tests :
246
253
needs :
247
254
- test-controller-api
@@ -281,155 +288,35 @@ jobs:
281
288
limit-access-to-actor : true
282
289
# Only ${{ github.actor }} has access
283
290
# 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
293
297
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 }}
297
302
TYK_DB_LICENSEKEY : ${{ secrets.DASH_LICENSE }}
298
303
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
324
306
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 }}
363
309
- name : Run API tests
310
+ uses : TykTechnologies/github-actions/.github/actions/tests/api-tests@main
364
311
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
389
316
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')
428
317
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 }}
433
320
test-controller-distros :
434
321
if : github.event.pull_request.draft == false
435
322
needs :
@@ -503,9 +390,11 @@ jobs:
503
390
load : true
504
391
- name : Test the built container image with api functionality test.
505
392
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 }}
507
394
sleep 2
508
395
./ci/tests/api-functionality/api_test.sh
396
+ sleep 2
397
+ docker stop test || true
509
398
upgrade-rpm :
510
399
services :
511
400
httpbin.org :
@@ -560,7 +449,7 @@ jobs:
560
449
tags : test-${{ matrix.distro }}-${{ matrix.arch }}
561
450
load : true
562
451
- 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 }}\n sleep 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 }}\n sleep 2\n ./ci/tests/api-functionality/api_test.sh\n sleep 2 \n docker stop test || true \n "
564
453
sbom :
565
454
needs : goreleaser
566
455
uses : TykTechnologies/github-actions/.github/workflows/sbom.yaml@main
0 commit comments