Skip to content

Commit 9dc821e

Browse files
committed
Consolidate duplicate powershell code
- delete `stembuild/modules/` in favor of `modules/` - consolidate `bin/build-stemcell-automation-zip.sh` into `ci/tasks/zip-files/run.bash` - update `ci/tasks/build-psmodules-zip/run.sh` to use `modules/` - remove tests for `stembuild/modules/` code from `stemcells-windows.yml` pipeline - update various docs
1 parent c1e02a0 commit 9dc821e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+34
-5004
lines changed

bin/build-stemcell-automation-zip.sh

Lines changed: 0 additions & 26 deletions
This file was deleted.

ci/pipelines/stemcells-windows.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -686,11 +686,6 @@ jobs:
686686
tags: [windows-nimbus]
687687
params:
688688
MODULES_DIR: modules
689-
- task: test-units-stembuild-psmodules
690-
file: bosh-windows-stemcell-builder-ci/ci/tasks/test-units-bosh-psmodules/task.yml
691-
tags: [windows-nimbus]
692-
params:
693-
MODULES_DIR: stembuild/modules
694689
- task: test-units-stembuild-stemcell-automation-psmodules
695690
file: bosh-windows-stemcell-builder-ci/ci/tasks/test-units-bosh-psmodules/task.yml
696691
tags: [windows-nimbus]

ci/tasks/build-psmodules-zip/run.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ zip_output_dir="${CONCOURSE_ROOT}/${ZIP_OUTPUT_DIR:-"stemcell-builder/build"}"
88

99
mkdir -p "${zip_output_dir}"
1010

