From f774dd57ba04ba82f6fce92d73a6b8f489cab7e8 Mon Sep 17 00:00:00 2001 From: Andrew Peabody Date: Fri, 17 May 2024 20:43:59 +0000 Subject: [PATCH] chore(CI): directory specific test change pruning --- .github/.keep | 0 build/int.cloudbuild.yaml | 18 +++++++++++++----- composer/.keep | 0 compute/.keep | 0 dns/.keep | 0 eventarc/.keep | 0 functions/.keep | 0 gke/standard/regional/labels/main.tf | 2 +- lb/.keep | 0 run/.keep | 0 storage/.keep | 0 vpc/.keep | 0 12 files changed, 14 insertions(+), 6 deletions(-) delete mode 100644 .github/.keep delete mode 100644 composer/.keep delete mode 100644 compute/.keep delete mode 100644 dns/.keep delete mode 100644 eventarc/.keep delete mode 100644 functions/.keep delete mode 100644 lb/.keep delete mode 100644 run/.keep delete mode 100644 storage/.keep delete mode 100644 vpc/.keep diff --git a/.github/.keep b/.github/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/build/int.cloudbuild.yaml b/build/int.cloudbuild.yaml index 65ba83fa..946261e4 100644 --- a/build/int.cloudbuild.yaml +++ b/build/int.cloudbuild.yaml @@ -29,10 +29,13 @@ 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." @@ -40,15 +43,20 @@ steps: 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' diff --git a/composer/.keep b/composer/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/compute/.keep b/compute/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/dns/.keep b/dns/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/eventarc/.keep b/eventarc/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/functions/.keep b/functions/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/gke/standard/regional/labels/main.tf b/gke/standard/regional/labels/main.tf index 9d0b15e8..1edd931a 100644 --- a/gke/standard/regional/labels/main.tf +++ b/gke/standard/regional/labels/main.tf @@ -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 = { diff --git a/lb/.keep b/lb/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/run/.keep b/run/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/storage/.keep b/storage/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/vpc/.keep b/vpc/.keep deleted file mode 100644 index e69de29b..00000000