Skip to content

Commit d38fd09

Browse files
authored
ci: compile go tools once (#1128)
1 parent 4764b42 commit d38fd09

File tree

1 file changed

+41
-12
lines changed

1 file changed

+41
-12
lines changed

.github/workflows/ci.yaml

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,67 @@ on:
66
- master
77
pull_request:
88
jobs:
9+
build-tools:
10+
runs-on: ubuntu-latest
11+
name: Build Go Tools
12+
steps:
13+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
14+
with:
15+
persist-credentials: false
16+
- uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
17+
with:
18+
go-version-file: scripts/go.mod
19+
cache-dependency-path: scripts/go.sum
20+
- name: Build Go tools
21+
run: |
22+
mkdir -p tmp/bin
23+
cd scripts && go list -e -mod=mod -tags tools -f '{{ range .Imports }}{{ printf "%s\n" .}}{{end}}' ./ | xargs -tI % go build -mod=mod -o ../tmp/bin %
24+
- name: Upload built tools
25+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
26+
with:
27+
name: go-tools
28+
path: tmp/bin/
29+
retention-days: 1
30+
if-no-files-found: error
31+
932
matrix:
1033
runs-on: ubuntu-latest
1134
name: ${{ matrix.name }}
35+
needs: build-tools
1236
strategy:
1337
fail-fast: false
1438
matrix:
1539
include:
1640
- name: Lint Alerts
17-
run: make --always-make alerts-lint
41+
run: make alerts-lint
1842
- name: Generate YAML
19-
run: make --always-make generate && git diff --exit-code
43+
run: make generate && git diff --exit-code
2044
- name: Lint Grafana Dashboards
21-
run: make --always-make dashboards-lint
45+
run: make dashboards-lint
2246
- name: Format JSONNET
23-
run: make --always-make jsonnet-fmt && git diff --exit-code
47+
run: make jsonnet-fmt && git diff --exit-code
2448
- name: Lint JSONNET
25-
run: make --always-make jsonnet-lint
49+
run: make jsonnet-lint
2650
- name: Format MD
27-
run: make --always-make markdownfmt && git diff --exit-code
51+
run: make markdownfmt && git diff --exit-code
2852
- name: Lint MD
29-
run: make --always-make vale && git diff --exit-code
53+
run: make vale && git diff --exit-code
3054
- name: Lint YAML
31-
run: make --always-make pint-lint
55+
run: make pint-lint
3256
- name: Run unit tests
33-
run: make --always-make test
57+
run: make test
3458

3559
steps:
3660
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
3761
with:
3862
persist-credentials: false
39-
- uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
63+
- name: Download built tools
64+
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
4065
with:
41-
go-version-file: scripts/go.mod
42-
cache-dependency-path: scripts/go.sum
66+
name: go-tools
67+
path: tmp/bin/
68+
- name: Make tools executable and update timestamps
69+
run: |
70+
chmod +x tmp/bin/*
71+
touch tmp/bin/*
4372
- run: ${{ matrix.run }}

0 commit comments

Comments
 (0)