test/lint: Run full golangci-lint instead of only new changes

Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
This commit is contained in:
Stéphane Graber 2026-05-26 20:57:56 +00:00
parent 814456248f
commit b6d7760c98
No known key found for this signature in database
GPG Key ID: C638974D64792D67

View File

@ -1,39 +1,4 @@
#!/bin/sh -eu
target_branch=""
if [ -n "${GITHUB_BASE_REF:-}" ]; then
# Attempt to fetch the reference (Github uses a shallow clone).
git fetch -q origin "${GITHUB_BASE_REF}" || true
# Target branch when scanning a Github pull request
target_branch="origin/${GITHUB_BASE_REF}"
elif [ -n "${GITHUB_BEFORE:-}" ]; then
# Target branch when scanning a Github merge
target_branch="${GITHUB_BEFORE}"
# Attempt to fetch the reference (Github uses a shallow clone).
git fetch -q origin "${GITHUB_BEFORE}" || true
elif [ -n "${1:-}" ]; then
# Allow a target branch parameter.
target_branch="${1}"
else
# Default target branch.
for branch in main origin lxc/main; do
if git show-ref --quiet "refs/heads/${branch}" > /dev/null 2>&1; then
target_branch="${branch}"
break
fi
done
fi
# Check if we found a target branch.
if [ -z "${target_branch}" ]; then
echo "The target branch for golangci couldn't be found, skipping."
return
fi
# Gets the most recent commit hash from the target branch.
rev="$(git log "${target_branch}" --oneline --no-abbrev-commit -n1 | cut -d' ' -f1)"
echo "Checking for golangci-lint errors between HEAD and ${target_branch}..."
golangci-lint run --timeout 5m --new --new-from-rev "${rev}"
echo "Checking for golangci-lint errors..."
golangci-lint run --timeout 5m