From b974679974f08fffe3684602f4b5d739a60d6c54 Mon Sep 17 00:00:00 2001 From: NiniOak Date: Mon, 18 Sep 2023 12:30:18 -0700 Subject: [PATCH] Update base ref property name --- .../scripts/filter_changed_files_go_test.sh | 42 +++++++++---------- .github/workflows/go-tests.yml | 1 + .github/workflows/test-integrations.yml | 1 + 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/.github/scripts/filter_changed_files_go_test.sh b/.github/scripts/filter_changed_files_go_test.sh index 1366cc2eeb266..4c748ee692920 100755 --- a/.github/scripts/filter_changed_files_go_test.sh +++ b/.github/scripts/filter_changed_files_go_test.sh @@ -2,9 +2,10 @@ # Copyright (c) HashiCorp, Inc. # SPDX-License-Identifier: BUSL-1.1 +set -euo pipefail # Get the list of changed files -files_to_check=$(git diff --name-only origin/$GITHUB_BASE_REF) +files_to_check=$(git diff --name-only "$(git merge-base origin/$BRANCH HEAD~)"...HEAD $*) # Define the directories to check skipped_directories=("docs/" "ui/" "website/" "grafana/") @@ -13,25 +14,24 @@ skipped_directories=("docs/" "ui/" "website/" "grafana/") other_directories="" trigger_ci=true -# # Loop through the changed files and find directories/files outside the skipped ones -# for file_to_check in $files_to_check; do -# file_is_skipped=false -# for dir in "${skipped_directories[@]}"; do -# if [[ "$file_to_check" == "$dir"* ]] || [[ "$file_to_check" == *.md && "$dir" == *"/" ]]; then -# file_is_skipped=true -# break -# fi -# done -# if [ "$file_is_skipped" = "false" ]; then -# other_directories+="$(dirname "$file_to_check")\n" -# trigger_ci=true -# echo "Non doc file(s) changed - triggered ci: $trigger_ci" -# echo -e $other_directories -# echo "trigger-ci=$trigger_ci" >>"$GITHUB_OUTPUT" -# exit 0 ## if file is outside of the skipped_directory exit script -# fi -# done +# Loop through the changed files and find directories/files outside the skipped ones +for file_to_check in $files_to_check; do + file_is_skipped=false + for dir in "${skipped_directories[@]}"; do + if [[ "$file_to_check" == "$dir"* ]] || [[ "$file_to_check" == *.md && "$dir" == *"/" ]]; then + file_is_skipped=true + break + fi + done + if [ "$file_is_skipped" = "true" ]; then + trigger_ci=false + echo -e "$file_to_check" + echo "Only doc file(s) changed - triggered ci: $trigger_ci" + echo "trigger-ci=$trigger_ci" >>"$GITHUB_OUTPUT" + exit 0 ## if file is in list of the skipped_directory, exit script + fi +done -# echo "Only doc file(s) changed - triggered ci: $trigger_ci" -echo "Doc file(s) change detection is currently disabled - triggering ci" +echo -e "$files_to_check" +echo "Non doc file(s) changed - triggered ci: $trigger_ci" echo "trigger-ci=$trigger_ci" >>"$GITHUB_OUTPUT" diff --git a/.github/workflows/go-tests.yml b/.github/workflows/go-tests.yml index 6782a3e4d7524..0030e60dc0086 100644 --- a/.github/workflows/go-tests.yml +++ b/.github/workflows/go-tests.yml @@ -22,6 +22,7 @@ permissions: env: TEST_RESULTS: /tmp/test-results GOPRIVATE: github.com/hashicorp # Required for enterprise deps + BRANCH: ${{ github.head_ref || github.ref_name }} # concurrency concurrency: diff --git a/.github/workflows/test-integrations.yml b/.github/workflows/test-integrations.yml index 70315390e3b02..5219d059627e8 100644 --- a/.github/workflows/test-integrations.yml +++ b/.github/workflows/test-integrations.yml @@ -24,6 +24,7 @@ env: # strip the hashicorp/ off the front of github.repository for consul CONSUL_LATEST_IMAGE_NAME: ${{ endsWith(github.repository, '-enterprise') && github.repository || 'hashicorp/consul' }} GOPRIVATE: github.com/hashicorp # Required for enterprise deps + BRANCH: ${{ github.head_ref || github.ref_name }} concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}