Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflows/test-unit-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Unit Test Coverage

on:
pull_request:
branches: [main]
paths:
# Only trigger on Go code changes in operator/src
- 'operator/src/**/*.go'
- 'operator/src/go.mod'
- 'operator/src/go.sum'

permissions:
contents: read
pull-requests: write

env:
GO_VERSION: '1.25.0'

jobs:
coverage:
name: Check Unit Test Coverage
runs-on: ubuntu-22.04
defaults:
run:
working-directory: operator/src

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for diff coverage analysis

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: operator/src/go.sum

- name: Download dependencies
run: go mod download

- name: Run unit tests with coverage
run: |
go test -coverprofile=coverage.out -covermode=atomic \
-coverpkg=./... \
$(go list ./... | grep -v /test/e2e)

echo "## Coverage Summary" >> $GITHUB_STEP_SUMMARY
go tool cover -func=coverage.out | tail -1 >> $GITHUB_STEP_SUMMARY

- name: Check diff coverage (newly added lines)
uses: seriousben/go-patch-cover-action@v1
with:
version: v0.7.0
coverage-filename: operator/src/coverage.out
threshold-file: 90 # Fail if new/changed lines have < 90% coverage

- name: Upload coverage artifact
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-report
path: operator/src/coverage.out
retention-days: 7
56 changes: 56 additions & 0 deletions .github/workflows/test-unit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Unit Test

on:
push:
branches: [main]
paths:
- 'operator/src/**/*.go'
- 'operator/src/go.mod'
- 'operator/src/go.sum'
pull_request:
branches: [main]
paths:
- 'operator/src/**/*.go'
- 'operator/src/go.mod'
- 'operator/src/go.sum'

permissions:
contents: read

env:
GO_VERSION: '1.25.0'

jobs:
unit-test:
name: Run Unit Tests
runs-on: ubuntu-22.04
defaults:
run:
working-directory: operator/src

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: operator/src/go.sum

- name: Download dependencies
run: go mod download

- name: Run go vet
run: go vet ./...

- name: Run unit tests
run: |
go test -v -race -timeout 10m \
$(go list ./... | grep -v /test/e2e)

- name: Test Summary
if: always()
run: |
echo "## Unit Test Results" >> $GITHUB_STEP_SUMMARY
echo "✅ Unit tests completed" >> $GITHUB_STEP_SUMMARY
Loading