File tree Expand file tree Collapse file tree 4 files changed +53
-2
lines changed Expand file tree Collapse file tree 4 files changed +53
-2
lines changed Original file line number Diff line number Diff line change 1+ name : Sonarcloud scan
2+
3+ on :
4+ workflow_run :
5+ workflows :
6+ - Unit Tests
7+ types :
8+ - completed
9+
10+ jobs :
11+ sonarcloud :
12+ uses : stolostron/governance-policy-framework/.github/workflows/sonarcloud.yml@main
13+ secrets :
14+ SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
Original file line number Diff line number Diff line change 2323 with :
2424 go-version-file : go.mod
2525
26- - name : Unit Tests
26+ - name : Test Coverage and Report Generation
2727 run : |
28- make test
28+ make test-coverage | tee report_unit.json
29+ make gosec-scan
30+ cat gosec.json
31+
32+ - name : Store the GitHub triggering event for the sonarcloud workflow
33+ if : |
34+ github.repository_owner == 'stolostron'
35+ run : |
36+ cat <<EOF > event.json
37+ ${{ toJSON(github.event) }}
38+ EOF
39+
40+ - name : Upload artifacts for the sonarcloud workflow
41+ if : |
42+ github.repository_owner == 'stolostron'
43+ uses : actions/upload-artifact@v3
44+ with :
45+ name : artifacts
46+ path : |
47+ coverage*.out
48+ event.json
49+ gosec.json
Original file line number Diff line number Diff line change @@ -24,3 +24,6 @@ vendor/
2424.idea
2525
2626bin /
27+
28+ gosec.json
29+ coverage.out
Original file line number Diff line number Diff line change @@ -80,6 +80,19 @@ lint: lint-dependencies lint-all
8080# ###########################################################
8181# test section
8282# ###########################################################
83+ GOSEC = $(LOCAL_BIN ) /gosec
8384
8485test :
8586 @go test $(TESTARGS ) ./...
87+
88+ .PHONY : test-coverage
89+ test-coverage : TESTARGS = -json -cover -covermode=atomic -coverprofile=coverage.out
90+ test-coverage : test
91+
92+ .PHONY : gosec
93+ gosec :
94+ $(call go-get-tool,github.com/securego/gosec/v2/cmd/[email protected] ) 95+
96+ .PHONY : gosec-scan
97+ gosec-scan : gosec
98+ $(GOSEC ) -fmt sonarqube -out gosec.json -no-fail -exclude-dir=.go ./...
You can’t perform that action at this time.
0 commit comments