Add SonarQube #22
11
.github/workflows/test.yml
vendored
11
.github/workflows/test.yml
vendored
@@ -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
29
ipilot_test.go
Normal 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()
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user