-
Notifications
You must be signed in to change notification settings - Fork 0
39 lines (38 loc) · 1.57 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
on: [push]
name: Test
jobs:
sonarcloud:
runs-on: ubuntu-latest
steps:
- name: get epository name
run: echo "REPOSITORY_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV
- uses: actions/checkout@v2
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
- uses: actions/setup-go@v3
with:
go-version: '1.20' # The Go version to download (if necessary) and use.
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
- name: Run tests
run: |
[[ ! -f ".golangci.yml" ]] && curl -kfsSL -O https://raw.githubusercontent.com/worldline-go/guide/main/lint/.golangci.yml || true
GOPATH="$(dirname ${PWD})" golangci-lint run --out-format checkstyle ./... > golangci-lint-report.out || true
go test -coverprofile=coverage.out -json ./... > test-report.out
- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@master
with:
args: >
-Dsonar.organization=${{ github.repository_owner }}
-Dsonar.projectKey=${{ github.repository_owner }}_${{ env.REPOSITORY_NAME }}
-Dsonar.go.coverage.reportPaths=coverage.out
-Dsonar.go.tests.reportPaths=test-report.out
-Dsonar.go.golangci-lint.reportPaths=golangci-lint-report.out
-Dsonar.sources=.
-Dsonar.exclusions=**/vendor/**,**/*_test.go
-Dsonar.tests=.
-Dsonar.test.inclusions=**/*_test.go
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}