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