-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.gitlab-ci.yaml
84 lines (78 loc) · 2.18 KB
/
.gitlab-ci.yaml
1
2
3
4
5
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
76
77
78
79
80
81
82
83
84
workflow:
rules:
- if: $CI_COMMIT_BRANCH == "master"
- if: $CI_MERGE_REQUEST_IID
- if: $CI_COMMIT_TAG
image: docker.frafos.net/go-ci:1.21
stages:
- test
- lint
- release
.go-cache:
variables:
GOPATH: /tmp/.go
before_script:
- mkdir -p /tmp/.go
cache:
paths:
- /tmp/.go/pkg/mod/
linting:
stage: lint
needs: []
allow_failure: true
artifacts:
when: always
paths:
- qc.json
reports:
codequality: qc.json
script:
- make lint LINT_ARGS='--max-same-issues 50 --out-format code-climate' \
| tee qc.json \
| jq -r '.[] | "\(.location.path):\(.location.lines.begin) \(.description)"'
unit testing:
stage: test
needs: []
extends: .go-cache
script:
- make test-cover TEST_ARGS='-v'
- make test-cover-html
- cat out.txt | go-junit-report > report.xml
- gocover-cobertura < cover.cov > cover.xml
coverage: /\(statements\)(?:\s+)?(\d+(?:\.\d+)?%)/
artifacts:
when: always
paths:
- report.xml
- cover.xml
- cover.html
reports:
junit: report.xml
coverage_report:
coverage_format: cobertura
path: cover.xml
release:
stage: release
image: docker.frafos.net/debian/git:12
needs:
- job: unit testing
artifacts: true
- job: linting
artifacts: true
artifacts:
when: always
paths:
- qc.json
- cover.html
rules:
- if: $CI_COMMIT_TAG # Run this job when a tag is created
script:
- |
release-cli --insecure-https create \
--name "gommon/webfmwk $CI_COMMIT_TAG" \
--description "New gommon/webfmwk version :tada: :rocket: ~~~ $CI_COMMIT_TAG_MESSAGE" \
--tag-name "$CI_COMMIT_TAG" \
--ref "$CI_COMMIT_SHORT_SHA" \
--assets-link "{\"name\":\"CHANGELOG\",\"url\":\"https://gitlab.frafos.net/gommon/webfmwk/-/blob/${CI_COMMIT_TAG}/CHANGELOG.md\"}" \
--assets-link "{\"name\":\"lint report\",\"url\":\"https://gitlab.frafos.net/gommon/webfmwk/-/jobs/${CI_JOB_ID}/artifacts/file/qc.json\"}" \
--assets-link "{\"name\":\"coverage report\",\"url\":\"https://gitlab.frafos.net/gommon/webfmwk/-/jobs/${CI_JOB_ID}/artifacts/file/cover.html\"}"