diff --git a/.custom-gcl.yml b/.custom-gcl.yml index bfbf6ad0f5b..4c2c4aae714 100644 --- a/.custom-gcl.yml +++ b/.custom-gcl.yml @@ -1,7 +1,7 @@ -version: v2.10.1 # should be in sync with script/setup-custom-gcl.sh +version: v2.10.1 # this is the version of golangci-lint plugins: - module: "github.com/google/go-github/v84/tools/extraneousnew" - path: ./tools/extraneous-new + path: ./tools/extraneousnew - module: "github.com/google/go-github/v84/tools/fmtpercentv" path: ./tools/fmtpercentv - module: "github.com/google/go-github/v84/tools/sliceofpointers" diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 3a492f63400..2a69022a367 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -13,6 +13,12 @@ jobs: with: go-version: stable cache-dependency-path: "**/go.sum" + - uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 + with: + path: | + bin/golangci-lint + bin/custom-gcl + key: ${{ runner.os }}-${{ runner.arch }}-tools-${{ hashFiles('.custom-gcl.yml', 'tools/**/go.mod', 'tools/**/go.sum', 'tools/**/*.go') }} - run: script/lint.sh env: CHECK_GITHUB_OPENAPI: 1 diff --git a/script/setup-custom-gcl.sh b/script/setup-custom-gcl.sh index 0dd896cfd33..36936e62a3b 100755 --- a/script/setup-custom-gcl.sh +++ b/script/setup-custom-gcl.sh @@ -4,11 +4,19 @@ set -e -# should be in sync with .custom-gcl.yml -GOLANGCI_LINT_VERSION="v2.10.1" +ROOT_DIR="$(cd -- "$(dirname -- "$0")/.." > /dev/null 2>&1 && pwd -P)" +CUSTOM_GCL_CONFIG="$ROOT_DIR/.custom-gcl.yml" +GOLANGCI_LINT_VERSION="$( + sed -n 's/^[[:space:]]*version:[[:space:]]*//p' "$CUSTOM_GCL_CONFIG" \ + | sed '1{s/[[:space:]]*#.*$//;s/^"//;s/"$//;s/[[:space:]]*$//;p;};d' +)" -# should in sync with fmt.sh and lint.sh -BIN="$(pwd -P)"/bin +if [ -z "$GOLANGCI_LINT_VERSION" ]; then + echo "Error: could not determine golangci-lint version from $CUSTOM_GCL_CONFIG" >&2 + exit 1 +fi + +BIN="$ROOT_DIR/bin" mkdir -p "$BIN" diff --git a/tools/extraneous-new/extraneous_new.go b/tools/extraneousnew/extraneousnew.go similarity index 100% rename from tools/extraneous-new/extraneous_new.go rename to tools/extraneousnew/extraneousnew.go diff --git a/tools/extraneous-new/extraneous_new_test.go b/tools/extraneousnew/extraneousnew_test.go similarity index 100% rename from tools/extraneous-new/extraneous_new_test.go rename to tools/extraneousnew/extraneousnew_test.go diff --git a/tools/extraneous-new/go.mod b/tools/extraneousnew/go.mod similarity index 100% rename from tools/extraneous-new/go.mod rename to tools/extraneousnew/go.mod diff --git a/tools/extraneous-new/go.sum b/tools/extraneousnew/go.sum similarity index 100% rename from tools/extraneous-new/go.sum rename to tools/extraneousnew/go.sum diff --git a/tools/extraneous-new/testdata/src/has-warnings/main.go b/tools/extraneousnew/testdata/src/has-warnings/main.go similarity index 100% rename from tools/extraneous-new/testdata/src/has-warnings/main.go rename to tools/extraneousnew/testdata/src/has-warnings/main.go diff --git a/tools/extraneous-new/testdata/src/no-warnings/main.go b/tools/extraneousnew/testdata/src/no-warnings/main.go similarity index 100% rename from tools/extraneous-new/testdata/src/no-warnings/main.go rename to tools/extraneousnew/testdata/src/no-warnings/main.go