Skip to content

Commit

Permalink
Merge pull request #12791 from markylaing/golangci-whole-files
Browse files Browse the repository at this point in the history
Golangci whole files
  • Loading branch information
tomponline authored Jan 30, 2024
2 parents 699e59c + cfd8375 commit 6a6d7e2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions test/lint/golangci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@ elif [ -n "${1:-}" ]; then
target_branch="${1}"
fi

# If we don't already have a target revision. Try to get one from the branch.
if [ -z "${target_revision}" ]; then
target_revision="$(git log --max-count=1 --format=%H "origin/${target_branch}" || true)"
# If we don't already have a target revision. Try to get one from the branch.
if [ -n "${GITHUB_ACTIONS:-}" ]; then
# If we're in CI, just attempt and continue, we may be in a shallow clone.
target_revision="$(git log --max-count=1 --format=%H "origin/${target_branch}" || true)"
else
# If we're local, fail if we don't find a revision (and don't prefix with "origin").
target_revision="$(git log --max-count=1 --format=%H "${target_branch}")"
fi
fi

# If we still don't have a target revision, we need to fetch the branch as actions/checkout performs a shallow clone by default.
Expand All @@ -33,4 +39,4 @@ elif ! git log --max-count=1 --format=%H "${target_revision}" >/dev/null 2>&1; t
fi

echo "Checking for golangci-lint errors between HEAD and ${target_branch} (${target_revision})..."
golangci-lint run --timeout 5m --new --new-from-rev "${target_revision}"
golangci-lint run --timeout 5m --new --new-from-rev "${target_revision}" --whole-files

0 comments on commit 6a6d7e2

Please sign in to comment.