From ad574ef276fe9e669cf34473d2779308c5f067e8 Mon Sep 17 00:00:00 2001 From: Tyler <48813565+technicallyty@users.noreply.github.com> Date: Thu, 20 Mar 2025 14:32:05 -0700 Subject: [PATCH] fix(scripts): lint scripts display different output in local vs CI (#24087) --- .github/workflows/lint.yml | 4 ++-- Makefile | 12 +++++++----- scripts/go-lint-all.bash | 4 ++-- scripts/go-lint-changes.bash | 4 ++-- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 02778d2a9d..6742300d44 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -31,7 +31,7 @@ jobs: if: env.GIT_DIFF id: lint_long run: | - make lint-changes + make lint - uses: technote-space/get-diff-action@v6.1.2 if: steps.lint_long.outcome == 'skipped' with: @@ -41,7 +41,7 @@ jobs: - name: run linting (short) if: steps.lint_long.outcome == 'skipped' && env.GIT_DIFF run: | - make lint-changes + make lint env: GIT_DIFF: ${{ env.GIT_DIFF }} LINT_DIFF: 1 diff --git a/Makefile b/Makefile index 9660988fc9..78f453b0e6 100644 --- a/Makefile +++ b/Makefile @@ -387,14 +387,16 @@ lint-install: @go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version) lint: - @echo "--> Running linter" + @echo "--> Running linter on diffed files only." + $(MAKE) lint-install + @./scripts/go-lint-changes.bash --timeout=15m + + +lint-all: + @echo "--> Running linter on all files" $(MAKE) lint-install @./scripts/go-lint-all.bash --timeout=15m -lint-changes: - @echo "--> Running linter" - $(MAKE) lint-install - @./scripts/go-lint-changes.bash --timeout=15m lint-fix: @echo "--> Running linter" diff --git a/scripts/go-lint-all.bash b/scripts/go-lint-all.bash index a94b513659..fcac08335d 100755 --- a/scripts/go-lint-all.bash +++ b/scripts/go-lint-all.bash @@ -13,7 +13,7 @@ lint_module() { shift cd "$(dirname "$root")" && echo "linting $(grep "^module" go.mod) [$(date -Iseconds -u)]" && - golangci-lint run ./... -c "${REPO_ROOT}/.golangci.yml" "$@" --new-from-rev=HEAD~ --build-tags=${LINT_TAGS} + golangci-lint run ./... -c "${REPO_ROOT}/.golangci.yml" "$@" --build-tags=${LINT_TAGS} } export -f lint_module @@ -34,7 +34,7 @@ else for f in $(dirname $(echo "$GIT_DIFF" | tr -d "'") | uniq); do echo "linting $f [$(date -Iseconds -u)]" && cd $f && - golangci-lint run ./... -c "${REPO_ROOT}/.golangci.yml" "$@" --new-from-rev=HEAD~ --build-tags=${LINT_TAGS} && + golangci-lint run ./... -c "${REPO_ROOT}/.golangci.yml" "$@" --build-tags=${LINT_TAGS} && cd $REPO_ROOT done fi \ No newline at end of file diff --git a/scripts/go-lint-changes.bash b/scripts/go-lint-changes.bash index ce60b0bd6f..aed46db85c 100755 --- a/scripts/go-lint-changes.bash +++ b/scripts/go-lint-changes.bash @@ -14,7 +14,7 @@ lint_module() { shift cd "$(dirname "$root")" && echo "linting $(grep "^module" go.mod) [$(date -Iseconds -u)]" && - golangci-lint run ./... -c "${REPO_ROOT}/.golangci.yml" "$@" --new-from-rev=HEAD~ --build-tags=${LINT_TAGS} + golangci-lint run ./... -c "${REPO_ROOT}/.golangci.yml" "$@" --new-from-rev=release/v0.53.x --build-tags=${LINT_TAGS} } export -f lint_module @@ -35,7 +35,7 @@ else for f in $(dirname $(echo "$GIT_DIFF" | tr -d "'") | uniq); do echo "linting $f [$(date -Iseconds -u)]" && cd $f && - golangci-lint run ./... -c "${REPO_ROOT}/.golangci.yml" "$@" --new-from-rev=HEAD~ --build-tags=${LINT_TAGS} && + golangci-lint run ./... -c "${REPO_ROOT}/.golangci.yml" "$@" --new-from-rev=release/v0.53.x --build-tags=${LINT_TAGS} && cd $REPO_ROOT done fi \ No newline at end of file