1
+ # GitHub repo level Secrets and Variables
2
+
3
+ # secrets.CLIENT_SECRET
4
+ # secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN
5
+ # vars.CAPI_RELEASE_VERSION
6
+ # vars.SHEPHERD_LEASE_NAMESPACE
7
+ # vars.SHEPHERD_POOL_DURATION
8
+ # vars.SHEPHERD_POOL_NAME
9
+ # vars.SHEPHERD_POOL_NAMESPACE
10
+
1
11
name : " Tests: Integration"
2
12
3
13
run-name : " Integration [${{ github.event_name }}: ${{ github.event.pull_request.head.sha || github.event.push.after || github.event.workflow_run.head_sha}}]: ${{ github.event.workflow_run.head_commit.message }}"
14
24
- run-integration-tests-cf-env
15
25
- run-integration-tests-cf-env-with-client-creds
16
26
- run-cats-cf-env
27
+ nodes :
28
+ description : Number of test nodes
29
+ required : false
30
+ type : string
31
+ default : " 12"
32
+ lease_id :
33
+ description : Pre-provisioned environment lease-id to use in tests
34
+ required : false
35
+ type : string
36
+ lease_namespace :
37
+ description : Pre-provisioned environment lease namespace to use in tests
38
+ required : false
39
+ type : string
40
+ run_unit_tests :
41
+ description : Run unit tests
42
+ required : false
43
+ type : boolean
44
+ default : true
45
+ reinstall_cfd :
46
+ description : Force re-installation of CFD
47
+ required : false
48
+ type : boolean
49
+ default : true
50
+
17
51
push :
18
52
tags :
19
53
- " v8.*"
31
65
- " .grype.yaml"
32
66
- " .git*"
33
67
- " .golangci.json"
68
+
69
+ env :
70
+ SHEPHERD_LEASE_ID : ${{ inputs.lease_id }}
71
+
34
72
jobs :
73
+
35
74
get-sha :
36
75
runs-on : ubuntu-latest
37
76
outputs :
@@ -57,14 +96,17 @@ jobs:
57
96
steps :
58
97
- name : Checkout
59
98
uses : actions/checkout@v4
99
+ if : ${{ inputs.run_unit_tests == 'true' }}
60
100
with :
61
101
ref : ${{needs.get-sha.outputs.gitRef}}
62
102
- name : Set Up Go
63
103
uses : actions/setup-go@v5
104
+ if : ${{ inputs.run_unit_tests == 'true' }}
64
105
with :
65
106
go-version-file : go.mod
66
107
check-latest : true
67
108
- name : Run Units
109
+ if : ${{ inputs.run_unit_tests == 'true' }}
68
110
run : make units
69
111
70
112
claim-env :
@@ -88,23 +130,45 @@ jobs:
88
130
- name : claim
89
131
id : claim
90
132
env :
91
- account_token : ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
92
- pool_name : ${{ vars.SHEPHERD_POOL_NAME }}
93
- pool_namespace : official
133
+ account_token : ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
134
+ pool_name : ${{ vars.SHEPHERD_POOL_NAME }}
135
+ pool_duration : ${{ vars.SHEPHERD_POOL_DURATION || '8h' }}
136
+ pool_namespace : ${{ vars.SHEPHERD_POOL_NAMESPACE || 'official' }}
137
+ lease_namespace : ${{ inputs.lease_namespace || vars.SHEPHERD_LEASE_NAMESPACE || 'tas-devex' }}
94
138
run : |
95
139
shepherd login service-account ${account_token}
96
140
97
- echo "shepherd create lease --duration 8h --pool ${pool_name} --pool-namespace ${pool_namespace} --namespace tas-devex --description 'CLI GHA'"
98
- lease_id=$(shepherd create lease --duration 8h --pool ${pool_name} --pool-namespace ${pool_namespace} --namespace tas-devex --json | jq -r .id)
99
-
141
+ if [[ -z $SHEPHERD_LEASE_ID ]]; then
142
+ lease_id=$( shepherd create lease \
143
+ --duration ${pool_duration} \
144
+ --pool ${pool_name} \
145
+ --pool-namespace ${pool_namespace} \
146
+ --namespace ${lease_namespace} \
147
+ --description "Claimed by CF CLI workflow ${{ github.workflow_run.url }}" \
148
+ --json \
149
+ | jq -r .id
150
+ )
151
+ else
152
+ lease_id=$SHEPHERD_LEASE_ID
153
+ fi
154
+
155
+ echo "Shepherd lease ID: ${lease_id}"
156
+
100
157
# Give sometime for the lease to complete. Shepherd may take upto an 3 hours to create an env
101
158
# if the pool is empty.
102
159
count=0
103
160
while [ $count -lt 360 ] ; do
104
161
sleep 30
105
- status=$(shepherd get lease ${lease_id} --namespace tas-devex --json | jq -r .status)
162
+ status=$( shepherd get lease ${lease_id} \
163
+ --namespace ${lease_namespace} \
164
+ --json \
165
+ | jq -r .status
166
+ )
106
167
if [ $status == "LEASED" ] ; then
107
- shepherd get lease ${lease_id} --namespace tas-devex --json | jq .output > metadata.json
168
+ shepherd get lease ${lease_id} \
169
+ --namespace ${lease_namespace} \
170
+ --json \
171
+ | jq .output > metadata.json
108
172
break
109
173
elif [ $status == "FAILED" -o $status == "EXPIRED" ] ; then
110
174
echo "There was an error obtaining the lease. Lease status is ${status}."
@@ -119,7 +183,7 @@ jobs:
119
183
echo "env name is ${env_name}"
120
184
echo "leaseid=${lease_id}" >> "${GITHUB_OUTPUT}"
121
185
122
- cf_deployment_version=$(jq -r '."cf-deployment_version "' metadata.json)
186
+ cf_deployment_version=$(jq -r '."cf_deployment_version "' metadata.json)
123
187
echo "cf_deployment_version is ${cf_deployment_version}"
124
188
echo "cf_deployment_version=${cf_deployment_version}" >> "${GITHUB_OUTPUT}"
125
189
@@ -130,6 +194,7 @@ jobs:
130
194
check-latest : true
131
195
132
196
- name : Install Tools
197
+ if : ${{ (inputs.lease_id == '') || (inputs.reinstall_cfd == true) }}
133
198
run : |
134
199
go version
135
200
@@ -149,11 +214,11 @@ jobs:
149
214
apt-get install -y build-essential unzip
150
215
151
216
- name : Upload latest CAPI release
217
+ if : ${{ (inputs.lease_id == '') || (inputs.reinstall_cfd == true) }}
152
218
env :
153
219
capi_release_version : ${{ vars.CAPI_RELEASE_VERSION }}
154
220
run : |
155
- if [ -z "$capi_release_version" ]
156
- then
221
+ if [ -z "$capi_release_version" ]; then
157
222
capi_release_version=$(curl -s https://api.github.com/repos/cloudfoundry/capi-release/releases/latest | jq -r .tag_name)
158
223
fi
159
224
@@ -166,19 +231,20 @@ jobs:
166
231
bosh upload-release "https://bosh.io/d/github.com/cloudfoundry/capi-release?v=$capi_release_version"
167
232
168
233
- name : Checkout cf-deployment
234
+ if : ${{ (inputs.lease_id == '') || (inputs.reinstall_cfd == true) }}
169
235
uses : actions/checkout@v4
170
236
with :
171
237
repository : cloudfoundry/cf-deployment
172
238
path : cf-deployment
173
239
ref : ${{steps.claim.outputs.cf_deployment_version}}
174
240
175
241
- name : Deploy Isolation Segment and OIDC Provider
242
+ if : ${{ (inputs.lease_id == '') || (inputs.reinstall_cfd == true) }}
176
243
run : |
177
244
env_name=$(jq -r .name metadata.json)
178
245
jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${env_name}.priv
179
246
eval "$(bbl print-env --metadata-file metadata.json)"
180
247
181
- # deploy
182
248
bosh -d cf manifest > /tmp/manifest.yml
183
249
bosh interpolate /tmp/manifest.yml \
184
250
-o cf-deployment/operations/use-internal-lookup-for-route-services.yml \
@@ -208,6 +274,8 @@ jobs:
208
274
name : Integration
209
275
gitRef : ${{needs.get-sha.outputs.gitRef}}
210
276
lease-id : ${{ needs.claim-env.outputs.leaseid }}
277
+ lease-namespace : ${{ inputs.lease_namespace }}
278
+ nodes : ${{ inputs.nodes }}
211
279
secrets : inherit
212
280
213
281
run-integration-tests-cf-env-with-client-creds :
@@ -224,6 +292,8 @@ jobs:
224
292
name : Integration client creds
225
293
gitRef : ${{needs.get-sha.outputs.gitRef}}
226
294
lease-id : ${{ needs.claim-env.outputs.leaseid }}
295
+ lease-namespace : ${{ inputs.lease_namespace }}
296
+ nodes : ${{ inputs.nodes }}
227
297
secrets : inherit
228
298
229
299
run-cats-cf-env :
@@ -241,21 +311,26 @@ jobs:
241
311
name : cats
242
312
gitRef : ${{needs.get-sha.outputs.gitRef}}
243
313
lease-id : ${{ needs.claim-env.outputs.leaseid }}
314
+ lease-namespace : ${{ inputs.lease_namespace }}
315
+ nodes : ${{ inputs.nodes }}
244
316
secrets : inherit
245
317
246
318
unclaim-env :
247
319
name : Unclaim environment
320
+ if : ${{ inputs.lease_id == '' }}
248
321
runs-on : ubuntu-latest
249
322
container : us-west2-docker.pkg.dev/shepherd-268822/shepherd2/concourse-resource:latest
250
323
needs :
251
324
- claim-env
252
325
- run-cats-cf-env
253
- if : always()
254
326
steps :
255
327
- name : unclaim
256
328
env :
257
- account_token : ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
329
+ account_token : ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
330
+ lease_namespace : ${{ inputs.lease_namespace || vars.SHEPHERD_LEASE_NAMESPACE || 'tas-devex' }}
258
331
run : |
259
332
shepherd login service-account ${account_token}
260
333
set -x
261
- shepherd delete lease ${{ needs.claim-env.outputs.leaseid }} --namespace tas-devex
334
+ shepherd delete lease ${{ needs.claim-env.outputs.leaseid }} \
335
+ --namespace ${lease_namespace}
336
+
0 commit comments