1515 pull_request :
1616 branches : [main]
1717
18+ env :
19+ GO_VERSION : " 1.25.5"
20+
1821jobs :
1922 lint :
2023 runs-on : ubuntu-latest
@@ -23,10 +26,15 @@ jobs:
2326 uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
2427
2528 - name : Set up Go
29+ id : setup-go
2630 uses : actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
2731 with :
28- go-version : " 1.25.5 "
32+ go-version : ${{ env.GO_VERSION }}
2933 cache : true
34+ cache-dependency-path : go.sum
35+
36+ - name : Go cache status
37+ run : echo "cache-hit=${{ steps.setup-go.outputs.cache-hit }}"
3038
3139 - name : Lint
3240 uses : golangci/golangci-lint-action@e7fa5ac41e1cf5b7d48e45e42232ce7ada589601 # v9.1.0
@@ -40,10 +48,15 @@ jobs:
4048 uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
4149
4250 - name : Set up Go
51+ id : setup-go
4352 uses : actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
4453 with :
45- go-version : " 1.25.5 "
54+ go-version : ${{ env.GO_VERSION }}
4655 cache : true
56+ cache-dependency-path : go.sum
57+
58+ - name : Go cache status
59+ run : echo "cache-hit=${{ steps.setup-go.outputs.cache-hit }}"
4760
4861 - name : Install Task
4962 uses : go-task/setup-task@0ab1b2a65bc55236a3bc64cde78f80e20e8885c2 # v1.0.0
@@ -60,10 +73,15 @@ jobs:
6073 uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
6174
6275 - name : Set up Go
76+ id : setup-go
6377 uses : actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
6478 with :
65- go-version : " 1.25.5 "
79+ go-version : ${{ env.GO_VERSION }}
6680 cache : true
81+ cache-dependency-path : go.sum
82+
83+ - name : Go cache status
84+ run : echo "cache-hit=${{ steps.setup-go.outputs.cache-hit }}"
6785
6886 - name : Install go-licences
6987 run : go install github.com/google/go-licenses@latest
@@ -79,10 +97,15 @@ jobs:
7997 uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
8098
8199 - name : Set up Go
100+ id : setup-go
82101 uses : actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
83102 with :
84- go-version : " 1.25.5 "
103+ go-version : ${{ env.GO_VERSION }}
85104 cache : true
105+ cache-dependency-path : go.sum
106+
107+ - name : Go cache status
108+ run : echo "cache-hit=${{ steps.setup-go.outputs.cache-hit }}"
86109
87110 - name : Install Task
88111 uses : go-task/setup-task@0ab1b2a65bc55236a3bc64cde78f80e20e8885c2 # v1.0.0
@@ -110,6 +133,7 @@ jobs:
110133 password : ${{ secrets.DOCKERPUBLICBOT_WRITE_PAT }}
111134
112135 - name : Set up Docker Buildx
136+ id : buildx
113137 uses : docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
114138
115139 - name : Docker metadata
@@ -122,6 +146,26 @@ jobs:
122146 type=edge
123147 type=ref,event=pr
124148
149+ - name : Cache Go build mounts
150+ id : cache
151+ uses : actions/cache@v4
152+ with :
153+ path : .buildkit-cache
154+ key : buildkit-${{ runner.os }}-${{ hashFiles('Dockerfile', 'go.sum') }}
155+ restore-keys : |
156+ buildkit-${{ runner.os }}-
157+
158+ - name : Inject Go caches into builder
159+ uses : reproducible-containers/buildkit-cache-dance@v3
160+ with :
161+ builder : ${{ steps.buildx.outputs.name }}
162+ cache-map : |
163+ {
164+ ".buildkit-cache/go-mod": "/go/pkg/mod",
165+ ".buildkit-cache/go-build": "/root/.cache/go-build"
166+ }
167+ skip-extraction : ${{ steps.cache.outputs.cache-hit }}
168+
125169 - name : Build and push image
126170 uses : docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
127171 with :
@@ -135,3 +179,5 @@ jobs:
135179 build-args : |
136180 GIT_TAG=${{ github.ref_name }}
137181 GIT_COMMIT=${{ github.sha }}
182+ cache-from : type=gha,scope=cagent-image
183+ cache-to : type=gha,mode=max,scope=cagent-image
0 commit comments