Add SonarQube #22

Merged
luketainton merged 6 commits from sonar into main 2022-08-13 20:02:15 +00:00
2 changed files with 37 additions and 3 deletions
Showing only changes of commit aa3c0c74f3 - Show all commits

View File

@@ -7,19 +7,24 @@ permissions:
contents: read contents: read
jobs: jobs:
lint: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Check out repository code - uses: actions/checkout@v3
uses: actions/checkout@v3
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.19
- name: Create golangci-lint report - name: Create golangci-lint report
run: | run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.42.1 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 $(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 sed -i 's+<file name="+<file name="go/+g' report.xml
cat report.xml cat report.xml
- name: Test
run: go test -short -coverprofile=coverage.out
- uses: sonarsource/sonarqube-scan-action@master - uses: sonarsource/sonarqube-scan-action@master
env: env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

29
ipilot_test.go Normal file
View File

@@ -0,0 +1,29 @@
package main
import "testing"
func TestGetCurrentIP(t *testing.T) {
myip := getLocalIP()
if myip == nil {
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()
}
}