Skip to content

Commit cab2990

Browse files
committed
ci: add maas-controller CI workflow and remove obsolete image build from maas-api
add a dedicated github actions workflow for maas-controller that runs lint and test jobs on PRs touching maas-controller/**, with coverage artifact uploads. the go version and golangci-lint version are resolved dynamically from go.mod and tools.mk respectively. remove the image build step and push-on-merge trigger from maas-api-ci since container builds are now handled by konflux. rename the build job to test to reflect its actual purpose. update maas-controller makefile test target to produce coverage output (-race -coverprofile) consistent with the maas-api pattern. Signed-off-by: Chaitanya Kulkarni <ckulkarn@redhat.com> Signed-off-by: Chaitanya Kulkarni <chkulkar@redhat.com> Made-with: Cursor
1 parent 409b0a7 commit cab2990

File tree

3 files changed

+72
-9
lines changed

3 files changed

+72
-9
lines changed

.github/workflows/maas-api-ci.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
name: MaaS API
22

33
on:
4-
push:
5-
branches:
6-
- main
74
pull_request:
85
paths:
96
- 'maas-api/**'
@@ -43,7 +40,7 @@ jobs:
4340
with:
4441
version: ${{ steps.golangci-version.outputs.version }}
4542
working-directory: ${{ env.PROJECT_DIR }}
46-
build:
43+
test:
4744
runs-on: ubuntu-latest
4845
steps:
4946
- uses: actions/checkout@v5
@@ -66,6 +63,3 @@ jobs:
6663
${{ env.PROJECT_DIR }}/coverage.out
6764
${{ env.PROJECT_DIR }}/coverage.html
6865
retention-days: 30
69-
70-
- name: Build image
71-
run: make build-image
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: MaaS Controller
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'maas-controller/**'
7+
8+
permissions:
9+
actions: read
10+
contents: read
11+
12+
env:
13+
PROJECT_DIR: maas-controller
14+
15+
defaults:
16+
17+
run:
18+
working-directory: maas-controller
19+
20+
jobs:
21+
lint:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v5
25+
26+
- name: Align golangci-lint version with Makefile
27+
id: golangci-version
28+
run: |
29+
VERSION=$(grep '^GOLANGCI_LINT_VERSION' tools.mk | cut -d'=' -f2 | tr -d ' ?')
30+
echo "version=$VERSION" >> $GITHUB_OUTPUT
31+
32+
- uses: actions/setup-go@v6
33+
with:
34+
go-version-file: maas-controller/go.mod
35+
cache: true
36+
cache-dependency-path: maas-controller/go.sum
37+
38+
- name: golangci-lint
39+
uses: golangci/golangci-lint-action@v9
40+
with:
41+
version: ${{ steps.golangci-version.outputs.version }}
42+
working-directory: ${{ env.PROJECT_DIR }}
43+
44+
test:
45+
runs-on: ubuntu-latest
46+
steps:
47+
- uses: actions/checkout@v5
48+
49+
- uses: actions/setup-go@v6
50+
with:
51+
go-version-file: ${{ env.PROJECT_DIR }}/go.mod
52+
cache: true
53+
cache-dependency-path: ${{ env.PROJECT_DIR }}/go.sum
54+
55+
- name: Run tests
56+
run: make test
57+
58+
- name: Upload coverage reports
59+
uses: actions/upload-artifact@v4
60+
if: always()
61+
with:
62+
name: maas-controller-coverage
63+
path: |
64+
${{ env.PROJECT_DIR }}/coverage.out
65+
${{ env.PROJECT_DIR }}/coverage.html
66+
retention-days: 30

maas-controller/Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,12 @@ $(BUILD_DIR):
6464
run: build ## build and run manager locally
6565
$(BUILD_DIR)/$(BINARY_NAME)
6666

67+
TEST_FLAGS ?= -race -coverprofile=coverage.out
6768
.PHONY: test
68-
test: tidy ## run tests
69-
go test ./...
69+
test: tidy ## run tests with coverage
70+
go test $(TEST_FLAGS) ./...
71+
@go tool cover -html=coverage.out -o coverage.html
72+
@echo "Test coverage report generated: $(abspath coverage.html)"
7073

7174
.PHONY: tidy
7275
tidy:

0 commit comments

Comments
 (0)