Skip to content

Commit c567e2c

Browse files
authored
Use bosh lite env (#32)
1 parent a54173c commit c567e2c

File tree

3 files changed

+69
-82
lines changed

3 files changed

+69
-82
lines changed

.github/workflows/create-bosh-release.yml

Lines changed: 56 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ env:
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 }}
2325
jobs:
2426
create_bosh_release:
2527
name: Create Bosh Release
@@ -38,6 +40,7 @@ jobs:
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

ci/Dockerfile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
FROM summerwind/actions-runner:latest
22

3-
ENV bbl_version 8.4.111
4-
ENV bosh_cli_version 7.2.3
3+
ENV bbl_version 9.0.35
4+
ENV bosh_cli_version 7.7.2
55
ENV NODE_VERSION 22.2.0
6-
ENV terraform_version 0.11.5
6+
ENV terraform_version 1.12.2
7+
ENV credhub_version 2.9.45
78

89
USER root
910
RUN usermod -a -G sudo root
@@ -14,6 +15,8 @@ RUN \
1415
apt-get update && \
1516
apt-get -y install \
1617
shellcheck \
18+
ruby-full \
19+
wamerican \
1720
yamllint && \
1821
apt list --installed
1922

@@ -68,7 +71,7 @@ RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
6871

6972
# bosh-cli
7073
RUN \
71-
wget --no-verbose https://s3.amazonaws.com/bosh-cli-artifacts/bosh-cli-${bosh_cli_version}-linux-amd64 --output-document="/usr/local/bin/bosh" && \
74+
curl https://github.com/cloudfoundry/bosh-cli/releases/download/v${bosh_cli_version}/bosh-cli-${bosh_cli_version}-linux-amd64 --silent --output /usr/local/bin/bosh --location && \
7275
chmod +x /usr/local/bin/bosh
7376

7477
# bbl and dependencies
@@ -93,3 +96,8 @@ RUN \
9396
cd /usr/local/bin && \
9497
chmod +x terraform && \
9598
rm -rf /tmp/*
99+
100+
RUN \
101+
curl https://github.com/cloudfoundry/credhub-cli/releases/download/${credhub_version}/credhub-linux-amd64-${credhub_version}.tgz --silent --location --output /tmp/credhub.tgz && \
102+
tar -xzf /tmp/credhub.tgz -C /usr/local/bin && \
103+
chmod +x /usr/local/bin/credhub

manifests/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ instance_groups:
2929
- name: cf-cli-8-linux-test
3030
release: cf-cli
3131
properties: {}
32-
vm_type: default
32+
vm_type: minimal
3333
stemcell: default
3434
networks:
3535
- name: default

0 commit comments

Comments
 (0)