-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy path.gitlab-ci.yml
135 lines (123 loc) · 3.23 KB
/
.gitlab-ci.yml
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
stages:
- base
- prepare
- lint
- build
- test
- build-release
- deploy-release
cache: &global_cache_configuration
paths:
- build/
policy: pull-push
.docker-job:
tags: [docker_runner]
before_script:
- apk add --no-cache curl unzip python3 py3-pip
- pip3 install --upgrade pip
- pip3 install awscli
- rm -rf /var/cache/apk/*
.merge-request-job:
tags: [docker_runner]
image: ${container_registry}/energi3_builder
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
.tag-job:
tags: [docker_runner]
image: ${container_registry}/energi3_builder
rules:
- if: $CI_COMMIT_TAG
build-builder:
stage: base
cache: []
extends: .docker-job
script:
- docker build -t energi3_builder:${CI_COMMIT_REF_NAME} -f Dockerfile.builder --build-arg repository_remote=${repository_remote} .
- docker tag energi3_builder:${CI_COMMIT_REF_NAME} ${container_registry}/energi3_builder:${CI_COMMIT_REF_NAME}
- docker push ${container_registry}/energi3_builder:${CI_COMMIT_REF_NAME}
- docker tag energi3_builder:${CI_COMMIT_REF_NAME} ${container_registry}/energi3_builder:latest
- docker push ${container_registry}/energi3_builder:latest
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
changes:
- Dockerfile.builder
- if: $CI_COMMIT_TAG
- if: '$CI_COMMIT_BRANCH == "main"'
clean-repo:
stage: prepare
cache: []
extends: .merge-request-job
script:
- git checkout -- .
- git clean -fdx .
lint-go:
stage: lint
extends: .merge-request-job
script:
- make lint
format-go:
stage: lint
extends: .merge-request-job
script:
- if [[ "$(gofmt -s -e -d .)" != "" ]]; then echo "[Error] gofmt found unformatted files"; exit 1; fi
build-linux:
stage: build
cache:
# inherit all global cache settings
<<: *global_cache_configuration
needs:
- "lint-go"
- "format-go"
extends: .merge-request-job
script:
- git checkout -- .
- git clean -fdx .
- make all
- if [[ -z "$(git status --porcelain)" ]]; then echo "Working directory clean"; else echo -e "[Error] compile job left modified files in working directory:\n$(git status --porcelain)"; exit 1; fi
test-go-report:
stage: test
needs:
- "build-linux"
cache:
# inherit all global cache settings
<<: *global_cache_configuration
# override the policy
policy: pull
extends: .merge-request-job
script:
- make test-go-cover && tail -n1 .test-go-cover.func
artifacts:
when: always
paths:
- .test-go-report.xml
- .test-go-cover.func
- .test-go-cover.html
reports:
junit: .test-go-report.xml
expire_in: 2 day
coverage: "/\\(statements\\)\\s+\\d+.?\\d+%/"
build-release:
stage: build-release
cache: []
extends: .tag-job
script:
- make -f Makefile.release release
artifacts:
when: always
paths:
- ./build/release/*/*.tgz
- ./build/release/*/*-setup.exe
- ./build/release/*/*.zip
expire_in: 1 day
deploy-release:
stage: deploy-release
cache:
# inherit all global cache settings
<<: *global_cache_configuration
# override the policy
policy: pull
needs:
- build-release
extends: .tag-job
script:
- make -f Makefile.release release-upload