File tree Expand file tree Collapse file tree 2 files changed +35
-2
lines changed
Expand file tree Collapse file tree 2 files changed +35
-2
lines changed Original file line number Diff line number Diff line change 11name : CI Workflow
22
3- on : [pull_request, workflow_dispatch]
3+ on :
4+ pull_request :
5+ workflow_dispatch :
6+ push :
7+ branches :
8+ - main
49
510env :
611 GO_VERSION : " 1.24"
12+ CODE_COVERAGE_FILE_NAME : " coverage.out" # must be the same as in Makefile
13+ CODE_COVERAGE_ARTIFACT_NAME : " code-coverage"
714
815jobs :
916 main :
3340 - name : Test
3441 run : make test
3542
43+
44+ - name : Archive code coverage results
45+ uses : actions/upload-artifact@v4
46+ with :
47+ name : ${{ env.CODE_COVERAGE_ARTIFACT_NAME }}
48+ path : " stackit/${{ env.CODE_COVERAGE_FILE_NAME }}"
49+
50+
3651 config :
3752 name : Check GoReleaser config
53+ if : github.event_name == 'pull_request'
3854 runs-on : ubuntu-latest
3955 steps :
4056 - name : Checkout
4460 uses : goreleaser/goreleaser-action@v6
4561 with :
4662 args : check
63+
64+ code_coverage :
65+ name : " Code coverage report"
66+ if : github.event_name == 'pull_request' # Do not run when workflow is triggered by push to main branch
67+ runs-on : ubuntu-latest
68+ needs : main
69+ permissions :
70+ contents : read
71+ actions : read # to download code coverage results from "main" job
72+ pull-requests : write # write permission needed to comment on PR
73+ steps :
74+ - name : Check new code coverage
75+ uses : fgrosse/go-coverage-report@v1.2.0
76+ with :
77+ coverage-artifact-name : ${{ env.CODE_COVERAGE_ARTIFACT_NAME }}
78+ coverage-file-name : ${{ env.CODE_COVERAGE_FILE_NAME }}
79+ root-package : ' github.com/stackitcloud/terraform-provider-stackit'
Original file line number Diff line number Diff line change 3535# TEST
3636test :
3737 @echo " Running tests for the terraform provider"
38- @cd $(ROOT_DIR ) /stackit && go test ./... -count=1 && cd $(ROOT_DIR )
38+ @cd $(ROOT_DIR ) /stackit && go test ./... -count=1 -coverprofile=coverage.out && cd $(ROOT_DIR )
3939
4040# Test coverage
4141coverage :
You can’t perform that action at this time.
0 commit comments