-
Notifications
You must be signed in to change notification settings - Fork 10
150 lines (124 loc) · 4.63 KB
/
release-testing.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
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:
timeout-minutes: ${{ fromJSON(vars.GHA_DEFAULT_TIMEOUT) }}
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: setup golang
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: run unit tests
run: make test.unit
setup-integration-tests:
timeout-minutes: ${{ fromJSON(vars.GHA_DEFAULT_TIMEOUT) }}
runs-on: ubuntu-latest
outputs:
test_names: ${{ steps.set_test_names.outputs.test_names }}
steps:
- uses: actions/checkout@v4
- 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:
op-token: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
- name: checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: setup golang
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- 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:
timeout-minutes: 30 # Setting up a GKE cluster and getting a LB ready can take more than the default 10m.
environment: gcloud
runs-on: ubuntu-latest
steps:
- uses: Kong/kong-license@master
id: license
with:
op-token: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
# --------------------------------------------------------------------------
# Repository Checkout
# --------------------------------------------------------------------------
- name: checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: setup golang
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- 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:
timeout-minutes: ${{ fromJSON(vars.GHA_DEFAULT_TIMEOUT) }}
runs-on: ubuntu-latest
needs:
- unit-tests
- integration-tests
- e2e-tests
steps:
- name: checkout repository
uses: actions/checkout@v4
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 }}