Skip to content

Commit 2f1f269

Browse files
committed
🚀 ci: optimize GitHub workflows with caching and timeouts
- Add timeout-minutes to all jobs - Add Go modules cache in CI workflow - Use go.mod file for Go version detection - Add Helm plugins cache in Helm release workflow - Add registry cache support for Docker builds - Improve coverage upload condition - Add coverage.txt to .gitignore
1 parent 6994ed4 commit 2f1f269

4 files changed

Lines changed: 30 additions & 4 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,25 @@ permissions:
1717
jobs:
1818
test:
1919
runs-on: ubuntu-latest
20+
timeout-minutes: 10
2021
steps:
2122
- name: Checkout
2223
uses: actions/checkout@v4
2324

25+
- name: Cache Go modules
26+
uses: actions/cache@v4
27+
with:
28+
path: |
29+
~/.cache/go-build
30+
~/go/pkg/mod
31+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
32+
restore-keys: |
33+
${{ runner.os }}-go-
34+
2435
- name: Set up Go
2536
uses: actions/setup-go@v5
2637
with:
27-
go-version: "1.25"
28-
cache: true
38+
go-version-file: 'go.mod'
2939

3040
- name: Run go vet
3141
run: go vet ./...
@@ -34,6 +44,7 @@ jobs:
3444
run: go test -race -coverprofile=coverage.txt -covermode=atomic ./...
3545

3646
- name: Upload coverage to Codecov
47+
if: success() || failure()
3748
uses: codecov/codecov-action@v4
3849
with:
3950
file: ./coverage.txt
@@ -42,6 +53,7 @@ jobs:
4253

4354
helm-lint:
4455
runs-on: ubuntu-latest
56+
timeout-minutes: 5
4557
steps:
4658
- name: Checkout
4759
uses: actions/checkout@v4

.github/workflows/docker-release.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ jobs:
4545
push: true
4646
tags: ${{ steps.meta.outputs.tags }}
4747
labels: ${{ steps.meta.outputs.labels }}
48-
cache-from: type=gha
49-
cache-to: type=gha,mode=max
48+
cache-from: |
49+
type=gha
50+
type=registry,ref=ghcr.io/crazygit/cert-manager-alidns-webhook:buildcache
51+
cache-to: |
52+
type=gha,mode=max
53+
type=registry,ref=ghcr.io/crazygit/cert-manager-alidns-webhook:buildcache,mode=max
5054
provenance: true
5155
sbom: true

.github/workflows/helm-release.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,19 @@ permissions:
1212
jobs:
1313
package-and-push:
1414
runs-on: ubuntu-latest
15+
timeout-minutes: 5
1516
steps:
1617
- name: Checkout
1718
uses: actions/checkout@v4
1819

20+
- name: Cache Helm plugins
21+
uses: actions/cache@v4
22+
with:
23+
path: ~/.local/share/helm/plugins
24+
key: ${{ runner.os }}-helm-plugins-${{ hashFiles('**/Chart.yaml') }}
25+
restore-keys: |
26+
${{ runner.os }}-helm-plugins-
27+
1928
- name: Set up Helm
2029
uses: azure/setup-helm@v4
2130
with:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ cert-manager-webhook-example
1818
_out
1919
_test
2020
*.tgz
21+
coverage.txt

0 commit comments

Comments
 (0)