-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathaction.yaml
More file actions
181 lines (153 loc) · 6.38 KB
/
action.yaml
File metadata and controls
181 lines (153 loc) · 6.38 KB
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
name: 'Kong Pongo'
description: 'Installs Pongo, tool for testing Kong Gateway plugins'
branding:
icon: activity
color: blue
inputs:
kong_version:
description: >
The Kong version to test against
required: true
pongo_version:
description: >
The Pongo version to use for testing. This can be a Pongo version tag or
branch name (use `"master"` for bleeding-edge). A special case is `"latest"`
which will get the latest released version.
required: true
default: "latest"
build_image:
description: >
Pre-build the image for the given Kong version (runs 'pongo build')
required: true
default: "true"
start_environment:
description: >
Start the test environment (runs 'pongo up')
required: true
default: "true"
license:
description: >
The Kong license (defaults to environment variable `KONG_LICENSE_DATA` if
not given). This is only required if you are testing a plugin against an
Enterprise version of the Kong Gateway.
required: false
enterprise_nightly_docker_password:
description: >
Kong Inc internal only!
The password to access the nightly Kong Enterprise images for `dev-ee`
testing.
required: false
enterprise_nightly_docker_username:
description: >
Kong Inc internal only!
The username to access the nightly Kong Enterprise images for `dev-ee`
testing.
required: false
github_token:
description: >
Kong Inc internal only!
The token to clone the `kong-ee` git repo for `dev-ee` testing.
required: false
cache:
description: >
If set, cache the Pongo test image using the given cache type
to avoid rebuilding the image at each run.
Can only be set to `github` for now.
required: false
runs:
using: "composite"
steps:
- name: Pongo version
id: pongo_ref
run: |
if [ "${{ inputs.pongo_version }}" == "latest" ]; then
# latest released version; fetch full git history and branches
echo "fetch=0" >> $GITHUB_OUTPUT
else
# specific version/branch; fetch single commit on that tag/version
echo "fetch=1" >> $GITHUB_OUTPUT
echo "ref=${{ inputs.pongo_version }}" >> $GITHUB_OUTPUT
fi
shell: bash
- name: Fetch Pongo
uses: actions/checkout@v3
with:
repository: Kong/kong-pongo
path: kong-pongo
fetch-depth: ${{ steps.pongo_ref.outputs.fetch }}
ref: ${{ steps.pongo_ref.outputs.ref }}
- name: Install Pongo
run: |
if [ "${{ inputs.pongo_version }}" == "latest" ]; then
# latest released version; find it and checkout
pushd "$GITHUB_WORKSPACE/kong-pongo/"
git checkout $(git describe --tags --abbrev=0)
popd
fi
ln -s "$GITHUB_WORKSPACE/kong-pongo/pongo.sh" "$GITHUB_WORKSPACE/kong-pongo/pongo"
echo "$GITHUB_WORKSPACE/kong-pongo/" >> $GITHUB_PATH
echo Installed pongo in the system path
shell: bash
- name: Export global Pongo configuration variables
# The license is exported only if given, and its signature masked.
# The Kong version is always exported.
# The docker credentials are only exported if testing 'dev-ee'
shell: bash
run: |
echo "KONG_VERSION=${{ inputs.kong_version }}" >> $GITHUB_ENV
echo Exported KONG_VERSION=${{ inputs.kong_version }} as global environment variable
INPUT_LICENSE=${{ inputs.license }}
if [ "$INPUT_LICENSE" == "" ]; then
INPUT_LICENSE="$KONG_LICENSE_DATA"
fi
if [ "$INPUT_LICENSE" == "" ]; then
echo Not exporting KONG_LICENSE_DATA, no license provided
else
echo ::add-mask::$(jq -r '.license.signature' <<< "$INPUT_LICENSE")
echo ::add-mask::$(jq -r '.license.payload.license_key' <<< "$INPUT_LICENSE")
echo 'KONG_LICENSE_DATA<<EOF' >> $GITHUB_ENV
echo $INPUT_LICENSE >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
echo Exported KONG_LICENSE_DATA as global environment variable
fi
# Note: "nightly-ee" was the old name with Pongo 1.x
if [ "${{ inputs.kong_version }}" == "nightly-ee" ] || [ "${{ inputs.kong_version }}" == "dev-ee" ]; then
echo "DOCKER_USERNAME=${{ inputs.enterprise_nightly_docker_username }}" >> $GITHUB_ENV
echo "DOCKER_PASSWORD=${{ inputs.enterprise_nightly_docker_password }}" >> $GITHUB_ENV
echo Exported DOCKER_USERNAME and DOCKER_PASSWORD as global environment variables
fi
- name: Start the Pongo environment
if: ${{ inputs.start_environment == 'true' }}
run: pongo up
shell: bash
# The native docker driver does not support cache from/to GitHub Actions Cache
# so we need to set up Buildx when GitHub cache is enabled
- name: Set up Docker Buildx to have GitHub Actions Cache support
if: ${{ inputs.cache == 'github' }}
uses: docker/setup-buildx-action@v3
with:
install: true
- name: Expose environment variables required by GitHub Actions Cache
if: ${{ inputs.cache == 'github' }}
uses: actions/github-script@v7
with:
# gha cache type requires an url and a token parameter, they will be automatically
# set from ACTIONS_CACHE_URL and ACTIONS_RUNTIME_TOKEN if present
# These variables are automatically set by GitHub Actions but they are only available
# for javascript actions, so we need to re-export them as environment variables
# We export the DOCKER_BUILD_EXTRA_ARGS similarly to be consistent
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env['ACTIONS_CACHE_URL'])
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env['ACTIONS_RUNTIME_TOKEN'])
core.exportVariable('DOCKER_BUILD_EXTRA_ARGS', process.env['DOCKER_BUILD_EXTRA_ARGS'])
env:
DOCKER_BUILD_EXTRA_ARGS: >
--output=type=docker
--cache-from=type=gha,scope=kong-pongo-${{ inputs.pongo_version }}:${{ inputs.kong_version }}
--cache-to=type=gha,mode=min,scope=kong-pongo-${{ inputs.pongo_version }}:${{ inputs.kong_version }},ignore-error=true
- name: Build the Pongo test image for Kong version ${{ inputs.kong_version }}
if: ${{ inputs.build_image == 'true' }}
env:
GITHUB_TOKEN: ${{ inputs.github_token }}
run: pongo build
shell: bash