From d8c4365480bcdbf0eb82e85404c821a56dc1fd6c Mon Sep 17 00:00:00 2001 From: Juan Calderon-Perez <835733+gaby@users.noreply.github.com> Date: Fri, 17 Nov 2023 08:22:30 -0500 Subject: [PATCH] Cleanup --- .github/workflows/golangci-lint.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index c3978575..375d7326 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -35,11 +35,19 @@ jobs: BASE_SHA="${{ github.event.pull_request.base.sha || github.event.before }}" HEAD_SHA="${{ github.event.pull_request.head.sha || github.event.after }}" - # Extract changed directories that contain a go.mod file - GO_MOD_DIRECTORIES=$(git diff --name-only $BASE_SHA $HEAD_SHA | grep '/go.mod$' | xargs -L1 dirname | sort -u) + # Extract directories from changed files, only include those with go.mod files + GO_MOD_DIRECTORIES=() + FILES=$(git diff --name-only $BASE_SHA $HEAD_SHA | grep -vE '/\.') + DIRECTORIES=$(echo "$FILES" | xargs -L1 dirname | sort -u) - # Convert to JSON and export - JSON_ARRAY=$(echo "$GO_MOD_DIRECTORIES" | jq -R -s -c 'split("\n")[:-1]') + for dir in $DIRECTORIES; do + if [[ -f "$dir/go.mod" ]]; then + GO_MOD_DIRECTORIES+=("$dir") + fi + done + + # Export the JSON array + JSON_ARRAY=$(printf '%s\n' "${GO_MOD_DIRECTORIES[@]}" | jq -R -s -c 'split("\n")[:-1]') echo "matrix=${JSON_ARRAY}" >> $GITHUB_OUTPUT lint: