Add SonarQube #22
35
.github/workflows/test.yml
vendored
Normal file
35
.github/workflows/test.yml
vendored
Normal 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 }}
|
||||
29
ipilot_test.go
Normal file
29
ipilot_test.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestGetCurrentIP(t *testing.T) {
|
||||
myip := getLocalIP()
|
||||
if myip == "" {
|
||||
t.Log("could not retrieve current IP")
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsIPAddress(t *testing.T) {
|
||||
ipaddress := "192.168.0.1"
|
||||
isIP := isIPAddress(ipaddress)
|
||||
if isIP == false {
|
||||
t.Log("could not verify " + ipaddress + " is an IP address")
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestResolveDNSHostname(t *testing.T) {
|
||||
hostname := "one.one.one.one"
|
||||
ipaddress := resolveDNSHostname(hostname)
|
||||
if ipaddress != "1.1.1.1" {
|
||||
t.Log("could not resolve IP for " + hostname)
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
6
sonar-project.properties
Normal file
6
sonar-project.properties
Normal file
@@ -0,0 +1,6 @@
|
||||
sonar.projectKey=luketainton_iPilot_AYKYmHI397IDIMpeRtF7
|
||||
sonar.sources=.
|
||||
sonar.exclusions=,.github/**,.gitignore,CODEOWNERS,CHANGELOG.md,LICENSE.md,README.md,renovate.json,**/*_test.go
|
||||
sonar.tests=.
|
||||
sonar.test.inclusions=**/*_test.go
|
||||
sonar.go.golangci-lint.reportPaths=report.xml
|
||||
Reference in New Issue
Block a user