Add SonarQube and unit tests (#22)

This commit was merged in pull request #22.
This commit is contained in:
Luke Tainton
2022-08-13 21:02:15 +01:00
committed by GitHub
parent c4de2f6025
commit d4c812f214
3 changed files with 70 additions and 0 deletions

35
.github/workflows/test.yml vendored Normal file
View File

@@ -0,0 +1,35 @@
name: Test
on:
pull_request:
push:
branches: [ main ]
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.19
- name: Create golangci-lint report
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.42.1
$(go env GOPATH)/bin/golangci-lint run --out-format checkstyle -D deadcode,unused --build-tags=integration --timeout 10m --issues-exit-code 0 ./... > report.xml
sed -i 's+<file name="+<file name="go/+g' report.xml
cat report.xml
- name: Test
run: go test -short -coverprofile=coverage.out
- uses: sonarsource/sonarqube-scan-action@master
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
- uses: sonarsource/sonarqube-quality-gate-action@master
timeout-minutes: 5
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}