Skip to content

Commit acab708

Browse files
authored
chore: Cache custom golangci-lint binaries in GHA workflow (#4116)
1 parent 19c1a8a commit acab708

9 files changed

Lines changed: 20 additions & 6 deletions

File tree

.custom-gcl.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
version: v2.10.1 # should be in sync with script/setup-custom-gcl.sh
1+
version: v2.10.1 # this is the version of golangci-lint
22
plugins:
33
- module: "github.com/google/go-github/v84/tools/extraneousnew"
4-
path: ./tools/extraneous-new
4+
path: ./tools/extraneousnew
55
- module: "github.com/google/go-github/v84/tools/fmtpercentv"
66
path: ./tools/fmtpercentv
77
- module: "github.com/google/go-github/v84/tools/sliceofpointers"

.github/workflows/linter.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ jobs:
1313
with:
1414
go-version: stable
1515
cache-dependency-path: "**/go.sum"
16+
- uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
17+
with:
18+
path: |
19+
bin/golangci-lint
20+
bin/custom-gcl
21+
key: ${{ runner.os }}-${{ runner.arch }}-tools-${{ hashFiles('.custom-gcl.yml', 'tools/**/go.mod', 'tools/**/go.sum', 'tools/**/*.go') }}
1622
- run: script/lint.sh
1723
env:
1824
CHECK_GITHUB_OPENAPI: 1

script/setup-custom-gcl.sh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,19 @@
44

55
set -e
66

7-
# should be in sync with .custom-gcl.yml
8-
GOLANGCI_LINT_VERSION="v2.10.1"
7+
ROOT_DIR="$(cd -- "$(dirname -- "$0")/.." > /dev/null 2>&1 && pwd -P)"
8+
CUSTOM_GCL_CONFIG="$ROOT_DIR/.custom-gcl.yml"
9+
GOLANGCI_LINT_VERSION="$(
10+
sed -n 's/^[[:space:]]*version:[[:space:]]*//p' "$CUSTOM_GCL_CONFIG" \
11+
| sed '1{s/[[:space:]]*#.*$//;s/^"//;s/"$//;s/[[:space:]]*$//;p;};d'
12+
)"
913

10-
# should in sync with fmt.sh and lint.sh
11-
BIN="$(pwd -P)"/bin
14+
if [ -z "$GOLANGCI_LINT_VERSION" ]; then
15+
echo "Error: could not determine golangci-lint version from $CUSTOM_GCL_CONFIG" >&2
16+
exit 1
17+
fi
18+
19+
BIN="$ROOT_DIR/bin"
1220

1321
mkdir -p "$BIN"
1422

File renamed without changes.

tools/extraneous-new/testdata/src/has-warnings/main.go renamed to tools/extraneousnew/testdata/src/has-warnings/main.go

File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)