Skip to content

Commit 13b38de

Browse files
committed
feat(ci): add lint, tidy, and formatting CI jobs
Replace custom Go tools with external formatters: - yamlfmt (google/yamlfmt) instead of custom yamllint - goimports instead of gofmt for import grouping - Remove coverage tool and all CI coverage enforcement - Add license header checking to lint pipeline
1 parent 47a7b40 commit 13b38de

37 files changed

Lines changed: 526 additions & 447 deletions

File tree

.github/actions/run-bazel-test/action.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ name: Run Bazel Test
22
description: Run a Bazel test target
33

44
inputs:
5-
target:
6-
description: Bazel test target pattern
7-
required: true
5+
target:
6+
description: Bazel test target pattern
7+
required: true
88

99
runs:
10-
using: composite
11-
steps:
12-
- name: Run Bazel test
13-
shell: bash
14-
run: ./tool/bazel test ${{ inputs.target }} --test_output=streamed
10+
using: composite
11+
steps:
12+
- name: Run Bazel test
13+
shell: bash
14+
run: ./tool/bazel test ${{ inputs.target }} --test_output=streamed

.github/actions/setup/action.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ description: Setup Bazel caches for CI jobs
1414
# same job (preferred), then same deps, then any.
1515

1616
runs:
17-
using: composite
18-
steps:
19-
- name: Setup Bazel cache
20-
uses: actions/cache@v4
21-
with:
22-
path: |
23-
~/.cache/bazel-disk-cache
24-
~/.cache/bazel-repo-cache
25-
~/.cache/bazelisk
26-
key: bazel-${{ runner.os }}-${{ github.job }}-${{ hashFiles('MODULE.bazel', 'go.mod', 'go.sum', '.bazelversion', '.bazelrc') }}-${{ github.run_id }}
27-
restore-keys: |
28-
bazel-${{ runner.os }}-${{ github.job }}-${{ hashFiles('MODULE.bazel', 'go.mod', 'go.sum', '.bazelversion', '.bazelrc') }}-
29-
bazel-${{ runner.os }}-${{ github.job }}-
30-
bazel-${{ runner.os }}-
17+
using: composite
18+
steps:
19+
- name: Setup Bazel cache
20+
uses: actions/cache@v4
21+
with:
22+
path: |
23+
~/.cache/bazel-disk-cache
24+
~/.cache/bazel-repo-cache
25+
~/.cache/bazelisk
26+
key: bazel-${{ runner.os }}-${{ github.job }}-${{ hashFiles('MODULE.bazel', 'go.mod', 'go.sum', '.bazelversion', '.bazelrc') }}-${{ github.run_id }}
27+
restore-keys: |
28+
bazel-${{ runner.os }}-${{ github.job }}-${{ hashFiles('MODULE.bazel', 'go.mod', 'go.sum', '.bazelversion', '.bazelrc') }}-
29+
bazel-${{ runner.os }}-${{ github.job }}-
30+
bazel-${{ runner.os }}-

.github/workflows/ci.yml

Lines changed: 141 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -1,133 +1,148 @@
11
name: CI
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
pull_request:
8-
types:
9-
- opened
10-
- reopened
11-
- synchronize
12-
merge_group:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types:
9+
- opened
10+
- reopened
11+
- synchronize
12+
merge_group:
1313

1414
permissions:
15-
contents: read
16-
pull-requests: read
15+
contents: read
1716

