From a3ebf976500969ca36bc00ad30a6c19b420c9a6a Mon Sep 17 00:00:00 2001 From: Ben Selby Date: Wed, 28 Aug 2019 21:56:27 +0100 Subject: [PATCH] Move builds and coverage to GitHub actions and Sonar --- .github/workflows/go.yml | 37 +++++++++++++++++++++++++++++++++++++ .gitignore | 3 +++ .travis.yml | 13 ------------- Makefile | 4 ++-- README.md | 4 ++-- sonar-project.properties | 13 +++++++++++++ 6 files changed, 57 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/go.yml delete mode 100644 .travis.yml create mode 100644 sonar-project.properties diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..bccc212 --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,37 @@ +name: Go +on: [push] +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Set up Go 1.12 + uses: actions/setup-go@v1 + with: + go-version: 1.12 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v1 + + - name: Get dependencies + run: | + make install + + - name: Vet + run: | + make vet + + - name: Build + run: | + make build + + - name: Test + run: | + make test + + - name: SonarCloud Scan + uses: sonarsource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.gitignore b/.gitignore index 725b1c9..cd29a58 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,6 @@ trace.out debug.test vendor/ debug + +# Sonar +.scannerwork/ diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 23afd73..0000000 --- a/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: go -go: - - 1.x -notifications: - email: always -env: - - GO111MODULE=on -before_install: - - go get golang.org/x/lint/golint -script: - - make all -after_success: - - bash <(curl -s https://codecov.io/bash) diff --git a/Makefile b/Makefile index 665d507..d977b84 100644 --- a/Makefile +++ b/Makefile @@ -48,11 +48,11 @@ static: ## Build the application .PHONY: test test: ## Run the unit tests - go test ./... -coverprofile=profile.out + go test ./... -coverprofile=coverage.out .PHONY: test-cov test-cov: test ## Run the unit tests with coverage - go tool cover -html=profile.out + go tool cover -html=coverage.out .PHONY: all ## Run everything all: clean install lint vet build test diff --git a/README.md b/README.md index 667363e..d59d6de 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Donny -[![Build Status](https://travis-ci.org/benmatselby/donny.png?branch=master)](https://travis-ci.org/benmatselby/donny) +[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=donny&metric=alert_status)](https://sonarcloud.io/dashboard?id=donny) [![Go Report Card](https://goreportcard.com/badge/github.com/benmatselby/donny?style=flat-square)](https://goreportcard.com/report/github.com/benmatselby/donny) _Forget it, Donny, you're out of your element!_ @@ -31,7 +31,7 @@ COMMANDS: If you are wanting to build and develop this, you will need the following items installed. If, however, you just want to run the application I recommend using the docker container (See below) -* Go version 1.11+ +- Go version 1.12+ ## Configuration diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..71a8a76 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,13 @@ +sonar.host.url=https://sonarcloud.io +sonar.organization=benmatselby +sonar.projectKey=donny +sonar.projectName=donny + +sonar.sources=. +sonar.exclusions=*_test.go + +sonar.tests=. +sonar.test.inclusions=*_test.go + +sonar.go.tests.reportPaths=coverage.out +sonar.go.coverage.reportPaths=coverage.out