@@ -19,6 +19,7 @@ func ciWorkflow(cfg core.Configuration, sr golang.ScanResult) {
1919
2020 w := newWorkflow ("CI" , ghwCfg .Global .DefaultBranch , ignorePaths )
2121 w .On .WorkflowDispatch .manualTrigger = true
22+ w .On .Push .Branches = []string {ghwCfg .Global .DefaultBranch }
2223
2324 if w .deleteIf (ghwCfg .CI .Enabled ) {
2425 return
@@ -52,36 +53,37 @@ func ciWorkflow(cfg core.Configuration, sr golang.ScanResult) {
5253 Run : makeMultilineYAMLString (testCmd ),
5354 })
5455
55- if ghwCfg .CI .Coveralls && ! ghwCfg .IsSelfHostedRunner {
56- multipleOS := len (ghwCfg .CI .RunsOn ) > 1
57- env := map [string ]string {
58- "GIT_BRANCH" : "${{ github.head_ref }}" ,
59- "COVERALLS_TOKEN" : "${{ secrets.GITHUB_TOKEN }}" ,
60- }
61- installGoveralls := "go install github.com/mattn/goveralls@latest"
62- cmd := "goveralls -service=github -coverprofile=build/cover.out"
63- if multipleOS {
64- cmd += ` -parallel -flagname="Unit-${{ matrix.os }}"`
65- }
66- testJob .addStep (jobStep {
67- Name : "Upload coverage report to Coveralls" ,
68- Run : makeMultilineYAMLString ([]string {installGoveralls , cmd }),
69- Env : env ,
70- })
56+ // see https://github.com/fgrosse/go-coverage-report#usage
57+ coverageArtifactName := "code-coverage"
58+ testJob .addStep (jobStep {
59+ Name : "Archive code coverage results" ,
60+ Uses : core .GetUploadArtifactAction (ghwCfg .IsSelfHostedRunner ),
61+ With : map [string ]any {
62+ "name" : coverageArtifactName ,
63+ "path" : "build/cover.out" ,
64+ },
65+ })
7166
72- if multipleOS {
73- // 04. Tell Coveralls to merge coverage results.
74- finishJob := baseJobWithGo ("Finish" , cfg )
75- finishJob .Needs = []string {"test" } // this is the <job_id> for the test job
76- finishJob .addStep (jobStep {
77- Name : "Coveralls post build webhook" ,
78- Run : makeMultilineYAMLString ([]string {installGoveralls , "goveralls -parallel-finish" }),
79- Env : env ,
80- })
81- w .Jobs ["finish" ] = finishJob
82- }
83- }
8467 w .Jobs ["test" ] = testJob
8568
69+ // see https://github.com/fgrosse/go-coverage-report#usage
70+ codeCov := baseJob ("Code coverage report" , cfg .GitHubWorkflow )
71+ codeCov .If = "github.event_name == 'pull_request'"
72+ codeCov .Needs = []string {"test" }
73+ codeCov .Permissions = permissions {
74+ Contents : "read" ,
75+ Actions : "read" ,
76+ PullRequests : "write" ,
77+ }
78+ codeCov .addStep (jobStep {
79+ Name : "Post coverage report" ,
80+ Uses : core .GoCoverageReportAction ,
81+ With : map [string ]any {
82+ "coverage-artifact-name" : coverageArtifactName ,
83+ "coverage-file-name" : "cover.out" ,
84+ },
85+ })
86+ w .Jobs ["code_coverage" ] = codeCov
87+
8688 writeWorkflowToFile (w )
8789}
0 commit comments