1817
jobs:
19-
# ---------------------------------------------------------------------------
20-
# BUILD AND UNIT TESTS (special case - Gazelle + build + unit tests)
21-
# ---------------------------------------------------------------------------
22-
build-and-unit-test:
23-
name: Build and Unit Test
24-
runs-on: ubuntu-latest
25-
steps:
26-
- uses: actions/checkout@v4
27-
- uses: ./.github/actions/setup
28-
29-
- name: Check BUILD files are up to date
30-
run: |
31-
echo "Running Gazelle to check BUILD files..." >&2
32-
make gazelle
33-
if ! git diff --quiet; then
34-
echo "BUILD files are out of date!" >&2
35-
echo "" >&2
36-
echo "The following files were modified by Gazelle:" >&2
37-
git diff --name-only >&2
38-
echo "" >&2
39-
echo "Please run 'make gazelle' locally and commit the changes." >&2
40-
exit 1
41-
fi
42-
echo "BUILD files are up to date" >&2
43-
44-
- name: Build project
45-
run: make build
46-
47-
- name: Run unit tests
48-
run: make test || echo "No unit tests found"
49-
50-
# ---------------------------------------------------------------------------
51-
# INTEGRATION TESTS (e2e, gateway, orchestrator)
52-
# ---------------------------------------------------------------------------
53-
e2e:
54-
name: E2E Integration Test
55-
runs-on: ubuntu-latest
56-
steps:
57-
- uses: actions/checkout@v4
58-
- uses: ./.github/actions/setup
59-
60-
- name: Run E2E tests
61-
run: make e2e-test
62-
63-
gateway-integration-test:
64-
name: Gateway Integration Test
65-
runs-on: ubuntu-latest
66-
steps:
67-
- uses: actions/checkout@v4
68-
- uses: ./.github/actions/setup
69-
70-
- name: Run Gateway integration tests
71-
run: make integration-test-gateway
72-
73-
orchestrator-integration-test:
74-
name: Orchestrator Integration Test
75-
runs-on: ubuntu-latest
76-
steps:
77-
- uses: actions/checkout@v4
78-
- uses: ./.github/actions/setup
79-
80-
- name: Run Orchestrator integration tests
81-
run: make integration-test-orchestrator
82-
83-
# ---------------------------------------------------------------------------
84-
# EXTENSION TESTS
85-
# ---------------------------------------------------------------------------
86-
counter-integration-test:
87-
name: Counter Extension Test
88-
runs-on: ubuntu-latest
89-
steps:
90-
- uses: actions/checkout@v4
91-
- uses: ./.github/actions/setup
92-
- uses: ./.github/actions/run-bazel-test
93-
with:
94-
target: //test/integration/extension/counter/...
95-
96-
queue-integration-test:
97-
name: Queue Extension Test
98-
runs-on: ubuntu-latest
99-
steps:
100-
- uses: actions/checkout@v4
101-
- uses: ./.github/actions/setup
102-
- uses: ./.github/actions/run-bazel-test
103-
with:
104-
target: //test/integration/extension/queue/...
105-
106-
storage-integration-test:
107-
name: Storage Extension Test
108-
runs-on: ubuntu-latest
109-
steps:
110-
- uses: actions/checkout@v4
111-
- uses: ./.github/actions/setup
112-
- uses: ./.github/actions/run-bazel-test
113-
with:
114-
target: //test/integration/extension/storage/...
115-
116-
# ---------------------------------------------------------------------------
117-
# REQUIRED CHECKS GATE
118-
# ---------------------------------------------------------------------------
119-
required-checks:
120-
name: Required Checks
121-
runs-on: ubuntu-latest
122-
needs:
123-
- build-and-unit-test
124-
- e2e
125-
- gateway-integration-test
126-
- orchestrator-integration-test
127-
- counter-integration-test
128-
- queue-integration-test
129-
- storage-integration-test
130-
steps:
131-
- name: All required checks passed
132-
run: |
133-
echo "All required checks passed!" >&2
18+
# ---------------------------------------------------------------------------
19+
# LINT (gofmt via Go SDK, yamlfmt via go run)
20+
# ---------------------------------------------------------------------------
21+
lint:
22+
name: Lint
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: ./.github/actions/setup
27+
28+
- name: Run linters
29+
run: make lint
30+
31+
# ---------------------------------------------------------------------------
32+
# TIDY (module files + BUILD files in sync)
33+
# ---------------------------------------------------------------------------
34+
tidy:
35+
name: Tidy
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v4
39+
- uses: ./.github/actions/setup
40+
41+
- name: Check module files are tidy
42+
run: make check-tidy
43+
44+
- name: Check BUILD files are up to date
45+
run: make check-gazelle
46+
47+
# ---------------------------------------------------------------------------
48+
# BUILD AND UNIT TESTS
49+
# ---------------------------------------------------------------------------
50+
build-and-unit-test:
51+
name: Build and Unit Test
52+
runs-on: ubuntu-latest
53+
steps:
54+
- uses: actions/checkout@v4
55+
- uses: ./.github/actions/setup
56+
57+
- name: Build project
58+
run: make build
59+
60+
- name: Run unit tests
61+
run: make test
62+
63+
# ---------------------------------------------------------------------------
64+
# INTEGRATION TESTS (e2e, gateway, orchestrator)
65+
# ---------------------------------------------------------------------------
66+
e2e:
67+
name: E2E Integration Test
68+
runs-on: ubuntu-latest
69+
steps:
70+
- uses: actions/checkout@v4
71+
- uses: ./.github/actions/setup
72+
73+
- name: Run E2E tests
74+
run: make e2e-test
75+
76+
gateway-integration-test:
77+
name: Gateway Integration Test
78+
runs-on: ubuntu-latest
79+
steps:
80+
- uses: actions/checkout@v4
81+
- uses: ./.github/actions/setup
82+
83+
- name: Run Gateway integration tests
84+
run: make integration-test-gateway
85+
86+
orchestrator-integration-test:
87+
name: Orchestrator Integration Test
88+
runs-on: ubuntu-latest
89+
steps:
90+
- uses: actions/checkout@v4
91+
- uses: ./.github/actions/setup
92+
93+
- name: Run Orchestrator integration tests
94+
run: make integration-test-orchestrator
95+
96+
# ---------------------------------------------------------------------------
97+
# EXTENSION TESTS
98+
# ---------------------------------------------------------------------------
99+
counter-integration-test:
100+
name: Counter Extension Test
101+
runs-on: ubuntu-latest
102+
steps:
103+
- uses: actions/checkout@v4
104+
- uses: ./.github/actions/setup
105+
- uses: ./.github/actions/run-bazel-test
106+
with:
107+
target: //test/integration/extension/counter/...
108+
109+
queue-integration-test:
110+
name: Queue Extension Test
111+
runs-on: ubuntu-latest
112+
steps:
113+
- uses: actions/checkout@v4
114+
- uses: ./.github/actions/setup
115+
- uses: ./.github/actions/run-bazel-test
116+
with:
117+
target: //test/integration/extension/queue/...
118+
119+
storage-integration-test:
120+
name: Storage Extension Test
121+
runs-on: ubuntu-latest
122+
steps:
123+
- uses: actions/checkout@v4
124+
- uses: ./.github/actions/setup
125+
- uses: ./.github/actions/run-bazel-test
126+
with:
127+
target: //test/integration/extension/storage/...
128+
129+
# ---------------------------------------------------------------------------
130+
# REQUIRED CHECKS GATE
131+
# ---------------------------------------------------------------------------
132+
required-checks:
133+
name: Required Checks
134+
runs-on: ubuntu-latest
135+
needs:
136+
- lint
137+
- tidy
138+
- build-and-unit-test
139+
- e2e
140+
- gateway-integration-test
141+
- orchestrator-integration-test
142+
- counter-integration-test
143+
- queue-integration-test
144+
- storage-integration-test
145+
steps:
146+
- name: All required checks passed
147+
run: |
148+
echo "All required checks passed!" >&2

