refactor(ci): standardize YAML formatting and improve Docker caching in workflows

- Convert space-indented lists to dash-indented in cd.yml and ci.yml for consistency - Remove trailing spaces throughout both files - Add buildx cache step in cd.yml and update cache-from/cache-to to use local cache for faster builds

lemon-mint committed Nov 5, 2025 at 08:49 UTC 4db45947ab1ed16c86cdd123b3e801f6798ab977
2 files changed +141 -135
.github/workflows/cd.yml
+42 -36
@@ -2,10 +2,10 @@ name: CD
2
3 on:
4 push:
5 - branches: [ main ]
6 - tags: [ 'v*' ]
5 + branches: [main]
6 + tags: ["v*"]
7 release:
8 - types: [ published ]
8 + types: [published]
9
10 env:
11 REGISTRY: ghcr.io
@@ -18,37 +18,43 @@ jobs:
18 permissions:
19 contents: read
20 packages: write
21 -
21 +
22 steps:
23 - - name: Checkout code
24 - uses: actions/checkout@v5
25 -
26 - - name: Log in to Container Registry
27 - uses: docker/login-action@v3
28 - with:
29 - registry: ${{ env.REGISTRY }}
30 - username: ${{ github.actor }}
31 - password: ${{ secrets.GITHUB_TOKEN }}
32 -
33 - - name: Extract metadata
34 - id: meta
35 - uses: docker/metadata-action@v5
36 - with:
37 - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
38 - tags: |
39 - type=ref,event=branch
40 - type=ref,event=pr
41 - type=semver,pattern={{version}}
42 - type=semver,pattern={{major}}.{{minor}}
43 - type=semver,pattern={{major}}
44 - type=sha,prefix={{branch}}-
45 -
46 - - name: Build and push Docker image
47 - uses: docker/build-push-action@v5
48 - with:
49 - context: .
50 - push: true
51 - tags: ${{ steps.meta.outputs.tags }}
52 - labels: ${{ steps.meta.outputs.labels }}
53 - cache-from: type=gha
54 - cache-to: type=gha,mode=max
\ No newline at end of file
23 + - name: Checkout code
24 + uses: actions/checkout@v5
25 +
26 + - name: Cache buildx
27 + uses: actions/cache@v4
28 + with:
29 + path: /tmp/.buildx-cache
30 + key: ${{ runner.os }}-${{ hashFiles('**/Dockerfile') }}
31 +
32 + - name: Log in to Container Registry
33 + uses: docker/login-action@v3
34 + with:
35 + registry: ${{ env.REGISTRY }}
36 + username: ${{ github.actor }}
37 + password: ${{ secrets.GITHUB_TOKEN }}
38 +
39 + - name: Extract metadata
40 + id: meta
41 + uses: docker/metadata-action@v5
42 + with:
43 + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
44 + tags: |
45 + type=ref,event=branch
46 + type=ref,event=pr
47 + type=semver,pattern={{version}}
48 + type=semver,pattern={{major}}.{{minor}}
49 + type=semver,pattern={{major}}
50 + type=sha,prefix={{branch}}-
51 +
52 + - name: Build and push Docker image
53 + uses: docker/build-push-action@v5
54 + with:
55 + context: .
56 + push: true
57 + tags: ${{ steps.meta.outputs.tags }}
58 + labels: ${{ steps.meta.outputs.labels }}
59 + cache-from: type=local,src=/tmp/.buildx-cache
60 + cache-to: type=local,dest=/tmp/.buildx-cache
.github/workflows/ci.yml
+99 -99
@@ -2,119 +2,119 @@ name: CI
2
3 on:
4 pull_request:
5 - branches: [ main, master ]
5 + branches: [main, master]
6
7 jobs:
8 test:
9 name: Test
10 runs-on: ubuntu-latest
11 -
11 +
12 steps:
13 - - name: Checkout code
14 - uses: actions/checkout@v5
15 -
16 - - name: Set up Go
17 - uses: actions/setup-go@v6
18 - with:
19 - go-version: "stable"
20 - check-latest: true
21 -
22 - - name: Cache Go modules
23 - uses: actions/cache@v3
24 - with:
25 - path: |
26 - ~/.cache/go-build
27 - ~/go/pkg/mod
28 - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
29 - restore-keys: |
30 - ${{ runner.os }}-go-
31 -
32 - - name: Download dependencies
33 - run: go mod download
34 -
35 - - name: Install protobuf compiler
36 - run: |
37 - sudo apt-get update
38 - sudo apt-get install -y protobuf-compiler
39 -
40 - - name: Install protoc-gen-go and protoc-gen-go-vtproto
41 - run: |
42 - go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
43 - go install github.com/planetscale/vtprotobuf/cmd/protoc-gen-go-vtproto@latest
44 -
45 - - name: Generate protobuf files
46 - run: make build-protoc
47 -
48 - - name: Run tests
49 - run: go test -v -race -coverprofile=coverage.out ./...
50 -
51 - - name: Upload coverage to Codecov
52 - uses: codecov/codecov-action@v3
53 - with:
54 - file: ./coverage.out
55 - flags: unittests
56 - name: codecov-umbrella
57 -
13 + - name: Checkout code
14 + uses: actions/checkout@v5
15 +
16 + - name: Set up Go
17 + uses: actions/setup-go@v6
18 + with:
19 + go-version: "stable"
20 + check-latest: true
21 +
22 + - name: Cache Go modules
23 + uses: actions/cache@v3
24 + with:
25 + path: |
26 + ~/.cache/go-build
27 + ~/go/pkg/mod
28 + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
29 + restore-keys: |
30 + ${{ runner.os }}-go-
31 +
32 + - name: Download dependencies
33 + run: go mod download
34 +
35 + - name: Install protobuf compiler
36 + run: |
37 + sudo apt-get update
38 + sudo apt-get install -y protobuf-compiler
39 +
40 + - name: Install protoc-gen-go and protoc-gen-go-vtproto
41 + run: |
42 + go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
43 + go install github.com/planetscale/vtprotobuf/cmd/protoc-gen-go-vtproto@latest
44 +
45 + - name: Generate protobuf files
46 + run: make build-protoc
47 +
48 + - name: Run tests
49 + run: go test -v -race -coverprofile=coverage.out ./...
50 +
51 + - name: Upload coverage to Codecov
52 + uses: codecov/codecov-action@v3
53 + with:
54 + file: ./coverage.out
55 + flags: unittests
56 + name: codecov-umbrella
57 +
58 build:
59 name: Build
60 runs-on: ubuntu-latest
61 needs: test
62 -
62 +
63 steps:
64 - - name: Checkout code
65 - uses: actions/checkout@v5
66 -
67 - - name: Set up Go
68 - uses: actions/setup-go@v6
69 - with:
70 - go-version: "stable"
71 - check-latest: true
72 -
73 - - name: Cache Go modules
74 - uses: actions/cache@v3
75 - with:
76 - path: |
77 - ~/.cache/go-build
78 - ~/go/pkg/mod
79 - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
80 - restore-keys: |
81 - ${{ runner.os }}-go-
82 -
83 - - name: Download dependencies
84 - run: go mod download
85 -
86 - - name: Install build dependencies
87 - run: |
88 - sudo apt-get update
89 - sudo apt-get install -y protobuf-compiler binaryen
90 -
91 - - name: Install protoc-gen-go and protoc-gen-go-vtproto
92 - run: |
93 - go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
94 - go install github.com/planetscale/vtprotobuf/cmd/protoc-gen-go-vtproto@latest
95 -
96 - - name: Build all components
97 - run: make build
98 -
99 - - name: Build Docker image
100 - run: |
101 - docker build -t relaydns:test .
102 -
64 + - name: Checkout code
65 + uses: actions/checkout@v5
66 +
67 + - name: Set up Go
68 + uses: actions/setup-go@v6
69 + with:
70 + go-version: "stable"
71 + check-latest: true
72 +
73 + - name: Cache Go modules
74 + uses: actions/cache@v3
75 + with:
76 + path: |
77 + ~/.cache/go-build
78 + ~/go/pkg/mod
79 + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
80 + restore-keys: |
81 + ${{ runner.os }}-go-
82 +
83 + - name: Download dependencies
84 + run: go mod download
85 +
86 + - name: Install build dependencies
87 + run: |
88 + sudo apt-get update
89 + sudo apt-get install -y protobuf-compiler binaryen
90 +
91 + - name: Install protoc-gen-go and protoc-gen-go-vtproto
92 + run: |
93 + go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
94 + go install github.com/planetscale/vtprotobuf/cmd/protoc-gen-go-vtproto@latest
95 +
96 + - name: Build all components
97 + run: make build
98 +
99 + - name: Build Docker image
100 + run: |
101 + docker build -t relaydns:test .
102 +
103 lint:
104 name: Lint
105 runs-on: ubuntu-latest
106 -
106 +
107 steps:
108 - - name: Checkout code
109 - uses: actions/checkout@v5
110 -
111 - - name: Set up Go
112 - uses: actions/setup-go@v6
113 - with:
114 - go-version: "stable"
115 - check-latest: true
116 -
117 - - name: golangci-lint
108 + - name: Checkout code
109 + uses: actions/checkout@v5
110 +
111 + - name: Set up Go
112 + uses: actions/setup-go@v6
113 + with:
114 + go-version: "stable"
115 + check-latest: true
116 +
117 + - name: golangci-lint
118 uses: golangci/golangci-lint-action@v8
119 with:
120 - version: v2.6.0
\ No newline at end of file
120 + version: v2.6.0