Skip to content

Commit

Permalink
chore(CI): directory specific test change pruning
Browse files Browse the repository at this point in the history
  • Loading branch information
apeabody committed Oct 14, 2024
1 parent 0a8dfce commit 02d581f
Show file tree
Hide file tree
Showing 12 changed files with 14 additions and 6 deletions.
Empty file removed .github/.keep
Empty file.
18 changes: 13 additions & 5 deletions build/int.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,34 @@ steps:
git fetch --unshallow
git diff origin/${_BASE_BRANCH} --name-only > _changed_files
sed 's/\/.*/\//' _changed_files > _changed_folders
sed 's:[^/]*$::' _changed_files > _changed_folders
sort -u -o _changed_folders{,}
echo Folders with changes:
cat _changed_folders
# Do not prune if changing tests themselves
_INFRA_FOLDERS="build test .github"
_INFRA_FOLDERS="build test/ .github/" # TODO: fix build/, remove github?
for d in _changed_folders; do
if [[ "${_INFRA_FOLDERS}" =~ "$d" ]]; then
echo "Infrastructure folders have changed; no tests will be pruned."
exit 0 # do not prune
fi
done
for d in */; do
if ! grep -q "^$d" _changed_folders && [[ "$d" != "test/" ]]; then
# Remove leaf folders without changes
# TODO: Handle intermeidate folders that also contain .tf
for d in `find . -type d -name 'test' -prune -o -links 2 -printf '%P\n'`; do
if ! grep -q "^$d" _changed_folders; then
rm -rf $d;
fi
done
# Remove any empty folders
find . -empty -type d -delete
# Report remaining folders
echo Folders in scope for tests:
for d in */; do echo $d; done
find . -type d -printf '%P\n'
- id: prepare
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
Expand Down
Empty file removed composer/.keep
Empty file.
Empty file removed compute/.keep
Empty file.
Empty file removed dns/.keep
Empty file.
Empty file removed eventarc/.keep
Empty file.
Empty file removed functions/.keep
Empty file.
2 changes: 1 addition & 1 deletion gke/standard/regional/labels/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# [START gke_standard_regional_labels_cluster]
resource "google_container_cluster" "default" {
name = "gke-standard-regional-labels"
location = "us-west1"
location = "us-central1"
initial_node_count = 2

resource_labels = {
Expand Down
Empty file removed lb/.keep
Empty file.
Empty file removed run/.keep
Empty file.
Empty file removed storage/.keep
Empty file.
Empty file removed vpc/.keep
Empty file.

0 comments on commit 02d581f

Please sign in to comment.