.yamlfmt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
formatter:
2+
type: basic
3+
indent: 4
4+
retain_line_breaks_single: true
5+
include_document_start: false

CLAUDE.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ submitqueue/
4848
│ ├── counter/ # Sequential number generation (interface + mysql/)
4949
│ ├── queue/ # Messaging queue abstraction (interface + sql/)
5050
│ └── storage/ # Storage abstraction (interface + mysql/)
51-
├── core/ # Shared infrastructure packages reused across services
51+
├── core/ # Shared infrastructure packages reused across services
5252
│ ├── consumer/ # Queue consumption framework (lifecycle, ack/nack, routing)
5353
│ └── errs/ # Error classification framework (user vs infra, retryability)
54+
├── tool/ # Development and CI tooling
5455
├── example/server/ # Runnable servers with Docker Compose
5556
├── test/
5657
│ ├── e2e/ # End-to-end tests (full stack)
@@ -157,10 +158,15 @@ integration-test: build-all-linux ## Run all integration tests (auto-builds bina
157158
```bash
158159
make build # Build all services
159160
make test # Run unit tests
161+
make lint # Run all linters (fmt + YAML)
162+
make fmt # Format Go and YAML code
163+
make check-tidy # Check go.mod and MODULE.bazel are tidy
164+
make check-gazelle # Check BUILD.bazel files are up to date
165+
make tidy # Run go mod tidy + bazel mod tidy
166+
make gazelle # Update BUILD.bazel files
160167
make integration-test # Run all integration tests (Docker-based)
161168
make e2e-test # Run end-to-end tests
162169
make proto # Regenerate proto files
163-
make gazelle # Update BUILD.bazel files
164170
make local-start # Start full stack with Docker Compose
165171
make local-ps # Show running containers and ports
166172
make local-logs # View logs from all services
@@ -256,6 +262,15 @@ deps = [
256262

257263
See [doc/howto/TESTING.md](doc/howto/TESTING.md) for full testing guide.
258264

265+
### CI and Validation
266+
267+
CI runs on every PR and enforces all checks via a `required-checks` gate. **Before committing, validate locally:**
268+
269+
1. `make fmt` — format Go and YAML code (CI will reject unformatted code)
270+
2. `make lint` — run all linters (formatting check)
271+
3. `make check-tidy` — ensure `go.mod` and `MODULE.bazel` are tidy
272+
4. `make check-gazelle` — ensure `BUILD.bazel` files are up to date
273+
259274
### Code Style
260275

261276
1. **Structured logging**`zap.SugaredLogger` with `Debugw`/`Infow`/`Errorw(msg, key, val, ...)`. Never unstructured methods.

0 commit comments

Comments
 (0)