diff --git a/.gitignore b/.gitignore index fe9a628c..5b6f7d4b 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,6 @@ releases/*.tgz releases/**/*.tgz ci/scripts/stemcell/*.tgz ci/scripts/stemcell-bionic/*.tgz -ci/scripts/bpm/*.tgz dev_releases blobs/* .blobs diff --git a/acceptance-tests/README.md b/acceptance-tests/README.md index 1a6797f0..637bd45c 100644 --- a/acceptance-tests/README.md +++ b/acceptance-tests/README.md @@ -3,12 +3,7 @@ ## Requirements * Docker installed locally -* A matching Jammy stemcell tgz downloaded to `ci/scripts/stemcell` - * Get it from https://bosh.io/stemcells/bosh-warden-boshlite-ubuntu-jammy-go_agent -* A matching Bionic stemcell tgz downloaded to `ci/scripts/stemcell-bionic` - * Get it from https://bosh.io/stemcells/bosh-warden-boshlite-ubuntu-bionic-go_agent -* A BPM release tgz downloaded to `ci/scripts/bpm` - * Get it from https://bosh.io/releases/github.com/cloudfoundry/bpm-release?all=1 +* x86 based computer (cloudfoundry currently doesn't build/run on arm; rosetta can't run docker in docker for x86) ## Running @@ -19,6 +14,8 @@ cd acceptance-tests ### Running on Docker for Mac +Unfortunately rosetta on arm based macs doesn't support docker in docker required for bosh docker-cpi used in this test setup. You will either have to run on x86 based mac or some remote x86 workstation. Virtualization using QEMU is possible, but so slow the tests fail on timeouts. + The BOSH Docker CPI requires cgroups v1 to be active. Docker for Mac since 4.3.x uses cgroups v2 by default. v1 can be restored with the flag `deprecatedCgroupv1` to `true` in `~/Library/Group Containers/group.com.docker/settings.json`. @@ -82,24 +79,40 @@ The output at the end should be: If you want to run only a specific part of the suite, you can use [focussed specs](https://onsi.github.io/ginkgo/#focused-specs) -The easiest way is to just provide the name of the tests you want to run as a command line argument like so: +The easiest way is to just provide the name of the tests you want to run as a `-F` command line argument: ```shell -./run-local.sh "description of the test to run" +./run-local.sh -F "description of the test to run" ``` The argument is passed as a regular expression that will match all `Describe`, `Context` or `It` closure descriptions in the suite. So, e.g. if you want to run all tests that use mTLS, you can run: ```shell -./run-local.sh mTLS +./run-local.sh -F mTLS ``` However, if you want to run exactly one specific test, make sure you pass the exact description of the matching `It` closure: ```shell -./run-local.sh "Correctly terminates mTLS requests" +./run-local.sh -F "Correctly terminates mTLS requests" ``` -Alternatively, you add an `F` to your `Describe`, `Context` or `It` closures. -Don't forget to do a local commit before running the tests, else BOSH will fail to produce a release. The git repo must be clean before running the tests. +Running tests in focus will also preserve the bosh container running after tests complete, so that you can easily run tests again without having to wait for bosh set-up again. + +### Persistent BOSH + +Because BOSH setup takes a while (it starts from scratch with bosh create-env), it is useful to preserve the container with bosh already configured to run tests. This can be done either by providing test focus as described above, or `-k` (keep) switch to `run-local.sh` and `run-shell.sh` scripts, e.g. `run-shell.sh -k`. Once initial setup is complete, scripts will output a message about how to get back into the running container: + +```text +KEEP_RUNNING is true and bosh remains running. +Re-enter container via: docker exec -it b7c767c5c0e4 bash + +Stop with: docker stop b7c767c5c0e4 +``` + +After you have completed your work and have stopped the container, it is required you do further cleanup. In order to have a working overlay2 filesystem for docker-cpi, it is necessary to mount ext4 based storage from `/workspace/docker-in` into the bosh container. Each container gets its own temporary space, which in case of containers that keep running is not deleted when the tests complete. The scripts will output the location of this temporary storage: + +```text +*** KEEP_RUNNING enabled. Please clean up docker scratch after removing containers: /workspace/docker-in/scratch-19517 +``` diff --git a/acceptance-tests/run-local.sh b/acceptance-tests/run-local.sh index 282146f6..391a8acd 100755 --- a/acceptance-tests/run-local.sh +++ b/acceptance-tests/run-local.sh @@ -1,18 +1,32 @@ #!/usr/bin/env bash -FOCUS="$1" set -eu +REPO_DIR="$(cd "$(dirname "$0")/.." && pwd)" +source "${REPO_DIR}/ci/scripts/functions-ci.sh" +KEEP_RUNNING="" -SCRIPT_DIR="$(cd "$(dirname "$0")/" && pwd)" -REPO_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" +usage() { + echo -e "Usage: $0 [-F ] [-k] -if ! [[ $(git status --porcelain=v1 2>/dev/null | wc -l) -eq 0 ]]; then - echo "You have changes in your Git repository. Commit or clean (e.g. git clean -f) before running." - echo "The build will fail otherwise." - echo "Git Status:" - git status - exit 1 -fi + -F Focus on a particular test. Expects a Ginkgo test name. Keep bosh running afterwards. + -k Keep bosh container running. Useful for debug." 1>&2; exit 1; +} + +while getopts ":F:k" o; do + case "${o}" in + F) + FOCUS=${OPTARG} + KEEP_RUNNING=true + ;; + k) + KEEP_RUNNING=true + ;; + *) + usage + ;; + esac +done +shift $((OPTIND-1)) docker_mac_check_cgroupsv1() { # Force cgroups v1 on Docker for Mac @@ -31,19 +45,14 @@ docker_mac_check_cgroupsv1() { check_required_files() { PIDS="" REQUIRED_FILE_PATTERNS=( - ../ci/scripts/stemcell/bosh-stemcell-*-ubuntu-jammy-*.tgz!https://bosh.io/d/stemcells/bosh-warden-boshlite-ubuntu-jammy-go_agent - ../ci/scripts/stemcell-bionic/bosh-stemcell-*-ubuntu-bionic-*.tgz!https://bosh.io/d/stemcells/bosh-warden-boshlite-ubuntu-bionic-go_agent + ci/scripts/stemcell/bosh-stemcell-*-ubuntu-jammy-*.tgz!https://bosh.io/d/stemcells/bosh-warden-boshlite-ubuntu-jammy-go_agent + ci/scripts/stemcell-bionic/bosh-stemcell-*-ubuntu-bionic-*.tgz!https://bosh.io/d/stemcells/bosh-warden-boshlite-ubuntu-bionic-go_agent ) - # BPM downloads as uuid and needs manually specifying file name - if [ ! -f "../ci/scripts/bpm/bpm-release-latest.tgz" ] ; then - curl -sL https://bosh.io/d/github.com/cloudfoundry/bpm-release -o ../ci/scripts/bpm/bpm-release-latest.tgz - fi - for entry in "${REQUIRED_FILE_PATTERNS[@]}"; do pattern=$(cut -f1 -d! <<<"$entry") url=$(cut -f2 -d! <<<"$entry") - folder=$(realpath "$(dirname "$SCRIPT_DIR/$pattern")") + folder=$(realpath "$(dirname "$REPO_DIR/$pattern")") filepattern=$(basename "$pattern") pattern=$folder/$filepattern @@ -76,14 +85,17 @@ if [ "$(uname)" == "Darwin" ]; then docker_mac_check_cgroupsv1 fi -# Build acceptance test image -pushd "$SCRIPT_DIR/../ci" || exit 1 - docker build -t haproxy-boshrelease-testflight . -popd || exit 1 +build_image "${REPO_DIR}/ci" +prepare_docker_scratch # Run acceptance tests -if [ -n "$FOCUS" ]; then - docker run --privileged -v "$REPO_DIR":/repo -e REPO_ROOT=/repo -e FOCUS="$FOCUS" haproxy-boshrelease-testflight bash -c "cd /repo/ci/scripts && ./acceptance-tests ; sleep infinity" +if [ -n "$KEEP_RUNNING" ] ; then + echo + echo "*** KEEP_RUNNING enabled. Please clean up docker scratch after removing containers: ${DOCKER_SCRATCH}" + echo + docker run --privileged -v "$REPO_DIR":/repo -v "${DOCKER_SCRATCH}":/scratch/docker -e REPO_ROOT=/repo -e FOCUS="$FOCUS" -e KEEP_RUNNING="${KEEP_RUNNING}" haproxy-boshrelease-testflight bash -c "cd /repo/ci/scripts && ./acceptance-tests ; sleep infinity" else - docker run --rm --privileged -v "$REPO_DIR":/repo -e REPO_ROOT=/repo haproxy-boshrelease-testflight bash -c "cd /repo/ci/scripts && ./acceptance-tests" + docker run --rm --privileged -v "$REPO_DIR":/repo -v "${DOCKER_SCRATCH}":/scratch/docker -e REPO_ROOT=/repo -e KEEP_RUNNING="" haproxy-boshrelease-testflight bash -c "cd /repo/ci/scripts && ./acceptance-tests" + echo "Cleaning up docker scratch: ${DOCKER_SCRATCH}" + sudo rm -rf "${DOCKER_SCRATCH}" fi diff --git a/acceptance-tests/run-shell.sh b/acceptance-tests/run-shell.sh index c98a21c6..b0d094d9 100755 --- a/acceptance-tests/run-shell.sh +++ b/acceptance-tests/run-shell.sh @@ -1,14 +1,37 @@ #!/usr/bin/env bash set -e +REPO_DIR="$(cd "$(dirname "$0")/.." && pwd)" +source "${REPO_DIR}/ci/scripts/functions-ci.sh" -SCRIPT_DIR="$(cd "$(dirname "$0")/" && pwd)" -REPO_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" +usage() { + echo -e "Usage: $0 [-k] -# Build acceptance test image -pushd "$SCRIPT_DIR/../ci" || exit 1 - docker build -t haproxy-boshrelease-testflight . -popd || exit 1 + -k Keep bosh container running. Useful for debug." 1>&2; exit 1; +} -# Run local shell -docker run -it --rm --privileged -v "$REPO_DIR":/repo -e REPO_ROOT=/repo haproxy-boshrelease-testflight bash -c "cd /repo/ci/scripts && ./shell" +while getopts ":k" o; do + case "${o}" in + k) + KEEP_RUNNING=true + ;; + *) + usage + ;; + esac +done + +build_image "${REPO_DIR}/ci" +prepare_docker_scratch + +# Run local shell - start new container with bosh +if [ -n "${KEEP_RUNNING}" ] ; then + echo + echo "*** KEEP_RUNNING enabled. Please clean up docker scratch after removing containers: ${DOCKER_SCRATCH}" + echo + docker run -it --privileged -v "$REPO_DIR":/repo -v "${DOCKER_SCRATCH}":/scratch/docker -e KEEP_RUNNING="${KEEP_RUNNING}" -e REPO_ROOT=/repo haproxy-boshrelease-testflight bash -c "cd /repo/ci/scripts && ./shell ; sleep infinity" +else + docker run -it --rm --privileged -v "$REPO_DIR":/repo -v "${DOCKER_SCRATCH}":/scratch/docker -e KEEP_RUNNING="" -e REPO_ROOT=/repo haproxy-boshrelease-testflight bash -c "cd /repo/ci/scripts && ./shell" + echo "Cleaning up docker scratch: ${DOCKER_SCRATCH}" + sudo rm -rf "${DOCKER_SCRATCH}" +fi diff --git a/ci/compilation.yml b/ci/compilation.yml new file mode 100644 index 00000000..a8fa4e0c --- /dev/null +++ b/ci/compilation.yml @@ -0,0 +1,3 @@ +- path: /compilation/workers + type: replace + value: 2 diff --git a/ci/pipeline.yml b/ci/pipeline.yml index 98b62f8b..c95d56f0 100644 --- a/ci/pipeline.yml +++ b/ci/pipeline.yml @@ -122,7 +122,6 @@ jobs: - { get: git, trigger: true, passed: [unit-tests] } - { get: stemcell } - { get: stemcell-bionic } - - { get: bpm } - get: haproxy-boshrelease-testflight - task: acceptance-tests privileged: true @@ -133,7 +132,6 @@ jobs: - { name: git } - { name: stemcell } - { name: stemcell-bionic } - - { name: bpm } run: path: ./git/ci/scripts/acceptance-tests args: [] @@ -155,7 +153,6 @@ jobs: - { get: git-pull-requests, trigger: true, version: every } - { get: stemcell } - { get: stemcell-bionic } - - { get: bpm } - get: haproxy-boshrelease-testflight - put: git-pull-requests params: @@ -173,7 +170,6 @@ jobs: - { name: git-pull-requests } - { name: stemcell } - { name: stemcell-bionic } - - { name: bpm } run: path: ./git-pull-requests/ci/scripts/acceptance-tests args: [] @@ -418,11 +414,6 @@ resources: source: name: bosh-warden-boshlite-ubuntu-jammy-go_agent - - name: bpm - type: bosh-io-release - source: - repository: cloudfoundry/bpm-release - - name: version type: semver source : diff --git a/ci/scripts/acceptance-tests b/ci/scripts/acceptance-tests index 6a017c5e..9cc17e83 100755 --- a/ci/scripts/acceptance-tests +++ b/ci/scripts/acceptance-tests @@ -1,27 +1,18 @@ #!/bin/bash set -e - -stemcell_jammy_path=$PWD/stemcell/*.tgz -stemcell_bionic_path=$PWD/stemcell-bionic/*.tgz -bpm_release_path=$PWD/bpm/*.tgz +source "${REPO_ROOT}/ci/scripts/functions-ci.sh" +START_DIR="${PWD}" # Differs for CI and manual execution if [ -n "$FOCUS" ]; then echo "------------------------------------------------------------------" echo "FOCUS is set. Will only run tests matching '$FOCUS'" - echo "Docker won't be stopped afterwards, so you can debug the test." echo "------------------------------------------------------------------" ADDITIONAL_ARGS=("--focus" "$FOCUS") fi -cd "${REPO_ROOT:?required}" -echo "----- Pulling in any git submodules..." -git config --global --add safe.directory /repo -git config --global --add safe.directory /repo/src/ttar -git submodule update --init --recursive --force +git_pull -# shellcheck disable=SC1091 -source "ci/scripts/skip-ci.sh" if [ -f ".git/resource/changed_files" ]; then if skip_ci "ci/.ci-ignore" ".git/resource/changed_files"; then echo "SKIP TEST: Only .ci-ignored changes found." @@ -30,47 +21,8 @@ if [ -f ".git/resource/changed_files" ]; then echo "RUN TEST: There is at least one non-ignored change found." fi fi -echo "----- Starting BOSH" - -./ci/scripts/start-bosh.sh - -function stop_docker() { - echo "----- stopping docker" - service docker stop -} - -if [ -z "$FOCUS" ]; then - trap stop_docker EXIT -fi - -# shellcheck disable=SC1091 -source /tmp/local-bosh/director/env - -echo "----- Creating candidate BOSH release..." -bosh -n reset-release # in case dev_releases/ is in repo accidentally - -bosh create-release -bosh upload-release --rebase -release_final_version=$(spruce json dev_releases/*/index.yml | jq -r ".builds[].version" | sed -e "s%+.*%%") -export RELEASE_VERSION="${release_final_version}.latest" -echo "----- Created ${RELEASE_VERSION}" - -echo "----- Uploading Jammy stemcell" -bosh -n upload-stemcell $stemcell_jammy_path -echo "----- Uploading Bionic stemcell" -bosh -n upload-stemcell $stemcell_bionic_path - -echo "----- Uploading BPM" -bosh -n upload-release $bpm_release_path - -echo "----- Uploading os-conf (used for tests only)" -bosh -n upload-release --sha1 386293038ae3d00813eaa475b4acf63f8da226ef \ - https://bosh.io/d/github.com/cloudfoundry/os-conf-release?v=22.1.2 - -# shellcheck disable=SC2155 -export BOSH_PATH=$(which bosh) -export BASE_MANIFEST_PATH="$PWD/manifests/haproxy.yml" +prepare_bosh cd "acceptance-tests" @@ -82,4 +34,12 @@ echo "----- Running tests" export PATH=$PATH:$GOPATH/bin ginkgo version -ginkgo -v -p -r --trace --show-node-events --randomize-all --flake-attempts 5 "${ADDITIONAL_ARGS[@]}" + +PARALLELISM="-p" +if [ -n "$FOCUS" ]; then + PARALLELISM="--nodes=1" +fi + +ginkgo -v "$PARALLELISM" -r --trace --show-node-events --randomize-all --flake-attempts 5 "${ADDITIONAL_ARGS[@]}" + +keep_running_info diff --git a/ci/scripts/bpm/.gitkeep b/ci/scripts/bpm/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/ci/scripts/functions-ci.sh b/ci/scripts/functions-ci.sh new file mode 100755 index 00000000..d3e64d50 --- /dev/null +++ b/ci/scripts/functions-ci.sh @@ -0,0 +1,110 @@ +#!/bin/bash + +function skip_ci() { + local ignore_list="$1" + local changed_files="$2" + while read -r changed_file + do + while read -r skip_for + do + # If a directory is on the allow-list + if [ -d "$skip_for" ]; then + for file_in_dir in "$skip_for"/*; do + if [ "$file_in_dir" == "$changed_file" ]; then + continue 3 + fi + done + fi + if [ "$skip_for" == "$changed_file" ] ; then + continue 2 + fi + done < "$ignore_list" + # If we get here the file is not skipped or in a skipped dir. + return 1 + done < "$changed_files" + # If we get here, all files are skipped or in skipped dirs. + return 0 +} + +function stop_docker() { + echo "----- stopping docker" + service docker stop +} + +# Build acceptance test image if not found. +function build_image() { + if docker images -a | grep "haproxy-boshrelease-testflight " ; then + echo "Found existing testflight image, skipping docker build. To force rebuild delete this image." + else + pushd "$1" + docker build -t haproxy-boshrelease-testflight . + popd + fi +} + +function git_pull() { + cd "${REPO_ROOT:?required}" + echo "----- Pulling in any git submodules..." + git config --global --add safe.directory /repo + git config --global --add safe.directory /repo/src/ttar + git submodule update --init --recursive --force +} + +function bosh_release() { + echo "----- Creating candidate BOSH release..." + bosh -n reset-release # in case dev_releases/ is in repo accidentally + + bosh create-release --force + bosh upload-release --rebase + release_final_version=$(spruce json dev_releases/*/index.yml | jq -r ".builds[].version" | sed -e "s%+.*%%") + export RELEASE_VERSION="${release_final_version}.latest" + echo "----- Created ${RELEASE_VERSION}" +} + +function bosh_assets() { + stemcell_jammy_path="$START_DIR/stemcell/*.tgz" + stemcell_bionic_path="$START_DIR/stemcell-bionic/*.tgz" + + echo "----- Uploading Jammy stemcell" + bosh -n upload-stemcell $stemcell_jammy_path + + echo "----- Uploading Bionic stemcell" + bosh -n upload-stemcell $stemcell_bionic_path + + echo "----- Uploading os-conf (used for tests only)" + bosh -n upload-release --sha1 386293038ae3d00813eaa475b4acf63f8da226ef \ + https://bosh.io/d/github.com/cloudfoundry/os-conf-release?v=22.1.2 + + export BOSH_PATH=$(command -v bosh) + export BASE_MANIFEST_PATH="$PWD/manifests/haproxy.yml" +} + +function prepare_bosh() { + if [ -z "${KEEP_RUNNING}" ] ; then + ./ci/scripts/start-bosh.sh + trap stop_docker EXIT + elif ! bosh deployments &>/dev/null ; then # With KEEP_RUNNING only start when not running already + ./ci/scripts/start-bosh.sh + fi + + # shellcheck disable=SC1091 + source /tmp/local-bosh/director/env + bosh_release + bosh_assets +} + +function keep_running_info() { + if [ -n "${KEEP_RUNNING}" ] ; then + echo + echo "KEEP_RUNNING is ${KEEP_RUNNING} and bosh remains running." + echo "Re-enter container via: docker exec -it $(hostname) bash" + echo + echo "Stop with: docker stop $(hostname)" + fi +} + +# Prepare ext4 based scratch for internal docker. This is so that it can run overlay2 FS for its containers. +function prepare_docker_scratch() { + DOCKER_SCRATCH="/workspace/docker-in/scratch-$RANDOM" + mkdir $DOCKER_SCRATCH +} diff --git a/ci/scripts/lint b/ci/scripts/lint index cdba86b7..9b8a4419 100755 --- a/ci/scripts/lint +++ b/ci/scripts/lint @@ -2,7 +2,7 @@ set -euo pipefail -cd ${REPO_ROOT} +cd "${REPO_ROOT}" bundle package bundle exec rake lint diff --git a/ci/scripts/shell b/ci/scripts/shell index c4efecd1..6e159d69 100755 --- a/ci/scripts/shell +++ b/ci/scripts/shell @@ -1,49 +1,12 @@ #!/bin/bash set -eu +source "${REPO_ROOT}/ci/scripts/functions-ci.sh" +START_DIR="${PWD}" # Differs for CI and manual execution -stemcell_path=$PWD/stemcell/*.tgz -bpm_release_path=$PWD/bpm/*.tgz - -cd ${REPO_ROOT:?required} -echo "----- Pulling in any git submodules..." -git config --global --add safe.directory /repo -git config --global --add safe.directory /repo/src/ttar -git submodule update --init --recursive --force - -echo "----- Starting BOSH" - -./ci/scripts/start-bosh.sh - -function stop_docker() { - echo "----- stopping docker" - service docker stop -} - -trap stop_docker EXIT - -source /tmp/local-bosh/director/env - -echo "----- Creating candidate BOSH release..." -bosh -n reset-release # in case dev_releases/ is in repo accidentally - -bosh create-release -bosh upload-release --rebase -release_final_version=$(spruce json dev_releases/*/index.yml | jq -r ".builds[].version" | sed -e "s%+.*%%") -export RELEASE_VERSION="${release_final_version}.latest" -echo "----- Created ${RELEASE_VERSION}" - -echo "----- Uploading stemcell" -bosh -n upload-stemcell $stemcell_path - -echo "----- Uploading BPM" -bosh -n upload-release $bpm_release_path - -echo "----- Uploading os-conf (used for tests only)" -bosh -n upload-release --sha1 386293038ae3d00813eaa475b4acf63f8da226ef \ - https://bosh.io/d/github.com/cloudfoundry/os-conf-release?v=22.1.2 - -export BOSH_PATH=$(which bosh) -export BASE_MANIFEST_PATH="$PWD/manifests/haproxy.yml" +git_pull +prepare_bosh bash + +keep_running_info diff --git a/ci/scripts/skip-ci.sh b/ci/scripts/skip-ci.sh deleted file mode 100755 index 0ba00057..00000000 --- a/ci/scripts/skip-ci.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -function skip_ci() { - local ignore_list="$1" - local changed_files="$2" - while read -r changed_file - do - while read -r skip_for - do - # If a directory is on the allow-list - if [ -d "$skip_for" ]; then - for file_in_dir in "$skip_for"/*; do - if [ "$file_in_dir" == "$changed_file" ]; then - continue 3 - fi - done - fi - if [ "$skip_for" == "$changed_file" ] ; then - continue 2 - fi - done < "$ignore_list" - # If we get here the file is not skipped or in a skipped dir. - return 1 - done < "$changed_files" - # If we get here, all files are skipped or in skipped dirs. - return 0 -} diff --git a/ci/scripts/start-bosh.sh b/ci/scripts/start-bosh.sh index 7dd9de68..3bda28f6 100755 --- a/ci/scripts/start-bosh.sh +++ b/ci/scripts/start-bosh.sh @@ -99,10 +99,7 @@ function sanitize_cgroups() { done } -function stop_docker() { - echo "ERROR: stopping docker" - service docker stop -} +source "ci/scripts/functions-ci.sh" function start_docker() { generate_certs "$1" @@ -165,8 +162,10 @@ EOF exit 1 fi - trap stop_docker ERR - echo $certs_dir + if [ -z "${KEEP_RUNNING}" ] ; then + trap stop_docker ERR + fi + echo "$certs_dir" } function main() { @@ -187,7 +186,8 @@ function main() { docker network create -d bridge --subnet=10.245.0.0/16 director_network fi - pushd ${BOSH_DEPLOYMENT_PATH:-/usr/local/bosh-deployment} > /dev/null + compilation_ops="$PWD/ci/compilation.yml" + pushd "${BOSH_DEPLOYMENT_PATH:-/usr/local/bosh-deployment}" > /dev/null export BOSH_DIRECTOR_IP="10.245.0.3" export BOSH_ENVIRONMENT="docker-director" @@ -202,7 +202,7 @@ function main() { -v internal_ip="${BOSH_DIRECTOR_IP}" \ -v docker_host="${DOCKER_HOST}" \ -v network=director_network \ - -v docker_tls="{\"ca\": \"$(cat ${certs_dir}/ca_json_safe.pem)\",\"certificate\": \"$(cat ${certs_dir}/client_certificate_json_safe.pem)\",\"private_key\": \"$(cat ${certs_dir}/client_private_key_json_safe.pem)\"}" \ + -v docker_tls="{\"ca\": \"$(cat "${certs_dir}"/ca_json_safe.pem)\",\"certificate\": \"$(cat "${certs_dir}"/client_certificate_json_safe.pem)\",\"private_key\": \"$(cat "${certs_dir}"/client_private_key_json_safe.pem)\"}" \ ${@} > "${local_bosh_dir}/bosh-director.yml" command bosh create-env "${local_bosh_dir}/bosh-director.yml" \ @@ -215,15 +215,16 @@ function main() { cat < "${local_bosh_dir}/env" export BOSH_ENVIRONMENT="${BOSH_ENVIRONMENT}" export BOSH_CLIENT=admin - export BOSH_CLIENT_SECRET=`bosh int "${local_bosh_dir}/creds.yml" --path /admin_password` + export BOSH_CLIENT_SECRET=$(bosh int "${local_bosh_dir}/creds.yml" --path /admin_password) export BOSH_CA_CERT="${local_bosh_dir}/ca.crt" EOF source "${local_bosh_dir}/env" - bosh -n update-cloud-config docker/cloud-config.yml -v network=director_network + bosh -n update-cloud-config docker/cloud-config.yml -v network=director_network -o "${compilation_ops}" popd > /dev/null } +echo "----- Starting BOSH" main $@ diff --git a/ci/scripts/unit-tests b/ci/scripts/unit-tests index 0cca6285..dc9d50fa 100755 --- a/ci/scripts/unit-tests +++ b/ci/scripts/unit-tests @@ -2,7 +2,7 @@ set -euo pipefail -cd ${REPO_ROOT} +cd "${REPO_ROOT}" bundle install bundle exec rake spec diff --git a/ci/scripts/update-blob b/ci/scripts/update-blob index f23d825b..976b504b 100755 --- a/ci/scripts/update-blob +++ b/ci/scripts/update-blob @@ -2,15 +2,15 @@ set -e -: ${BLOB_DIR:?required} -: ${BLOB_NAME:?required} -: ${BLOB_BINARY:?required} -: ${BLOB_CLEANUP:?required} -: ${BLOB_DESTINATION:?required} +: "${BLOB_DIR:?required}" +: "${BLOB_NAME:?required}" +: "${BLOB_BINARY:?required}" +: "${BLOB_CLEANUP:?required}" +: "${BLOB_DESTINATION:?required}" -VERSION=$(cat ${BLOB_DIR}/version) +VERSION=$(cat "${BLOB_DIR}"/version) -pushd ${REPO_ROOT:?required} +pushd "${REPO_ROOT:?required}" cat <config/private.yml --- @@ -22,19 +22,19 @@ blobstore: EOF blobs_to_remove=$(spruce json config/blobs.yml | jq -r "keys[] | select(test(\"${BLOB_CLEANUP}\"))") -if [[ ! -z $blobs_to_remove ]]; then +if [[ -n $blobs_to_remove ]]; then echo "$blobs_to_remove" | xargs -L1 bosh remove-blob fi # expand ${VERSION} env var into file path eval "blob_destination=${BLOB_DESTINATION}" -bosh add-blob ../${BLOB_DIR}/${BLOB_BINARY} "${blob_destination}" +bosh add-blob "../${BLOB_DIR}/${BLOB_BINARY}" "${blob_destination}" bosh -n upload-blobs rm config/private.yml popd -if [[ -n "$(cd ${REPO_ROOT}; git status --porcelain)" ]]; then - pushd ${REPO_ROOT} +if [[ -n "$(cd "${REPO_ROOT}"; git status --porcelain)" ]]; then + pushd "${REPO_ROOT}" cat <>ci/release_notes.md # ${BLOB_NAME} @@ -50,12 +50,12 @@ EOF git config --global user.name "CI Bot" fi - (cd ${REPO_ROOT} - git merge --no-edit ${BRANCH} + (cd "${REPO_ROOT}" + git merge --no-edit "${BRANCH}" git add -A git status git commit -m "Bumped ${BLOB_NAME} to v${VERSION}") fi # so that future steps in the pipeline can push our changes -cp -a ${REPO_ROOT} ${REPO_OUT} +cp -a "${REPO_ROOT}" "${REPO_OUT}" diff --git a/ci/scripts/update-manifest b/ci/scripts/update-manifest index 40a58afc..dc887733 100755 --- a/ci/scripts/update-manifest +++ b/ci/scripts/update-manifest @@ -5,13 +5,12 @@ RELEASE_NAME=$2 VERSION=$3 SHA1=$4 MANIFEST_PATH=$5 -: ${MANIFEST_PATH:?USAGE: ./ci/scripts/update-manifest GITHUB_OWNER RELEASE_NAME VERSION SHA1 MANIFEST_PATH} +: "${MANIFEST_PATH:?USAGE: ./ci/scripts/update-manifest GITHUB_OWNER RELEASE_NAME VERSION SHA1 MANIFEST_PATH}" set -e -u -manifest_len=$(wc -l $MANIFEST_PATH | awk '{print $1}') -manifest_head=$(head -n `expr $manifest_len - 4` $MANIFEST_PATH) -cat > $MANIFEST_PATH < "$MANIFEST_PATH" <