11-
pushd "${CONCOURSE_ROOT}/stemcell-builder/modules"
12-
zip -r "${zip_output_dir}/bosh-psmodules.zip" ./*
11+
pushd "${CONCOURSE_ROOT}/modules"
12+
zip -r "${zip_output_dir}/bosh-psmodules.zip" ./BOSH.*
1313
popd

ci/tasks/zip-files/run.bash

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,27 @@ set -eu -o pipefail
33

44
ROOT_DIR=$(pwd)
55

6-
export OPENSSH_ZIP=open-ssh/OpenSSH-Win64.zip
7-
export BOSH_PSMODULES_ZIP=psmodules-zip-output/bosh-psmodules.zip
8-
export AGENT_ZIP=bosh-agent/agent.zip
9-
export DEPS_JSON=deps-file/deps.json
6+
REPO_ROOT="${REPO_ROOT:-"$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)"}"
7+
ZIP_FILE_DESTINATION="${ZIP_FILE_DESTINATION:-"${ROOT_DIR}/zip-file/StemcellAutomation-$(date +"%s").zip"}"
108

11-
"${ROOT_DIR}/stemcell-builder/bin/build-stemcell-automation-zip.sh"
9+
OPENSSH_ZIP="${OPENSSH_ZIP:-"${ROOT_DIR}/open-ssh/OpenSSH-Win64.zip"}"
10+
BOSH_PSMODULES_ZIP="${BOSH_PSMODULES_ZIP:-"${ROOT_DIR}/psmodules-zip-output/bosh-psmodules.zip"}"
11+
AGENT_ZIP="${AGENT_ZIP:-"${ROOT_DIR}/bosh-agent/agent.zip"}"
12+
DEPS_JSON="${DEPS_JSON:-"${ROOT_DIR}/deps-file/deps.json"}"
1213

13-
cp "${ROOT_DIR}/stemcell-builder/stembuild/assets/StemcellAutomation.zip" \
14-
"zip-file/StemcellAutomation-$(date +"%s").zip"
14+
TEMP_DIR=$(mktemp -d)
15+
trap 'rm -r "${TEMP_DIR}"' EXIT
16+
stemcell_automation_dir="${TEMP_DIR}/stemcell_automation"
17+
stemcell_automation_zip="${TEMP_DIR}/StemcellAutomation.zip"
18+
19+
mkdir -p "${stemcell_automation_dir}"
20+
21+
declare -a files_to_zip
22+
mapfile -t files_to_zip < <(find "${REPO_ROOT}/stembuild/stemcell-automation" -type f -not -name "*Test*" -name "*.ps*1")
23+
files_to_zip+=("${OPENSSH_ZIP}" "${BOSH_PSMODULES_ZIP}" "${AGENT_ZIP}" "${DEPS_JSON}")
24+
25+
cp "${files_to_zip[@]}" "${stemcell_automation_dir}"
26+
27+
zip -rj "${stemcell_automation_zip}" "${stemcell_automation_dir}"
28+
29+
cp "${stemcell_automation_zip}" "${ZIP_FILE_DESTINATION}"

modules/README.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ The test suite for each module currently assumes that the tests are being run wi
1010
This requires iterating through the module directories to run all the tests:
1111

1212
```powershell
13-
# Where MODULES_DIR is "stembuild/modules", or "modules"
14-
cd $MODULES_DIR
13+
cd modules
1514
foreach ($module in (Get-ChildItem "./modules").Name) {
1615
Push-Location "modules/$module"
1716
$results=Invoke-Pester -PassThru
@@ -26,21 +25,17 @@ echo "Failed Tests: $result"
2625
If you just need to test a single module, you could do this:
2726

2827
```powershell
29-
# Where MODULES_DIR is "stembuild/modules", or "modules"
30-
cd "${MODULES_DIR}/BOSH.<module>"
28+
cd "modules/BOSH.<module>"
3129
Install-Module -Name Pester -Force
3230
Invoke-Pester
3331
```
3432

3533
### Running tests via Concourse
3634

3735
```shell
38-
# Where MODULES_DIR is "stembuild/modules", or "modules"
39-
export MODULES_DIR="${MODULES_DIR}"
40-
4136
WINDOWS_STEMCELL_BUILDER=${WINDOWS_STEMCELL_BUILDER:-~/workspace/bosh-windows-stemcell-builder}
4237

43-
fly -t "${CONCOURSE_TARGET:-bosh-ecosystem}" \
38+
MODULES_DIR="${DIR_WITH_PESTER_TESTS}" fly -t "${CONCOURSE_TARGET:-bosh-ecosystem}" \
4439
--tag="${WINDOWS_TAG:-windows-nimbus}" \
4540
--input=stemcell-builder="${WINDOWS_STEMCELL_BUILDER}" \
4641
--input-mapping="bosh-windows-stemcell-builder-ci=stemcell-builder" \

stembuild/README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,13 @@ You will need to construct `assets/StemcellAutomation.zip`. This file represents
263263
```json
264264
{
265265
"OpenSSH-Win64.zip": {
266-
"sha": "SOME-SHA256",
266+
"sha": "SOME-SHA256"
267267
},
268268
"bosh-psmodules.zip": {
269-
"sha": "SOME-SHA256",
269+
"sha": "SOME-SHA256"
270270
},
271271
"agent.zip": {
272-
"sha": "SOME-SHA256",
272+
"sha": "SOME-SHA256"
273273
},
274274
"LGPO.zip": {
275275
"sha": "SOME-SHA256",
@@ -278,13 +278,14 @@ You will need to construct `assets/StemcellAutomation.zip`. This file represents
278278
}
279279
```
280280

281-
Once you have these files, run `./bin/build-stemcell-automation-zip.sh`:
281+
Once you have these files, run:
282282
```bash
283-
OPENSSH_ZIP=OpenSSH-Win64.zip \
283+
OPENSSH_ZIP="OpenSSH-Win64.zip" \
284284
BOSH_PSMODULES_ZIP="bosh-psmodules.zip" \
285285
AGENT_ZIP="agent.zip" \
286286
DEPS_JSON="deps.json" \
287-
./bin/build-stemcell-automation-zip.sh
287+
ZIP_FILE_DESTINATION="stembuild/assets/StemcellAutomation.zip" \
288+
./ci/tasks/zip-files/run.bash
288289
```
289290

290291
Use `make build` to build stembuild, providing the corresponding values for the stemcell version you

stembuild/modules/BOSH.Account/BOSH.Account.Tests.ps1

Lines changed: 0 additions & 47 deletions
This file was deleted.

stembuild/modules/BOSH.Account/BOSH.Account.psd1

Lines changed: 0 additions & 21 deletions
This file was deleted.

stembuild/modules/BOSH.Account/BOSH.Account.psm1

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)