-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
113 lines (101 loc) · 2.68 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
---
image: golang:latest
services:
- postgres:latest
variables:
REPO_NAME: gitlab.cs.ui.ac.id/ppl-fasilkom-ui/2022/Kelas-B/OOP/majapahit-service
POSTGRES_DB: $DB_NAME
POSTGRES_USER: $DB_USERNAME
POSTGRES_PASSWORD: $DB_PASSWORD
POSTGRES_HOST_AUTH_METHOD: trust
before_script:
- mkdir -p $GOPATH/src/$(dirname $REPO_NAME)
- ln -svf $CI_PROJECT_DIR $GOPATH/src/$REPO_NAME
- cd $GOPATH/src/$REPO_NAME
stages:
- formatter
- quality
- test
- build
- deploy
Test:
stage: test
script:
- go test -v $(go list ./... | grep -v ./main.go | grep -v /vendor/)
- go test $(go list ./... | grep -v ./main.go | grep -v /vendor/) -coverprofile=coverage.out && go tool cover -func coverage.out
Formater:
stage: formatter
script:
- go fmt $(go list ./... | grep -v /vendor/)
Linter:
stage: quality
image: registry.gitlab.com/pipeline-components/go-lint:latest
script:
- golint -set_exit_status ./...
SonarScanner Dev:
image:
name: sonarsource/sonar-scanner-cli:latest
entrypoint: [ '' ]
stage: quality
script:
- sonar-scanner
-Dsonar.host.url=$SONARQUBE_HOST_URL
-Dsonar.login=$SONARQUBE_TOKEN
-Dsonar.branch.name=$CI_COMMIT_REF_NAME
-Dsonar.branch.target=staging
-Dsonar.projectKey=$SONARQUBE_PROJECT_KEY
-Dproject.settings=./sonar-project.properties
except:
- master
- staging
SonarScanner:
image:
name: sonarsource/sonar-scanner-cli:latest
entrypoint: [ '' ]
stage: quality
script:
- sonar-scanner
-Dsonar.host.url=$SONARQUBE_HOST_URL
-Dsonar.login=$SONARQUBE_TOKEN
-Dsonar.branch.name=$CI_COMMIT_REF_NAME
-Dsonar.projectKey=$SONARQUBE_PROJECT_KEY
-Dproject.settings=./sonar-project.properties
only:
- master
- staging
Build:
stage: build
image: golang:latest
script:
- go get -d -v
- go build -o bin/majapahit-service -v .
only:
- master
- staging
- merge_requests
Deployment:
rules:
- if: '$CI_COMMIT_REF_NAME == "master"'
image: ruby:2.7
stage: deploy
before_script:
- gem install dpl
- wget -qO- https://cli-assets.heroku.com/install-ubuntu.sh | sh
script:
- dpl --provider=heroku --app=$HEROKU_APP_NAME --api-key=$HEROKU_API_KEY
environment:
name: production
url: https://$HEROKU_APP_NAME.herokuapp.com
Deployment Staging:
rules:
- if: '$CI_COMMIT_REF_NAME == "staging"'
image: ruby:2.7
stage: deploy
before_script:
- gem install dpl
- wget -qO- https://cli-assets.heroku.com/install-ubuntu.sh | sh
script:
- dpl --provider=heroku --app=$HEROKU_APP_NAME_STAGING --api-key=$HEROKU_API_KEY
environment:
name: staging
url: https://$HEROKU_APP_NAME_STAGING.herokuapp.com