Skip to content

Commit

Permalink
ci: Skip acceptance tests for files in .ci-ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
domdom82 committed Mar 21, 2024
1 parent 927c70e commit 5128c4e
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 7 deletions.
7 changes: 7 additions & 0 deletions 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
1 change: 1 addition & 0 deletions ci/pipeline.yml
Expand Up @@ -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:
Expand Down
23 changes: 16 additions & 7 deletions ci/scripts/acceptance-tests
Expand Up @@ -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 "------------------------------------------------------------------"
Expand All @@ -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
Expand All @@ -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..."
Expand All @@ -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"

Expand Down
27 changes: 27 additions & 0 deletions 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
}

0 comments on commit 5128c4e

Please sign in to comment.