1- name : Unit Tests
1+ name : Unit
22
33on :
44 pull_request :
@@ -16,25 +16,62 @@ concurrency:
1616 cancel-in-progress : true
1717
1818jobs :
19- # Runs the unit tests for Go packages
20- go :
21- name : Go Unit Tests
19+ unit-tests :
20+ name : unit-tests (${{ matrix.shard.name }})
2221 runs-on : ubuntu-22.04
23- timeout-minutes : 25
22+ strategy :
23+ fail-fast : false
24+ matrix :
25+ shard :
26+ - name : fast
27+ # packages are everything except the heavy hitters. calculated in the job step.
28+ - name : translator
29+ packages : " ./internal/kgateway/translator/gateway"
30+ - name : setup
31+ packages : " ./internal/kgateway/setup"
32+ - name : controller
33+ packages : " ./internal/kgateway/controller"
34+ - name : agw
35+ packages : " ./internal/kgateway/agentgatewaysyncer"
36+ - name : sds
37+ packages : " ./internal/sds/pkg/run"
2438 steps :
25- - uses : actions/checkout@v4
26- - name : Setup Go
27- uses : actions/setup-go@v5
28- with :
29- go-version-file : go.mod
30- - name : Install dependencies
31- run : make mod-download
32- - name : Run Tests
33- shell : bash
34- run : make unit-with-coverage
35- - name : Validate Test Coverage
36- shell : bash
37- # The make will error if test coverage drops below a certain threshold
38- # We intentionally ignore the errors while we build out our test coverage, to establish a good baseline
39- # However, we should strive to establish a baseline, and then make it required on PRs
40- run : make --always-make --ignore-errors validate-test-coverage
39+ - uses : actions/checkout@v4
40+ - name : Setup Go
41+ uses : actions/setup-go@v5
42+ with :
43+ go-version-file : go.mod
44+ cache : true
45+ - name : Download deps
46+ run : make mod-download
47+ - name : Run unit tests (${{ matrix.shard.name }})
48+ run : |
49+ if [ "${{ matrix.shard.name }}" = "fast" ]; then
50+ PACKAGES=$(go list ./... | grep -v -e 'internal/kgateway/translator/gateway$' -e 'internal/kgateway/controller$' -e 'internal/kgateway/agentgatewaysyncer$' -e 'internal/sds/pkg/run$' -e 'internal/kgateway/setup$' | tr '\n' ' ')
51+ make unit-with-coverage TEST_PKG="$PACKAGES" GO_TEST_ARGS="-timeout=15m"
52+ else
53+ make unit-with-coverage TEST_PKG="${{ matrix.shard.packages }}" GO_TEST_ARGS="-timeout=15m"
54+ fi
55+ - name : Validate Test Coverage
56+ shell : bash
57+ run : make validate-test-coverage || true
58+ - name : Upload coverage
59+ if : success()
60+ uses : actions/upload-artifact@v4
61+ with :
62+ name : coverage-${{ matrix.shard.name }}
63+ path : cover.out
64+ if-no-files-found : ignore
65+
66+ aggregate :
67+ name : unit
68+ runs-on : ubuntu-22.04
69+ needs :
70+ - unit-tests
71+ steps :
72+ - name : Download coverage artifacts
73+ uses : actions/download-artifact@v4
74+ with :
75+ path : ./coverage
76+ - name : Done
77+ run : echo "All unit tests passed"
0 commit comments