File tree Expand file tree Collapse file tree 3 files changed +89
-0
lines changed
Expand file tree Collapse file tree 3 files changed +89
-0
lines changed Original file line number Diff line number Diff line change 1+ FROM scratch
2+ COPY php-metrics /
3+ ENTRYPOINT ["/php-metrics" ]
Original file line number Diff line number Diff line change 1+ node(' go1.15' ) {
2+ container(' run' ){
3+ def tag = ' '
4+
5+ try {
6+ stage(' Checkout' ){
7+ checkout scm
8+ notifyBitbucket()
9+ tag = sh(script : ' git tag -l --contains HEAD' , returnStdout : true ). trim()
10+ }
11+
12+ stage(' Run test' ){
13+ sh(' go test -v ./...' )
14+ }
15+
16+ if ( tag != ' ' ){
17+ strippedTag = tag. replaceFirst(' v' , ' ' )
18+ stage(' Build the application' ){
19+ echo " Building with docker tag ${ strippedTag} "
20+ sh(' CGO_ENABLED=0 GOOS=linux go build' )
21+ }
22+
23+ stage(' Generate docker image' ){
24+ image = docker. build(' fortnox/php-metrics:' + strippedTag, ' --pull .' )
25+ }
26+
27+ stage(' Push docker image' ){
28+ docker. withRegistry(" https://quay.io" , ' docker-registry' ) {
29+ image. push()
30+ }
31+ }
32+ }
33+
34+ currentBuild. result = ' SUCCESS'
35+ } catch (err) {
36+ currentBuild. result = ' FAILED'
37+ notifyBitbucket()
38+ throw err
39+ }
40+
41+ notifyBitbucket()
42+ }
43+ }
Original file line number Diff line number Diff line change 1+ .PHONY : build push run
2+
3+ IMAGE = quay.io/fortnox/php-metrics
4+ # supply when running make: make all VERSION=1.0.0
5+ # VERSION = 0.0.1
6+
7+ build :
8+ CGO_ENABLED=0 GOOS=linux go build
9+
10+ docker : build
11+ docker build --pull --rm -t $(IMAGE ) :$(VERSION ) .
12+ rm php-metrics
13+
14+ push :
15+ docker push $(IMAGE ) :$(VERSION )
16+
17+ all : build docker push
18+
19+ run :
20+ docker run -i --env-file=.env --rm -p 8080:8080 -t $(IMAGE ) :$(VERSION )
21+
22+ test : fmt
23+ go test ./...
24+
25+ cover :
26+ @echo Running coverage
27+ go get github.com/wadey/gocovmerge
28+ $(eval PKGS := $(shell go list ./... | grep -v /vendor/) )
29+ $(eval PKGS_DELIM := $(shell echo $(PKGS ) | sed -e 's/ /,/g') )
30+ go list -f ' {{if or (len .TestGoFiles) (len .XTestGoFiles)}}go test -test.v -test.timeout=120s -covermode=count -coverprofile={{.Name}}_{{len .Imports}}_{{len .Deps}}.coverprofile -coverpkg $(PKGS_DELIM) {{.ImportPath}}{{end}}' $(PKGS ) | xargs -I {} bash -c {}
31+ gocovmerge ` ls * .coverprofile` > cover.out
32+ rm * .coverprofile
33+
34+ cover-html : cover
35+ go tool cover -html cover.out
36+ cover-test : cover
37+ go get github.com/jonaz/gototcov
38+ gototcov -f cover.out -limit 80 -ignore-zero
39+
40+ localrun :
41+ bash -c " env ` grep -Ev ' ^#' .env | xargs` go run *.go"
42+ fmt :
43+ bash -c " test -z $$ (gofmt -l $$ (find . -type f -name '*.go' -not -path './vendor/*') | tee /dev/stderr) || (echo 'Code not formatted correctly according to gofmt!' && exit 1)"
You can’t perform that action at this time.
0 commit comments