From e08dcc04d5fa138870559816c027210b54f3b779 Mon Sep 17 00:00:00 2001 From: Philippe Caseiro Date: Wed, 24 Oct 2018 10:44:44 +0200 Subject: [PATCH] Updating repo for Jenkins pipeline --- Jenkinsfile | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 35 +++++++++++++++++++++++++++++++ go.mod | 1 + modd.conf | 16 +++++++++++++++ 4 files changed, 111 insertions(+) create mode 100644 Jenkinsfile create mode 100644 Makefile create mode 100644 go.mod create mode 100644 modd.conf diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..03b3249 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,59 @@ +pipeline { + + agent { + docker { image 'golang:1.11' } + } + + stages { + + stage('Prepare environment') { + steps { + script { + sh 'make install-devtools' + sh 'make vendor' + } + } + } + + stage('Run unit tests') { + steps { + script { + sh 'make test' + } + } + } + + stage('Run lint') { + steps { + script { + try { + sh 'make LINT_ARGS="--new-from-rev=HEAD~" lint' + } catch(ex) { + currentBuild.result = "UNSTABLE" + } + } + } + } + + } + + post { + always { + script { + if (currentBuild.currentResult != 'SUCCESS') { + emailext ( + subject: "${currentBuild.currentResult} - Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'", + body: """ + Voir les étapes du job: ${env.BUILD_URL}flowGraphTable + + Projet: ${env.GIT_URL} + Branche: ${env.GIT_BRANCH} + Commit: ${env.GIT_COMMIT} + """, + recipientProviders: [developers(), requestor()], + ) + } + } + } + } +} diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b83e129 --- /dev/null +++ b/Makefile @@ -0,0 +1,35 @@ +LINT_ARGS ?= ./... +export GO111MODULE := on + +test: tidy + GO111MODULE=off go clean -testcache + go test -mod=vendor -v ./... + +lint: + @GO111MODULE=off golangci-lint run -e '.*/pkg/mod' -e ".*/go/src" --enable-all --disable lll $(LINT_ARGS) + +tidy: + go mod tidy + +vendor: tidy + go mod vendor + +install-devtools: vendor + # Install modd + GO111MODULE=off go get -u github.com/cortesi/modd/cmd/modd + # Install golangci-lint + GO111MODULE=off go get -u github.com/golangci/golangci-lint/cmd/golangci-lint + +clean: + rm -rf ./bin + go clean -i -x -r -modcache + +doc: + @echo "Open your browser to http://localhost:6060/pkg/forge.cadoles.com/Pyxis/orion/ to see the documentation" + @godoc -http=:6060 + +watch: + modd + + +.PHONY: test clean generate vendor install-devtools lint watch tidy doc bin/server diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..5eff59b --- /dev/null +++ b/go.mod @@ -0,0 +1 @@ +module forge.cadoles.com/Cadoles/owrt diff --git a/modd.conf b/modd.conf new file mode 100644 index 0000000..4c3a636 --- /dev/null +++ b/modd.conf @@ -0,0 +1,16 @@ +**/*.go +!**/*_test.go +modd.conf +.env +Makefile { + prep: make test +} + + +**/*.go +modd.conf +Makefile { + prep: make lint LINT_ARGS=--fast + prep: make test +} +