From e955f65d8f880772dbbf8ec68304b13853c99528 Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Arango Gutierrez Date: Tue, 4 Mar 2025 12:13:46 +0100 Subject: [PATCH] [no-relnote] Enable Coveralls Signed-off-by: Carlos Eduardo Arango Gutierrez --- .github/workflows/golang.yaml | 21 ++++++++++++++++++++- Makefile | 6 +++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/.github/workflows/golang.yaml b/.github/workflows/golang.yaml index 3afd8e84..f9776daa 100644 --- a/.github/workflows/golang.yaml +++ b/.github/workflows/golang.yaml @@ -30,54 +30,73 @@ jobs: steps: - uses: actions/checkout@v4 name: Checkout code + - name: Get Golang version id: vars run: | GOLANG_VERSION=$(./hack/golang-version.sh) echo "GOLANG_VERSION=${GOLANG_VERSION##GOLANG_VERSION := }" >> $GITHUB_ENV + - name: Install Go uses: actions/setup-go@v5 with: go-version: ${{ env.GOLANG_VERSION }} + - name: Lint uses: golangci/golangci-lint-action@v8 with: version: latest args: -v --timeout 5m skip-cache: true + - name: Check golang modules run: | make check-vendor make -C deployments/devel check-modules + test: name: Unit test runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 + - name: Get Golang version id: vars run: | GOLANG_VERSION=$(./hack/golang-version.sh) echo "GOLANG_VERSION=${GOLANG_VERSION##GOLANG_VERSION := }" >> $GITHUB_ENV + - name: Install Go uses: actions/setup-go@v5 with: go-version: ${{ env.GOLANG_VERSION }} - - run: make test + + - name: Run unit tests and generate coverage report + run: make coverage + + - name: Upload to Coveralls + uses: coverallsapp/github-action@v2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + file: coverage.out + build: name: Build runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 + - name: Get Golang version id: vars run: | GOLANG_VERSION=$(./hack/golang-version.sh) echo "GOLANG_VERSION=${GOLANG_VERSION##GOLANG_VERSION ?= }" >> $GITHUB_ENV + - name: Install Go uses: actions/setup-go@v5 with: go-version: ${{ env.GOLANG_VERSION }} + - run: make build diff --git a/Makefile b/Makefile index ac491762..86433fa2 100644 --- a/Makefile +++ b/Makefile @@ -122,11 +122,11 @@ licenses: COVERAGE_FILE := coverage.out test: build cmds - go test -coverprofile=$(COVERAGE_FILE) $(MODULE)/... + go test -coverprofile=$(COVERAGE_FILE).with-mocks $(MODULE)/... coverage: test - cat $(COVERAGE_FILE) | grep -v "_mock.go" > $(COVERAGE_FILE).no-mocks - go tool cover -func=$(COVERAGE_FILE).no-mocks + cat $(COVERAGE_FILE).with-mocks | grep -v "_mock.go" > $(COVERAGE_FILE) + go tool cover -func=$(COVERAGE_FILE) generate: go generate $(MODULE)/...