Newer
Older
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
format:
stage: build
script:
- test -z "$(gofmt -l ./)"
vet:
stage: build
script:
- go vet -json ./... | tee vet-report.json
artifacts:
when: always
paths:
- vet-report.json
expire_in: 1 hour
test:
stage: build
script:
- go test -coverprofile=coverage.out -json ./... | tee test-report.json
artifacts:
when: always
paths:
- test-report.json
- coverage.out
expire_in: 1 hour
staticcheck:
stage: build
script:
- go install honnef.co/go/tools/cmd/staticcheck@latest # ideally we should version pin
- staticcheck ./...
golint:
stage: build
script:
- go install golang.org/x/lint/golint@latest # ideally we should version pin
- golint -set_exit_status ./...
build:
stage: build
script:
- go build ./...
artifacts:
# instead of manually adding i.e. the built binaries, we can instead just
# grab anything not tracked in Git
untracked: true
expire_in: 1 hour
# sonar instance needs to be running on localhost:9000 for this to work!
sonarcloud-check:
stage: build
needs:
- job: test
artifacts: true
- job: vet
artifacts: true
image:
name: sonarsource/sonar-scanner-cli:latest
entrypoint: [""]
variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"
GIT_DEPTH: "0"
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
script:
- sonar-scanner
release_job:
stage: release
rules:
- if: $CI_COMMIT_TAG # Run this job when a tag is created
script:
- ./go-executable-build.sh boilr boilr.go
release: # See https://docs.gitlab.com/ee/ci/yaml/#release for available properties
tag_name: '$CI_COMMIT_TAG'
description: '$CI_COMMIT_TAG'
artifacts:
paths:
- build/*