Skip to content

release-testing

release-testing #45

name: release-testing
on:
workflow_dispatch:
inputs:
tag:
description: 'a release tag that will be created upon success'
required: true
jobs:
# --------------------------------------------------------------------------
# Release Testing Job
# --------------------------------------------------------------------------
unit-tests:
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: setup golang
uses: actions/setup-go@v4
with:
go-version: '^1.19'
- name: run unit tests
run: make test.unit
setup-integration-tests:
runs-on: ubuntu-latest
outputs:
test_names: ${{ steps.set_test_names.outputs.test_names }}
steps:
- uses: actions/checkout@v3
- id: set_test_names
name: Set test names
working-directory: test/integration/
# grep magic described in https://unix.stackexchange.com/a/13472
# sed to add the extra $ is because some of our test names overlap. we need it so the -run regex only matches one test
run: |
echo "test_names=$(grep -shoP "(?<=^func )(Test[a-zA-z_0-9]+)(?=\(t \*testing.T\) {)" * | sed -e "s/$/\$/"| jq -R . | jq -cs .)" >> $GITHUB_OUTPUT
- name: Print test names
run: echo "Test names ${{ steps.set_test_names.outputs.test_names }}"
integration-tests:
runs-on: ubuntu-latest
needs:
- setup-integration-tests
strategy:
fail-fast: false
matrix:
test: ${{ fromJSON(needs.setup-integration-tests.outputs.test_names) }}
steps:
- uses: Kong/kong-license@master
id: license
with:
password: ${{ secrets.PULP_PASSWORD }}
- name: checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: setup golang
uses: actions/setup-go@v4
with:
go-version: '^1.19'
- name: run integration tests
run: make test.integration
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
KTF_TEST_KONG_PULL_USERNAME: ${{ secrets.GHA_DOCKERHUB_PULL_USER }}
KTF_TEST_KONG_PULL_PASSWORD: ${{ secrets.GHA_KONG_ORG_DOCKERHUB_PUBLIC_TOKEN }}
KONG_LICENSE_DATA: ${{ steps.license.outputs.license }}
TEST_RUN: ${{ matrix.test }}
e2e-tests:
environment: gcloud
runs-on: ubuntu-latest
steps:
- uses: Kong/kong-license@master
id: license
with:
password: ${{ secrets.PULP_PASSWORD }}
# --------------------------------------------------------------------------
# Repository Checkout
# --------------------------------------------------------------------------
- name: checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: setup golang
uses: actions/setup-go@v4
with:
go-version: '^1.19'
- name: run e2e tests
run: make test.e2e
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
GOOGLE_PROJECT: ${{ secrets.GOOGLE_PROJECT }}
GOOGLE_LOCATION: ${{ secrets.GOOGLE_LOCATION }}
KONG_LICENSE_DATA: ${{ steps.license.outputs.license }}
release-tagging:
runs-on: ubuntu-latest
needs:
- unit-tests
- integration-tests
- e2e-tests
steps:
- name: checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
# This is needed to trigger another workflow, specifically release workflow
# which listens to pushing "v*" tags.
# > When you use the repository’s GITHUB_TOKEN to perform tasks on behalf
# > of the GitHub Actions app, events triggered by the GITHUB_TOKEN will not
# > create a new workflow run.
# ref: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow
token: ${{ secrets.PAT_GITHUB }}
# --------------------------------------------------------------------------
# Release Tagging
# --------------------------------------------------------------------------
- name: set the tag ${{ github.event.inputs.tag }} and push it
run: |
git tag ${{ github.event.inputs.tag }}
git push origin refs/tags/${{ github.event.inputs.tag }}