1919 BOSH_DEPLOYMENT : cf-cli-test
2020 BOSH_NON_INTERACTIVE : true
2121 PAGER : cat
22-
22+ BBL_IAAS : gcp
23+ BBL_GCP_REGION : us-east1
24+ BBL_GCP_SERVICE_ACCOUNT_KEY : ${{ secrets.GCP_CREDENTIALS_JSON }}
2325jobs :
2426 create_bosh_release :
2527 name : Create Bosh Release
3840 ./ci/scripts/download-cf-cli-binary.sh --major-version 8 --output-dir ./build/cf-cli-binaries
3941
4042 - name : Overwrite config/final.yml with the destination bucket
43+ if : ${{ vars.PRODUCTION == 'true' }}
4144 run : |
4245 cat << EOF > config/final.yml
4346 name: cf-cli
@@ -87,68 +90,60 @@ jobs:
8790 branch : ${{ format('{0}{1}', github.ref, vars.BRANCH_SUFFIX) }}
8891 github_token : ${{ secrets.GITHUB_TOKEN }}
8992
90- - name : Create test environment
91- id : create-env
92- if : ${{ !(vars.ENV_ID || vars.SKIP_TESTS == 'true') }}
93- uses : pivotal-cf/gha-shepherd@latest
94- with :
95- api_endpoint : ${{ secrets.SHEPHERD_API_ENDPOINT }}
96- api_token : ${{ secrets.SHEPHERD_API_TOKEN }}
97- command : create
98- debug : ${{ runner.debug }}
99- duration : 1h
100- namespace : tas-devex
101- pool_name : cfd
102- pool_namespace : official
103-
104- - name : Get running env metadata
105- if : ${{ vars.SKIP_TESTS != 'true' }}
106- uses : pivotal-cf/gha-shepherd@latest
107- with :
108- api_endpoint : ${{ secrets.SHEPHERD_API_ENDPOINT }}
109- api_token : ${{ secrets.SHEPHERD_API_TOKEN }}
110- command : get
111- debug : ${{ runner.debug }}
112- env_file_path : lease.json
113- env_id : ${{ vars.ENV_ID || steps.create-env.outputs.env-id }}
114- namespace : tas-devex
115-
116- - name : Store lease data
117- if : ${{ vars.SKIP_TESTS != 'true' }}
118- uses : actions/upload-artifact@v4
93+ - name : Checkout bosh-bootloader
94+ uses : actions/checkout@v4
11995 with :
120- name : lease-json
121- path : lease.json
96+ repository : cloudfoundry/bosh-bootloader
97+ path : bosh-bootloader
12298
123- - name : Deploy and run tests
124- if : ${{ vars.SKIP_TESTS != 'true' }}
99+ - name : Setup bbl
100+ id : setup-bbl-env
125101 run : |
126- rm lease.json
127-
128- # use previous lease data to reuse leased environment
129- - name : Retrieve lease data
130- if : ${{ vars.SKIP_TESTS != 'true' }}
131- uses : actions/download-artifact@v4
132- with :
133- name : lease-json
102+ env_name="$(grep '^.\{1,4\}$' /usr/share/dict/words |
103+ shuf -n1 |
104+ tr -dc '[:alnum:]\n\r' |
105+ tr '[:upper:]' '[:lower:]')"
106+
107+ if [ ! -z "${env_name}" ]; then
108+ env_name=cli-bosh-rel-${env_name}
109+ mkdir -p $env_name/bbl-state
110+ fi
111+ echo "Bbl environment name: $env_name"
112+ echo "envName=$env_name" >> $GITHUB_OUTPUT
134113
135- - name : Deploy and run tests
136- if : ${{ vars.SKIP_TESTS != 'true' }}
114+ - name : Create bbl env
115+ id : create-env
137116 run : |
138- setup_bosh_environment() {
117+ env_name=${{ steps.setup-bbl-env.outputs.envName }}
118+ cd $env_name/bbl-state
139119
140- jq -r .output lease.json > metadata.json
120+ cp -R ${GITHUB_WORKSPACE}/bosh-bootloader/plan-patches/bosh-lite-gcp/* .
121+ bbl plan --name $env_name
122+ bbl up
123+ eval "$(bbl print-env)"
124+ bosh upload-stemcell "https://bosh.io/d/stemcells/bosh-warden-boshlite-ubuntu-jammy-go_agent?v=${{ vars.STEMCELL_VERSION }}"
141125
142- env_name=$(jq -r .name metadata.json)
143- jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${env_name}.priv
144- eval "$(bbl print-env --metadata-file metadata.json)"
126+ - name : Authenticate to Google Cloud
127+ uses : google-github-actions/auth@v2
128+ with :
129+ credentials_json : ${{ secrets.GCP_CREDENTIALS_JSON }}
130+
131+ - name : Setup gcloud CLI
132+ uses : google-github-actions/setup-gcloud@v1
145133
146- }
134+ - name : Save bbl state
135+ run : |
136+ env_name=${{ steps.setup-bbl-env.outputs.envName }}
137+ gsutil -m cp -P -R ./$env_name gs://cf-cli-bosh-lites/
147138
148- setup_bosh_environment
139+ - name : Deploy and run tests
140+ if : ${{ vars.SKIP_TESTS != 'true' }}
141+ run : |
142+ env_name=${{ steps.setup-bbl-env.outputs.envName }}
149143
150- bosh delete-deployment --force
151- bosh deployments
144+ pushd $env_name/bbl-state
145+ eval "$(bbl print-env)"
146+ popd
152147
153148 echo "::group::Bosh deploy"
154149 bosh deploy ./manifests/test.yml
@@ -161,21 +156,7 @@ jobs:
161156
162157 bosh delete-deployment
163158 bosh clean-up --all
164-
165- - name : Upload artifacts with test results
166- if : ${{ vars.SKIP_TESTS != 'true' }}
167- uses : actions/upload-artifact@v4
168- with :
169- name : test-results
170- path : /tmp/cf-cli-*-test.out
171-
172- - name : Retrieve test results
173- if : ${{ vars.SKIP_TESTS != 'true' }}
174- uses : actions/download-artifact@v4
175- with :
176- name : test-results
177- path : /tmp
178-
159+
179160 - name : Verify test results
180161 if : ${{ vars.SKIP_TESTS != 'true' }}
181162 run : |
@@ -308,13 +289,11 @@ jobs:
308289 files : |
309290 ./cf-cli-v${{ steps.generate-next-release-version.outputs.version }}.tgz
310291
311- - name : Delete lease with provided env_id and namespace
292+ - name : Delete env
312293 if : ${{ always() && !vars.ENV_ID && steps.create-env.outcome == 'success' && !runner.debug }}
313- uses : pivotal-cf/gha-shepherd@latest
314- with :
315- api_endpoint : ${{ secrets.SHEPHERD_API_ENDPOINT }}
316- api_token : ${{ secrets.SHEPHERD_API_TOKEN }}
317- command : delete
318- debug : ${{ runner.debug }}
319- env_id : ${{ steps.create-env.outputs.env-id }}
320- namespace : tas-devex
294+ run : |
295+ env_name=${{ steps.setup-bbl-env.outputs.envName }}
296+ cd $env_name/bbl-state
297+ bbl destroy --no-confirm
298+ rm -rf $env_name
299+ gsutil rm -R gs://cf-cli-bosh-lites/$env_name
0 commit comments