-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci.yml
115 lines (105 loc) · 2.96 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
variables:
FF_GITLAB_REGISTRY_HELPER_IMAGE: 1
stages:
- test
- deploy
# Stage: test
##############################################################################
staticcheck:
stage: test
image: golang:1.21-bullseye
before_script:
- go install honnef.co/go/tools/cmd/[email protected]
script:
- staticcheck ./...
test:
stage: test
image: golang:1.21-bullseye
variables:
GOPATH: $CI_PROJECT_DIR/.go
POSTGRES_DB: testvillasdb
POSTGRES_USER: villas
POSTGRES_PASSWORD: villas
POSTGRES_HOST: postgres
RABBITMQ_DEFAULT_USER: villas
RABBITMQ_DEFAULT_PASS: villas
MINIO_ROOT_USER: minio-villas
MINIO_ROOT_PASSWORD: minio-villas
MINIO_REGION_NAME: default
AWS_ACCESS_KEY_ID: ${MINIO_ROOT_USER}
AWS_SECRET_ACCESS_KEY: ${MINIO_ROOT_PASSWORD}
S3_BUCKET: villas-web
S3_ENDPOINT: http://minio:9000
S3_PATHSTYLE: 'true'
S3_NOSSL: 'false'
S3_REGION: ${MINIO_REGION_NAME}
AMQP_HOST: rabbitmq:5672
AMQP_USER: villas
AMQP_PASS: villas
PORT: 4000
DB_NAME: ${POSTGRES_DB}
DB_HOST: ${POSTGRES_HOST}
DB_USER: ${POSTGRES_USER}
DB_PASS: ${POSTGRES_PASSWORD}
BASE_PATH: /api
MODE: release
services:
- postgres:12
- rabbitmq:3.8
- name: minio/minio:RELEASE.2021-01-16T02-19-44Z
command: ['server', '/minio']
alias: minio
before_script:
- mkdir -p .go
- wget -qO /usr/bin/mc https://dl.min.io/client/mc/release/linux-amd64/mc && chmod +x /usr/bin/mc
- mc alias set gitlab http://minio:9000 ${MINIO_ROOT_USER} ${MINIO_ROOT_PASSWORD}
- mc mb gitlab/${S3_BUCKET}
script:
- go mod tidy
- go get github.com/swaggo/swag/cmd/[email protected]
- go install github.com/swaggo/swag/cmd/swag
- ${GOPATH}/bin/swag init --propertyStrategy pascalcase
--generalInfo "start.go"
--output "./doc/api/"
--parseDependency
--parseInternal
--parseVendor
--parseDepth 2
- go build
- go test $(go list ./... )
-p 1
-v
-covermode=count
-coverprofile ./testcover.txt
- go tool cover -func=testcover.txt
# test file package without S3 object storage (minio)
- cd routes/file
- S3_BUCKET="" go test -v
- cd ../../
# Stage: deploy
##############################################################################
deploy:
stage: deploy
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [ "" ]
variables:
DOCKER_TAG: ${CI_COMMIT_BRANCH}
script:
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"${CI_REGISTRY}\":{\"username\":\"${CI_REGISTRY_USER}\",\"password\":\"${CI_REGISTRY_PASSWORD}\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor
--context ${CI_PROJECT_DIR}
--dockerfile ${CI_PROJECT_DIR}/Dockerfile
--destination ${CI_REGISTRY_IMAGE}:${DOCKER_TAG}
--snapshotMode=redo
--single-snapshot
dependencies:
- test
deploy.latest:
variables:
DOCKER_TAG: latest
extends: deploy
only:
refs:
- master