@@ -30,34 +30,71 @@ jobs:
30
30
31
31
- run : go version
32
32
33
- # Checks-out repository under $GITHUB_WORKSPACE
34
- - name : Checkout
35
- if : ${{!startsWith(matrix.os, 'ubuntu')}}
36
- uses : actions/checkout@v4
37
-
38
33
# Checks-out repository under $GITHUB_WORKSPACE with tags and history (needed by "SonarCloud Scan" step)
39
34
- name : Full checkout
40
- if : startsWith(matrix.os,'ubuntu')
41
35
uses : actions/checkout@v4
42
36
with :
43
37
fetch-depth : 0 # Full clone for SonarCloud
44
38
45
39
# Build everything
46
40
- name : Run a build
47
41
run : go build ./...
42
+ shell : bash
48
43
49
44
# Runs a single command using the runners shell, -p1 for `race: limit on 8128 simultaneously alive goroutines is exceeded, dying` at macos
50
45
- name : Run a test
51
- run : go test -v -race ./... -coverpkg=./... -covermode=atomic -coverprofile=./coverage.txt
46
+ run : go test -v -race ./... -coverpkg=./... -covermode=atomic -coverprofile=./coverage.txt -json > ./report.json
47
+ shell : bash
48
+
49
+ - name : Dump test report
50
+ if : always()
51
+ run : cat ./report.json
52
+ shell : bash
53
+
54
+ - name : Prepare upload files
55
+ run : |
56
+ mkdir -p ./outputs
57
+ cp ./coverage.txt ./outputs/${{ matrix.os }}.coverage.txt
58
+ cp ./report.json ./outputs/${{ matrix.os }}.report.json
59
+ shell : bash
60
+
61
+ - name : Upload coverage and report files
62
+ uses : actions/upload-artifact@v3
63
+ with :
64
+ name : ${{ hashFiles('./outputs') || 'none' }}
65
+ path : ./outputs
66
+ retention-days : 1
67
+ if-no-files-found : warn
68
+
69
+ coverage-sonar-cloud-scan :
70
+ needs : test
71
+ # The type of runner that the job will run on
72
+ runs-on : ubuntu-latest
73
+ steps :
74
+ # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
75
+ - uses : actions/checkout@v4
76
+ with :
77
+ fetch-depth : 0 # Shallow clones should be disabled for a better relevancy of analysis
78
+
79
+ - name : Download artifacts
80
+ uses : actions/download-artifact@v3
81
+ with :
82
+ path : ./outputs
83
+
84
+ - name : Prepare coverage and report files
85
+ run : |
86
+ mkdir -p .tmp/coverage
87
+ mkdir -p .tmp/report
88
+ find ./outputs -name "*.coverage.txt" -exec sh -c 'cp $1 .tmp/coverage/$(echo $1 | sed "s/[\/.]/-/g" ).coverage.txt' _ {} \;
89
+ find ./outputs -name "*.report.json" -exec sh -c 'cp $1 .tmp/report/$(echo $1 | sed "s/[\/.]/-/g" ).report.json' _ {} \;
52
90
53
- # Skip this step when running from forked repository (no write privileges)
54
- - name : Publish the coverage
55
- if : startsWith(matrix.os,'ubuntu')
56
- run : bash <(curl -s https://codecov.io/bash)
91
+ - name : Code coverage
92
+ uses : codecov/codecov-action@v4.0.0-beta.3
93
+ with :
94
+ token : ${{ secrets.CODECOV_TOKEN }}
95
+ directory : .tmp/
57
96
58
- # Skip this step when running from forked repository (no access to ${{ secrets }})
59
97
- name : SonarCloud Scan
60
- if : startsWith(matrix.os,'ubuntu')
61
98
uses : SonarSource/sonarcloud-github-action@master
62
99
env :
63
100
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments