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 }}"
13
24
- all
14
25
- run-integration-tests-cf-env
15
26
- run-integration-tests-cf-env-with-client-creds
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
+
16
51
push :
17
52
tags :
18
53
- " v8.*"
26
61
- " doc/**"
27
62
- " .gitpod.yml"
28
63
- " README.md"
64
+ - " .github/**"
65
+ - " .grype.yaml"
66
+ - " .git*"
67
+ - " .golangci.json"
68
+
69
+ env :
70
+ SHEPHERD_LEASE_ID : ${{ inputs.lease_id }}
71
+
29
72
jobs :
73
+
30
74
get-sha :
31
75
runs-on : ubuntu-latest
32
76
outputs :
@@ -52,15 +96,18 @@ jobs:
52
96
steps :
53
97
- name : Checkout
54
98
uses : actions/checkout@v4
99
+ if : ${{ inputs.run_unit_tests == 'true' }}
55
100
with :
56
101
ref : ${{needs.get-sha.outputs.gitRef}}
57
102
fetch-depth : 0
58
103
- name : Set Up Go
59
104
uses : actions/setup-go@v5
105
+ if : ${{ inputs.run_unit_tests == 'true' }}
60
106
with :
61
107
go-version-file : go.mod
62
108
check-latest : true
63
109
- name : Run Units
110
+ if : ${{ inputs.run_unit_tests == 'true' }}
64
111
run : make units
65
112
66
113
claim-env :
@@ -84,23 +131,57 @@ jobs:
84
131
- name : claim
85
132
id : claim
86
133
env :
87
- account_token : ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
88
- pool_name : ${{ vars.SHEPHERD_POOL_NAME }}
89
- 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' }}
90
140
run : |
91
141
shepherd login service-account ${account_token}
92
142
93
- echo "shepherd create lease --duration 8h --pool ${pool_name} --pool-namespace ${pool_namespace} --namespace tas-devex --description 'CLI GHA'"
94
- lease_id=$(shepherd create lease --duration 8h --pool ${pool_name} --pool-namespace ${pool_namespace} --namespace tas-devex --json | jq -r .id)
95
-
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
+
96
170
# Give sometime for the lease to complete. Shepherd may take upto an 3 hours to create an env
97
171
# if the pool is empty.
98
172
count=0
99
173
while [ $count -lt 360 ] ; do
100
174
sleep 30
101
- 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
+ )
102
180
if [ $status == "LEASED" ] ; then
103
- 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
104
185
break
105
186
elif [ $status == "FAILED" -o $status == "EXPIRED" ] ; then
106
187
echo "There was an error obtaining the lease. Lease status is ${status}."
@@ -115,7 +196,7 @@ jobs:
115
196
echo "env name is ${env_name}"
116
197
echo "leaseid=${lease_id}" >> "${GITHUB_OUTPUT}"
117
198
118
- cf_deployment_version=$(jq -r '."cf-deployment_version "' metadata.json)
199
+ cf_deployment_version=$(jq -r '."cf_deployment_version "' metadata.json)
119
200
echo "cf_deployment_version is ${cf_deployment_version}"
120
201
echo "cf_deployment_version=${cf_deployment_version}" >> "${GITHUB_OUTPUT}"
121
202
@@ -126,6 +207,7 @@ jobs:
126
207
check-latest : true
127
208
128
209
- name : Install Tools
210
+ if : ${{ (inputs.lease_id == '') || (inputs.reinstall_cfd == true) }}
129
211
run : |
130
212
go version
131
213
@@ -145,11 +227,11 @@ jobs:
145
227
apt-get install -y build-essential unzip
146
228
147
229
- name : Upload latest CAPI release
230
+ if : ${{ (inputs.lease_id == '') || (inputs.reinstall_cfd == true) }}
148
231
env :
149
232
capi_release_version : ${{ vars.CAPI_RELEASE_VERSION }}
150
233
run : |
151
- if [ -z "$capi_release_version" ]
152
- then
234
+ if [ -z "$capi_release_version" ]; then
153
235
capi_release_version=$(curl -s https://api.github.com/repos/cloudfoundry/capi-release/releases/latest | jq -r .tag_name)
154
236
fi
155
237
@@ -162,19 +244,20 @@ jobs:
162
244
bosh upload-release "https://bosh.io/d/github.com/cloudfoundry/capi-release?v=$capi_release_version"
163
245
164
246
- name : Checkout cf-deployment
247
+ if : ${{ (inputs.lease_id == '') || (inputs.reinstall_cfd == true) }}
165
248
uses : actions/checkout@v4
166
249
with :
167
250
repository : cloudfoundry/cf-deployment
168
251
path : cf-deployment
169
252
ref : ${{steps.claim.outputs.cf_deployment_version}}
170
253
171
254
- name : Deploy Isolation Segment and OIDC Provider
255
+ if : ${{ (inputs.lease_id == '') || (inputs.reinstall_cfd == true) }}
172
256
run : |
173
257
env_name=$(jq -r .name metadata.json)
174
258
jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${env_name}.priv
175
259
eval "$(bbl print-env --metadata-file metadata.json)"
176
260
177
- # deploy
178
261
bosh -d cf manifest > /tmp/manifest.yml
179
262
bosh interpolate /tmp/manifest.yml \
180
263
-o cf-deployment/operations/use-internal-lookup-for-route-services.yml \
@@ -204,6 +287,8 @@ jobs:
204
287
name : Integration
205
288
gitRef : ${{needs.get-sha.outputs.gitRef}}
206
289
lease-id : ${{ needs.claim-env.outputs.leaseid }}
290
+ lease-namespace : ${{ inputs.lease_namespace || vars.SHEPHERD_LEASE_NAMESPACE || 'tas-devex' }}
291
+ nodes : ${{ inputs.nodes }}
207
292
secrets : inherit
208
293
209
294
run-integration-tests-cf-env-with-client-creds :
@@ -220,22 +305,25 @@ jobs:
220
305
name : Integration client creds
221
306
gitRef : ${{needs.get-sha.outputs.gitRef}}
222
307
lease-id : ${{ needs.claim-env.outputs.leaseid }}
308
+ lease-namespace : ${{ inputs.lease_namespace || vars.SHEPHERD_LEASE_NAMESPACE || 'tas-devex' }}
223
309
secrets : inherit
224
310
225
311
unclaim-env :
226
312
name : Unclaim environment
313
+ if : ${{ inputs.lease_id == '' }}
227
314
runs-on : ubuntu-latest
228
315
container : us-west2-docker.pkg.dev/shepherd-268822/shepherd2/concourse-resource:latest
229
316
needs :
230
317
- claim-env
231
318
- run-integration-tests-cf-env
232
319
- run-integration-tests-cf-env-with-client-creds
233
- if : always()
234
320
steps :
235
321
- name : unclaim
236
322
env :
237
- account_token : ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
323
+ account_token : ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
324
+ lease_namespace : ${{ inputs.lease_namespace || vars.SHEPHERD_LEASE_NAMESPACE || 'tas-devex' }}
238
325
run : |
239
326
shepherd login service-account ${account_token}
240
327
set -x
241
- shepherd delete lease ${{ needs.claim-env.outputs.leaseid }} --namespace tas-devex
328
+ shepherd delete lease ${{ needs.claim-env.outputs.leaseid }} \
329
+ --namespace ${lease_namespace}
0 commit comments