Skip to content

Commit a5cfe83

Browse files
committed
chore: cache Go dependencies and sample files
Signed-off-by: egibs <20933572+egibs@users.noreply.github.com>
1 parent 02f42d4 commit a5cfe83

4 files changed

Lines changed: 105 additions & 6 deletions

File tree

.github/workflows/codeql.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
with:
5555
go-version-file: "go.mod"
5656
check-latest: true
57-
cache: false
57+
cache: true
5858
- name: Initialize CodeQL
5959
uses: github/codeql-action/init@45cbd0c69e560cd9e7cd7f8c32362050c9b7ded2 # v4.32.2
6060
with:

.github/workflows/fuzz.yaml

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ jobs:
117117
- name: Install dependencies
118118
run: |
119119
apk update
120-
apk add curl findutils git go nodejs upx xz yara-x~1.12.0
120+
apk add curl findutils git gnutar go nodejs upx xz yara-x~1.12.0
121121
122122
- name: Checkout code
123123
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -127,7 +127,34 @@ jobs:
127127
- name: Trust repository
128128
run: git config --global --add safe.directory "${GITHUB_WORKSPACE}"
129129

130-
- name: Clone malcontent samples (required for compile fuzzers)
130+
- name: Get Go cache paths
131+
id: go-env
132+
run: |
133+
echo "modcache=$(go env GOMODCACHE)" >> "${GITHUB_OUTPUT}"
134+
echo "cache=$(go env GOCACHE)" >> "${GITHUB_OUTPUT}"
135+
136+
- name: Cache Go dependencies
137+
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
138+
with:
139+
path: |
140+
${{ steps.go-env.outputs.modcache }}
141+
${{ steps.go-env.outputs.cache }}
142+
key: go-${{ hashFiles('go.sum') }}
143+
restore-keys: go-
144+
145+
- name: Get samples commit
146+
id: samples
147+
if: contains(matrix.target.package, 'programkind')
148+
run: echo "commit=$(grep '^SAMPLES_COMMIT' Makefile | head -1 | cut -d'=' -f2 | tr -d ' ?')" >> "$GITHUB_OUTPUT"
149+
150+
- name: Cache malcontent samples
151+
if: contains(matrix.target.package, 'programkind')
152+
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
153+
with:
154+
path: out/chainguard-sandbox/malcontent-samples
155+
key: samples-${{ steps.samples.outputs.commit }}
156+
157+
- name: Clone malcontent samples (required for programkind fuzzers)
131158
if: contains(matrix.target.package, 'programkind')
132159
run: |
133160
make samples

.github/workflows/go-tests.yaml

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
- name: Install dependencies
3838
run: |
3939
apk update
40-
apk add curl findutils git go nodejs upx xz yara-x~1.12.0
40+
apk add curl findutils git gnutar go nodejs upx xz yara-x~1.12.0
4141
4242
- name: Checkout code
4343
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -47,6 +47,21 @@ jobs:
4747
- name: Trust repository
4848
run: git config --global --add safe.directory "${GITHUB_WORKSPACE}"
4949

50+
- name: Get Go cache paths
51+
id: go-env
52+
run: |
53+
echo "modcache=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT"
54+
echo "cache=$(go env GOCACHE)" >> "$GITHUB_OUTPUT"
55+
56+
- name: Cache Go dependencies
57+
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
58+
with:
59+
path: |
60+
${{ steps.go-env.outputs.modcache }}
61+
${{ steps.go-env.outputs.cache }}
62+
key: go-${{ hashFiles('go.sum') }}
63+
restore-keys: go-
64+
5065
- name: Unit tests
5166
run: |
5267
make test
@@ -74,7 +89,7 @@ jobs:
7489
- name: Install dependencies
7590
run: |
7691
apk update
77-
apk add curl findutils git go nodejs upx xz yara-x~1.12.0
92+
apk add curl findutils git gnutar go nodejs upx xz yara-x~1.12.0
7893
7994
- name: Checkout code
8095
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -84,6 +99,34 @@ jobs:
8499
- name: Trust repository
85100
run: git config --global --add safe.directory "${GITHUB_WORKSPACE}"
86101

102+
- name: Get Go cache paths
103+
id: go-env
104+
run: |
105+
echo "modcache=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT"
106+
echo "cache=$(go env GOCACHE)" >> "$GITHUB_OUTPUT"
107+
108+
- name: Cache Go dependencies
109+
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
110+
with:
111+
path: |
112+
${{ steps.go-env.outputs.modcache }}
113+
${{ steps.go-env.outputs.cache }}
114+
key: go-${{ hashFiles('go.sum') }}
115+
restore-keys: go-
116+
117+
- name: Get samples commit
118+
id: samples
119+
run: echo "commit=$(grep '^SAMPLES_COMMIT' Makefile | head -1 | cut -d'=' -f2 | tr -d ' ?')" >> "$GITHUB_OUTPUT"
120+
121+
- name: Cache malcontent samples
122+
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
123+
with:
124+
path: out/chainguard-sandbox/malcontent-samples
125+
key: samples-${{ steps.samples.outputs.commit }}
126+
127+
- name: Prepare samples
128+
run: make samples
129+
87130
- name: Integration tests
88131
run: |
89132
make integration

.github/workflows/third-party.yaml

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,39 @@ jobs:
3737
- name: Install dependencies
3838
run: |
3939
apk update
40-
apk add bash curl findutils gh git go nodejs perl upx xz yara-x~1.12.0
40+
apk add bash curl findutils gh git gnutar go nodejs perl upx xz yara-x~1.12.0
4141
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
4242
- name: Trust repository
4343
run: git config --global --add safe.directory "${GITHUB_WORKSPACE}"
44+
45+
- name: Get Go cache paths
46+
id: go-env
47+
run: |
48+
echo "modcache=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT"
49+
echo "cache=$(go env GOCACHE)" >> "$GITHUB_OUTPUT"
50+
51+
- name: Cache Go dependencies
52+
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
53+
with:
54+
path: |
55+
${{ steps.go-env.outputs.modcache }}
56+
${{ steps.go-env.outputs.cache }}
57+
key: go-${{ hashFiles('go.sum') }}
58+
restore-keys: go-
59+
60+
- name: Get samples commit
61+
id: samples
62+
run: echo "commit=$(grep '^SAMPLES_COMMIT' Makefile | head -1 | cut -d'=' -f2 | tr -d ' ?')" >> "$GITHUB_OUTPUT"
63+
64+
- name: Cache malcontent samples
65+
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
66+
with:
67+
path: out/chainguard-sandbox/malcontent-samples
68+
key: samples-${{ steps.samples.outputs.commit }}
69+
70+
- name: Prepare samples
71+
run: make samples
72+
4473
- uses: chainguard-dev/actions/setup-gitsign@6f74cdeee55d70b03fa220746d6739dbbb3e9421
4574
- name: Set up Octo-STS
4675
uses: octo-sts/action@f603d3be9d8dd9871a265776e625a27b00effe05 # v1.1.1

0 commit comments

Comments
 (0)