-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
143 lines (135 loc) · 4.44 KB
/
.gitlab-ci.yml
File metadata and controls
143 lines (135 loc) · 4.44 KB
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
136
137
138
139
140
141
142
143
stages:
- test
- compile
- build
- deploy
# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Security/SAST.gitlab-ci.yml
#include:
# - template: "SAST.gitlab-ci.yml"
# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Jobs/Code-Quality.gitlab-ci.yml
# https://docs.gitlab.com/ee/user/project/merge_requests/code_quality.html#example-configuration
# https://gitlab.com/gitlab-org/security-products/codequality
# https://gitlab.com/gitlab-org/ci-cd/codequality/-/issues/10
# https://gitlab.com/jheimbuck_gl/jh_java_example_project/-/blob/master/.gitlab-ci.yml
#include:
# - template: Code-Quality.gitlab-ci.yml
update-todo:
stage: compile
image: alpine:latest
script:
- apk add --no-cache curl git bash gawk
- bash Taskfile.sh update-todo-issue
only:
- master
frontend:
stage: compile
image: node:10-alpine
script:
- cd master-frontend
- apk add yarn
- yarn install --frozen-lockfile
- VUE_APP_API_URL="" yarn build
- ls -alh dist
- mv dist $CI_PROJECT_DIR/aimpanel-master-frontend
cache:
key: "$CI_JOB_NAME"
paths:
- master-frontend/node_modules
artifacts:
paths:
- aimpanel-master-frontend
expire_in: 1 month
only:
- master
- merge_requests
tags:
- docker
backend:
stage: compile
image: golang:latest
script:
- apt-get update
- apt-get install -y upx
#- go build -race -ldflags "-extldflags '-static'" -o $CI_PROJECT_DIR/aimpanel-master
#- go test -race $(go list ./... | grep -v /vendor/)
- CGO_ENABLED=0 go build -ldflags "-X gitlab.com/systemz/aimpanel2/master/config.GIT_COMMIT=$CI_COMMIT_SHA" -o $CI_PROJECT_DIR/aimpanel-master gitlab.com/systemz/aimpanel2/master
# requirements for journald integration
- apt-get update && apt-get install -q -y libsystemd-dev
- go build -ldflags "-X gitlab.com/systemz/aimpanel2/slave/config.GIT_COMMIT=$CI_COMMIT_SHA" -o $CI_PROJECT_DIR/aimpanel-slave-raw gitlab.com/systemz/aimpanel2/slave
# pack slave binary for smaller disk footprint
- upx -9 -o $CI_PROJECT_DIR/aimpanel-slave $CI_PROJECT_DIR/aimpanel-slave-raw
# generate RESTful API spec
- go get github.com/swaggo/swag/cmd/swag
- bash Taskfile.sh ci-swagger-gen
# generate code report
- go get github.com/jstemmer/go-junit-report
- go test -v $(go list ./... | grep -v /src/)
- go test -v $(go list ./... | grep -v /src/) 2>&1 | go-junit-report > $CI_PROJECT_DIR/report.xml
# tests at the end to still allow artifacts uploading
- go fmt $(go list ./... | grep -v /src/) || true
- go vet $(go list ./... | grep -v /src/)
# binaries built and tested, upload binary and install script, cleanup old files after
- bash Taskfile.sh ci-slave-upload
cache:
key: "$CI_JOB_NAME-src"
paths:
- $GOPATH/src
artifacts:
# https://docs.gitlab.com/ee/ci/yaml/README.html#artifactsreportscodequality-starter
reports:
junit: report.xml
paths:
- aimpanel-master
- aimpanel-slave
- swagger.json
- report.xml
when: always
only:
- master
- merge_requests
tags:
- docker
redis:
stage: compile
image: ubuntu:18.04
variables:
# https://hub.docker.com/_/redis/?tab=tags
REDIS_VERSION: "6.0.6"
REDIS_DOWNLOAD_URL: "http://download.redis.io/releases/redis-6.0.6.tar.gz"
REDIS_DOWNLOAD_SHA: "1e3ab1524498d0922d3ceeada5233d8d35b94d229baa1f8a867edcd0ddaa9199"
script:
- bash Taskfile.sh ci-redis-compile
- bash Taskfile.sh ci-redis-upload
artifacts:
paths:
- redis-server
tags:
- docker
when: manual
docker-image:
stage: build
image: docker:stable
services:
- docker:stable-dind
variables:
# Use TLS https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#tls-enabled
DOCKER_HOST: tcp://docker:2376
DOCKER_TLS_CERTDIR: "/certs"
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker build --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA .
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
only:
- master
- merge_requests
tags:
- docker
.deploy:
stage: deploy
image: alpine:latest
script:
- apk add --no-cache curl git bash gawk
- curl -X POST -F token=$INFRA_TOKEN -F "ref=master" -F "variables[SERVICE_NAME]=aimpanel-lab" -F "variables[SERVICE_VERSION]=pipeline-$CI_PIPELINE_ID" https://gitlab.com/api/v4/projects/6986946/trigger/pipeline
#- bash Taskfile.sh update-todo-issue
only:
- master