-
-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
calculate coverage and report also from the other platforms
- Loading branch information
Showing
2 changed files
with
51 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,34 +30,71 @@ jobs: | |
|
||
- run: go version | ||
|
||
# Checks-out repository under $GITHUB_WORKSPACE | ||
- name: Checkout | ||
if: ${{!startsWith(matrix.os, 'ubuntu')}} | ||
uses: actions/checkout@v4 | ||
|
||
# Checks-out repository under $GITHUB_WORKSPACE with tags and history (needed by "SonarCloud Scan" step) | ||
- name: Full checkout | ||
if: startsWith(matrix.os,'ubuntu') | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # Full clone for SonarCloud | ||
|
||
# Build everything | ||
- name: Run a build | ||
run: go build ./... | ||
shell: bash | ||
|
||
# Runs a single command using the runners shell, -p1 for `race: limit on 8128 simultaneously alive goroutines is exceeded, dying` at macos | ||
- name: Run a test | ||
run: go test -v -race ./... -coverpkg=./... -covermode=atomic -coverprofile=./coverage.txt | ||
run: go test -v -race ./... -coverpkg=./... -covermode=atomic -coverprofile=./coverage.txt -json > ./report.json | ||
shell: bash | ||
|
||
- name: Dump test report | ||
if: always() | ||
run: cat ./report.json | ||
shell: bash | ||
|
||
- name: Prepare upload files | ||
run: | | ||
mkdir -p ./outputs | ||
cp ./coverage.txt ./outputs/${{ matrix.os }}.coverage.txt | ||
cp ./report.json ./outputs/${{ matrix.os }}.report.json | ||
shell: bash | ||
|
||
- name: Upload coverage and report files | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ hashFiles('./outputs') || 'none' }} | ||
path: ./outputs | ||
retention-days: 1 | ||
if-no-files-found: warn | ||
|
||
coverage-sonar-cloud-scan: | ||
needs: test | ||
# The type of runner that the job will run on | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | ||
|
||
- name: Download artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
path: ./outputs | ||
|
||
- name: Prepare coverage and report files | ||
run: | | ||
mkdir -p .tmp/coverage | ||
mkdir -p .tmp/report | ||
find ./outputs -name "*.coverage.txt" -exec sh -c 'cp $1 .tmp/coverage/$(echo $1 | sed "s/[\/.]/-/g" ).coverage.txt' _ {} \; | ||
find ./outputs -name "*.report.json" -exec sh -c 'cp $1 .tmp/report/$(echo $1 | sed "s/[\/.]/-/g" ).report.json' _ {} \; | ||
# Skip this step when running from forked repository (no write privileges) | ||
- name: Publish the coverage | ||
if: startsWith(matrix.os,'ubuntu') | ||
run: bash <(curl -s https://codecov.io/bash) | ||
- name: Code coverage | ||
uses: codecov/[email protected] | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
directory: .tmp/ | ||
|
||
# Skip this step when running from forked repository (no access to ${{ secrets }}) | ||
- name: SonarCloud Scan | ||
if: startsWith(matrix.os,'ubuntu') | ||
uses: SonarSource/sonarcloud-github-action@master | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters