diff --git a/ci/.ci-ignore b/ci/.ci-ignore new file mode 100644 index 00000000..c586ea6b --- /dev/null +++ b/ci/.ci-ignore @@ -0,0 +1,7 @@ +README.md +CONTRIBUTING.md +LICENSE.md +ci/README.md +ci/release_notes_template.md +ci/release_notes.md +docs diff --git a/ci/pipeline.yml b/ci/pipeline.yml index 2c3288c5..dfe83540 100644 --- a/ci/pipeline.yml +++ b/ci/pipeline.yml @@ -190,6 +190,7 @@ jobs: path: git-pull-requests status: pending context: acceptance-tests + get_params: {list_changed_files: true} - task: acceptance-tests privileged: true config: diff --git a/ci/scripts/acceptance-tests b/ci/scripts/acceptance-tests index fe9a1184..fabb86f9 100755 --- a/ci/scripts/acceptance-tests +++ b/ci/scripts/acceptance-tests @@ -2,9 +2,9 @@ set -e -stemcell_jammy_path=$PWD/stemcell/*.tgz -stemcell_bionic_path=$PWD/stemcell-bionic/*.tgz -bpm_release_path=$PWD/bpm/*.tgz +stemcell_jammy_path="$PWD/stemcell/*.tgz" +stemcell_bionic_path="$PWD/stemcell-bionic/*.tgz" +bpm_release_path="$PWD/bpm/*.tgz" if [ -n "$FOCUS" ]; then echo "------------------------------------------------------------------" @@ -14,10 +14,17 @@ if [ -n "$FOCUS" ]; then ADDITIONAL_ARGS=("--focus" "$FOCUS") fi -cd ${REPO_ROOT:?required} +cd "${REPO_ROOT:?required}" echo "----- Pulling in any git submodules..." git submodule update --init --recursive --force +# shellcheck disable=SC1091 +source "ci/scripts/skip-ci.sh" +if skip_ci "ci/.ci-ignore" ".git/resource/changed_files"; then + echo "SKIP TEST: Only .ci-ignored changes found." + exit 0 +fi + echo "----- Starting BOSH" ./ci/scripts/start-bosh.sh @@ -31,6 +38,7 @@ if [ -z "$FOCUS" ]; then trap stop_docker EXIT fi +# shellcheck disable=SC1091 source /tmp/local-bosh/director/env echo "----- Creating candidate BOSH release..." @@ -43,18 +51,19 @@ export RELEASE_VERSION="${release_final_version}.latest" echo "----- Created ${RELEASE_VERSION}" echo "----- Uploading Jammy stemcell" -bosh -n upload-stemcell $stemcell_jammy_path +bosh -n upload-stemcell "$stemcell_jammy_path" echo "----- Uploading Bionic stemcell" -bosh -n upload-stemcell $stemcell_bionic_path +bosh -n upload-stemcell "$stemcell_bionic_path" echo "----- Uploading BPM" -bosh -n upload-release $bpm_release_path +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" diff --git a/ci/scripts/skip-ci.sh b/ci/scripts/skip-ci.sh new file mode 100755 index 00000000..0ba00057 --- /dev/null +++ b/ci/scripts/skip-ci.sh @@ -0,0 +1,27 @@ +#!/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 +}