@@ -54,18 +54,22 @@ jobs:
5454 # Standard E2E tests on all supported K8s versions
5555 k8s-version : ["1.31.14", "1.32.11", "1.33.7", "1.34.3", "1.35.0"]
5656 test-suite : ["e2e"]
57+ make-targets : ["setup-kind-cluster e2e-tests"]
5758 include :
58- # Deployment policy tests on 15-node cluster (K8s 1.34 only)
59+ # Deployment policy tests on 15-node cluster (K8s 1.35 only)
5960 - k8s-version : " 1.35.0"
6061 test-suite : deployment-policy
6162 kind-config : k8s-tests/chainsaw/deployment-policy/kind-config.yaml
62- make-target : deployment-policy-tests
63+ make-targets : " setup-kind-cluster deployment-policy-tests"
6364 # CLI e2e tests on K8s 1.34 only
6465 - k8s-version : " 1.35.0"
6566 test-suite : cli-e2e
66- make-target : cli-e2e-tests
67+ make-targets : " setup-kind-cluster cli-e2e-tests"
68+ - k8s-version : " 1.35.0"
69+ test-suite : unit-tests
70+ make-targets : " vet lint unit-tests"
6771 fail-fast : false # Continue testing other versions if one fails
68- name : ${{ matrix.test-suite }}-tests (k8s-${{ matrix.k8s-version }})
72+ name : ${{ matrix.test-suite }} (k8s-${{ matrix.k8s-version }})
6973 steps :
7074 - uses : actions/checkout@v4
7175 with :
@@ -77,16 +81,18 @@ jobs:
7781 go-version : ${{ env.GO_VERSION }}
7882 cache-dependency-path : operator/go.sum
7983 - name : Log in to the Container registry
84+ if : matrix.test-suite != 'unit-tests' # unit tests don't need a container registry login
8085 uses : docker/login-action@v3
8186 with :
8287 registry : ${{ env.REGISTRY }}
8388 username : ${{ github.actor }}
8489 password : ${{ secrets.GITHUB_TOKEN }}
8590 - name : Create Kubernetes KinD Cluster v${{ matrix.k8s-version }}
91+ if : matrix.test-suite != 'unit-tests' # unit tests don't need a kind cluster
8692 id : kind
8793 uses : helm/kind-action@v1
8894 with :
89- version : v0.30 .0
95+ version : v0.31 .0
9096 node_image : kindest/node:v${{ matrix.k8s-version }}
9197 config : ${{ matrix.kind-config || 'operator/config/local-dev/kind-config.yaml' }}
9298 cluster_name : kind
@@ -118,18 +124,53 @@ jobs:
118124 - name : Run ${{ matrix.test-suite }} tests
119125 run : |
120126 cd operator
121- if [ "${{ matrix.test-suite }}" = "e2e" ]; then
122- make setup-kind-cluster
123- make test
124- elif [ "${{ matrix.test-suite }}" = "cli-e2e" ]; then
125- make setup-kind-cluster
126- make ${{ matrix.make-target }}
127- else
128- make ${{ matrix.make-target }}
129- fi
130- # Upload coverage to Coveralls using goveralls (Go-specific tool)
131- - name : Upload coverage to Coveralls
132- if : matrix.test-suite == 'e2e' && matrix.k8s-version == '1.35.0'
127+ make ${{ matrix.make-targets }} merge-coverage
128+ # Save coverage artifacts from any test suite that generates them
129+ - name : Upload coverage artifact
130+ if : hashFiles('operator/reporting/cover.out') != ''
131+ uses : actions/upload-artifact@v4
132+ with :
133+ name : coverage-${{ matrix.test-suite }}-k8s-${{ matrix.k8s-version }}
134+ path : operator/reporting/cover.out
135+ retention-days : 1
136+ if-no-files-found : ignore
137+
138+ # Merge coverage from all test suites and upload to Coveralls
139+ upload-coverage :
140+ runs-on : ubuntu-latest
141+ needs : [tests]
142+ # Only upload coverage for PRs and main branch pushes, not for tags
143+ if : success() && !startsWith(github.ref, 'refs/tags/')
144+ steps :
145+ - uses : actions/checkout@v4
146+ - name : Setup Go ${{ env.GO_VERSION }}
147+ uses : actions/setup-go@v5
148+ with :
149+ go-version : ${{ env.GO_VERSION }}
150+ - name : Download all coverage artifacts
151+ uses : actions/download-artifact@v4
152+ with :
153+ pattern : coverage-*
154+ path : coverage-artifacts
155+ merge-multiple : false
156+ - name : Merge coverage files
157+ run : |
158+ cd operator
159+ mkdir -p reporting
160+ # Combine all coverage files
161+ for file in ../coverage-artifacts/*/cover.out; do
162+ if [ -f "$file" ]; then
163+ echo "Merging coverage from $file"
164+ cat "$file" >> reporting/all-cover.out
165+ fi
166+ done
167+ # Create final merged coverage file
168+ echo "mode: set" > reporting/cover.out
169+ tail -n +2 reporting/all-cover.out | sed '/mode: set/d' >> reporting/cover.out
170+ # Show total coverage
171+ echo "📊 Total Combined Coverage:"
172+ go tool cover -func reporting/cover.out | grep total
173+ - name : Upload to Coveralls
133174 uses : coverallsapp/github-action@v2
134175 with :
135176 github-token : ${{ secrets.GITHUB_TOKEN }}
0 commit comments