2
2
3
3
# secrets.CLIENT_SECRET
4
4
# secrets.GITHUB_TOKEN
5
- # secrets.TOOLSMITHS_API_TOKEN
6
- # vars.TOOLSMITHS_HOSTNAME
7
- # vars.TOOLSMITHS_POOL_NAME
5
+ # secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN
6
+ # vars.SHEPHERD_POOL_NAME
8
7
9
8
name : " pvt: run integration tests"
10
9
30
29
run :
31
30
shell : bash
32
31
runs-on : ${{ inputs.os }}
33
-
32
+ container : us-west2-docker.pkg.dev/shepherd-268822/shepherd2/concourse-resource:latest
34
33
steps :
35
34
-
uses :
LouisBrunner/[email protected]
36
35
if : always()
42
41
sha : ${{github.event.workflow_run.head_sha}}
43
42
output : |
44
43
{"title": "${{ inputs.name }}", "summary":"started ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"}
44
+
45
45
- name : Checkout cli
46
46
uses : actions/checkout@v4
47
47
with :
56
56
- id : read-min-capi
57
57
name : Read MIN CAPI
58
58
run : |
59
+ wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq &&\
60
+ chmod +x /usr/bin/yq
59
61
version=$(yq '.capi-version-min' build_data.yml)
60
62
echo "version=$version" >> $GITHUB_OUTPUT
61
63
@@ -80,38 +82,36 @@ jobs:
80
82
repository : cloudfoundry/cf-deployment-concourse-tasks
81
83
path : cf-deployment-concourse-tasks
82
84
83
- - id : claim-toolsmiths- env
84
- name : Claim Toolsmiths Environment
85
+ - id : claim-env
86
+ name : Claim Environment
85
87
env :
86
- api_token : ${{ secrets.TOOLSMITHS_API_TOKEN }}
87
- hostname : ${{ vars.TOOLSMITHS_HOSTNAME }}
88
- notes : " GHA CF CLI Integration Tests ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
89
- pool_name : ${{ vars.TOOLSMITHS_POOL_NAME }}
88
+ account_token : ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
89
+ pool_name : ${{ vars.SHEPHERD_POOL_NAME }}
90
90
run : |
91
- while true; do
92
- curl -s --show-error -D headers.txt -H 'Accept: application/json' \
93
- -X POST "https://${hostname}/pooled_gcp_engineering_environments/claim" \
94
- --data-urlencode "api_token=${api_token}" \
95
- --data-urlencode "pool_name=${pool_name}" \
96
- --data-urlencode "notes=${notes}" > metadata.json \
97
- || echo "Unable to reach server, trying again in 30 seconds..."
98
-
99
- cat headers.txt
100
-
101
- ERR_500="Sorry, the Toolsmiths Environments app is currently encountering issues. Trying again in 30 seconds..."
102
- ERR_429="Sorry, Toolsmiths are out of environments in your requested pool. New environments are on their way but you can stop by the Toolsmiths slack channel for more help."
103
- ERR_409="Sorry, was not able to claim an environment. Trying again in 30 seconds..."
104
-
105
- grep -q -E "HTTP/[[:digit:]\.]{1,3} 401" headers.txt && exit 1
106
- grep -q -E "HTTP/[[:digit:]\.]{1,3} 404" headers.txt && exit 2
107
- grep -q -E "HTTP/[[:digit:]\.]{1,3} 500" headers.txt && echo "$ERR_500"
108
- grep -q -E "HTTP/[[:digit:]\.]{1,3} 200" headers.txt && break
109
- grep -q -E "HTTP/[[:digit:]\.]{1,3} 429" && echo "$ERR_429"
110
- grep -q -E "HTTP/[[:digit:]\.]{1,3} 409" && echo "$ERR_409"
91
+ shepherd login service-account ${account_token}
92
+ lease_id=$(shepherd create lease --duration 8h --pool ${pool_name} --pool-namespace official --namespace tas-devex --json | jq -r .id)
111
93
94
+ # Give somtime for the lease to complete. Shepherd may take upto an 3 hours to create an env
95
+ # if the pool is empty.
96
+ count=0
97
+ while [ $count -lt 360 ] ; do
112
98
sleep 30
99
+ status=$(shepherd get lease ${lease_id} --namespace tas-devex --json | jq -r .status)
100
+ if [ $status == "LEASED" ] ; then
101
+ shepherd get lease ${lease_id} --namespace tas-devex --json | jq .output > metadata.json
102
+ break
103
+ elif [ $status == "FAILED" -o $status == "EXPIRED" ] ; then
104
+ echo "There was an error obtaining the lease. Lease status is ${status}."
105
+ exit 1
106
+ else
107
+ echo "Waiting for environment to be ready. Lease status is ${status}."
108
+ fi
109
+ count=$(($count+1))
113
110
done
111
+
112
+ env_name=$(jq -r .name metadata.json)
114
113
cat metadata.json | jq -r '.name'
114
+ echo "lease-id=$lease_id" >> "${GITHUB_OUTPUT}"
115
115
116
116
- name : Install Tools
117
117
run : |
@@ -141,11 +141,16 @@ jobs:
141
141
chmod +x $install_location/credhub
142
142
credhub --version
143
143
144
+ apt-get update
145
+ apt-get install -y build-essential
146
+
144
147
- name : Deploy Isolation Segment and OIDC Provider
145
148
if : ${{ inputs.capi-version == 'edge' }}
146
149
env :
147
150
CF_INT_CLIENT_SECRET : ${{ secrets.CLIENT_SECRET }}
148
151
run : |
152
+ env_name=$(jq -r .name metadata.json)
153
+ jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${env_name}.priv
149
154
eval "$(bbl print-env --metadata-file metadata.json)"
150
155
151
156
# deploy
@@ -182,6 +187,8 @@ jobs:
182
187
cp cli-ci/ci/infrastructure/operations/use-latest-ruby-buildpack.yml ops-files/
183
188
184
189
# Deletes CF-D
190
+ env_name=$(jq -r .name metadata.json)
191
+ jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${env_name}.priv
185
192
eval "$(bbl print-env --metadata-file metadata.json)"
186
193
bosh -d cf delete-deployment -n
187
194
@@ -225,11 +232,13 @@ jobs:
225
232
if : ${{ !inputs.run-with-client-creds }}
226
233
run : |
227
234
ENV=$(cat metadata.json | jq -r '.name')
235
+ jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${ENV}.priv
228
236
eval "$(bbl print-env --metadata-file ./metadata.json)"
229
237
export CF_INT_PASSWORD="$(credhub get -n /bosh-$ENV/cf/cf_admin_password | bosh interpolate --path /value -)"
230
238
export CF_INT_OIDC_USERNAME="admin-oidc"
231
239
export CF_INT_OIDC_PASSWORD=$(credhub get -n /bosh-$ENV/cf/uaa_oidc_admin_password | bosh interpolate --path /value -)
232
- export CF_INT_API="https://api.${ENV}.cf-app.com"
240
+ API_URL="$(jq -r .cf.api_url metadata.json)"
241
+ export CF_INT_API="https://$API_URL"
233
242
export CF_DIAL_TIMEOUT=15
234
243
export CF_USERNAME=admin
235
244
export FLAKE_ATTEMPTS=2
@@ -255,11 +264,13 @@ jobs:
255
264
CF_INT_CLIENT_SECRET : ${{ secrets.CLIENT_SECRET }}
256
265
run : |
257
266
ENV=$(cat metadata.json | jq -r '.name')
267
+ jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${ENV}.priv
258
268
eval "$(bbl print-env --metadata-file ./metadata.json)"
259
269
export CF_INT_PASSWORD="$(credhub get -n /bosh-$ENV/cf/cf_admin_password | bosh interpolate --path /value -)"
260
270
export CF_INT_OIDC_USERNAME="admin-oidc"
261
271
export CF_INT_OIDC_PASSWORD=$(credhub get -n /bosh-$ENV/cf/uaa_oidc_admin_password | bosh interpolate --path /value -)
262
- export CF_INT_API="https://api.${ENV}.cf-app.com"
272
+ API_URL="$(jq -r .cf.api_url metadata.json)"
273
+ export CF_INT_API="https://$API_URL"
263
274
export CF_DIAL_TIMEOUT=15
264
275
export CF_USERNAME=admin
265
276
export FLAKE_ATTEMPTS=2
@@ -278,29 +289,15 @@ jobs:
278
289
279
290
make integration-tests-full-ci
280
291
281
-
282
292
- name : Unclaim environment
283
293
if : always()
284
294
env :
285
- api_token : ${{ secrets.TOOLSMITHS_API_TOKEN }}
286
- hostname : ${{ vars.TOOLSMITHS_HOSTNAME }}
295
+ account_token : ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
287
296
run : |
288
- ENV=$(cat metadata.json | jq -r '.name')
289
- while true; do
290
- output=$(curl -s --show-error -D headers.txt -H 'Accept: application/json' \
291
- -X POST "https://${hostname}/pooled_gcp_engineering_environments/unclaim" \
292
- --data-urlencode "api_token=${api_token}" \
293
- --data-urlencode "name=${ENV}")
294
-
295
- cat headers.txt
296
-
297
- ERR_500="Sorry, the Toolsmiths Environments app is currently encountering issues. Trying again in 30 seconds..."
298
-
299
- grep -q -E "HTTP/[[:digit:]\.]{1,3} 500" headers.txt && echo "$ERR_500" && sleep 30 && continue
300
- grep -q -E "HTTP/[[:digit:]\.]{1,3} 401" headers.txt && echo $(echo "$output" | jq '.messages | join(", ")') && exit 1
301
- grep -q -E "HTTP/[[:digit:]\.]{1,3} 404" headers.txt && echo $(echo "$output" | jq '.messages | join(", ")') && exit 2
302
- grep -q -E "HTTP/[[:digit:]\.]{1,3} 202" headers.txt && break
303
- done
297
+ shepherd login service-account ${account_token}
298
+ set -x
299
+ shepherd delete lease ${{ steps.claim-env.outputs.lease-id }} --namespace tas-devex
300
+
304
301
-
uses :
LouisBrunner/[email protected]
305
302
if : always()
306
303
with :
0 commit comments