Newer
Older
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
image: docker:latest
variables:
DOCKER_DRIVER: overlay2
IMAGE_NAME: gitlab.nexdev.uk:5555/web-dev/users
stages:
- prebuild
- build
- testing
- release
- deploy
docker_lint:
stage: prebuild
image: hadolint/hadolint:latest-debian
script:
# Ignoring DL3008 - Pin Versions of apt-get modules
- hadolint --ignore DL3008 Dockerfile
tags:
- nexus_runner
build_image:
stage: build
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN gitlab.nexdev.uk:5555
- docker build -t $IMAGE_NAME:$CI_COMMIT_SHA .
- docker push $IMAGE_NAME:$CI_COMMIT_SHA
tags:
- nexus_runner
rubocop_lint:
variables:
PRONTO_GITLAB_API_ENDPOINT: "https://gitlab.nexdev.uk/api/v4"
stage: testing
image: $IMAGE_NAME:$CI_COMMIT_SHA
script:
- cd /builds/web-dev/users
- git fetch
# - bundle exec pronto run -c=origin/master --exit-code -f gitlab
tags:
- nexus_runner
dependency_scanning:
stage: testing
image: ruby:2.6.2
allow_failure: true
script:
- gem install bundler-audit
- bundle audit check --update
artifacts:
paths: [gl-dependency-scanning-report.json]
tags:
- nexus_runner
test:unit:
stage: testing
image: $IMAGE_NAME:$CI_COMMIT_SHA
services:
- name: postgres:12.2
alias: user_db
- name: mysql:5.6
alias: mysql
variables:
# Set variables for the MySQL image
FW_DB_TEST_HOST: mysql
MYSQL_DATABASE: nexus_api_forum_test
MYSQL_USER: runner
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: password
OTP_ENC_KEY: 'avQrhpsxSNtx26xdM6M65Z7KUARctq5z'
TWILIO_NUMBER: '+15005550006'
TWILIO_SID: 'ACe28fd8b14f682e46536a3a2910f5ea0e'
TWILIO_TOKEN: 'd117d8463ebf05cf8ed5b9584b1a6d66'
POSTGRES_PASSWORD: password
script:
- bundle exec rake db:create RAILS_ENV=test
- bundle exec rake db:migrate RAILS_ENV=test
- bundle exec rake fw_test_db:import_forum RAILS_ENV=test
- COVERAGE=true bundle exec rspec --format documentation
tags:
- nexus_runner
test:integration:
stage: testing
image: $IMAGE_NAME:$CI_COMMIT_SHA
allow_failure: true
services:
- name: postgres:12.2
alias: user_db
- name: mysql:5.6
alias: mysql
variables:
# Set variables for the MySQL image
FW_DB_TEST_HOST: mysql
MYSQL_DATABASE: nexus_api_forum_test
MYSQL_USER: runner
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: password
OTP_ENC_KEY: 'avQrhpsxSNtx26xdM6M65Z7KUARctq5z'
TWILIO_NUMBER: '+15005550006'
TWILIO_SID: 'ACe28fd8b14f682e46536a3a2910f5ea0e'
TWILIO_TOKEN: 'd117d8463ebf05cf8ed5b9584b1a6d66'
POSTGRES_PASSWORD: password
script:
- bundle exec rake db:create RAILS_ENV=test
- bundle exec rake db:migrate RAILS_ENV=test
- bundle exec rake fw_test_db:import_forum RAILS_ENV=test
- bundle exec rspec --format documentation --tag integration
tags:
- nexus_runner
release:version:
image: gitlab.nexdev.uk:5555/pub/nexus-release-image/master
stage: release
before_script:
- eval $(ssh-agent -s)
- echo "$CI_DEPLOY_KEY" | tr -d '\r' | ssh-add -
- ssh-keyscan gitlab.nexdev.uk >> ~/.ssh/known_hosts
script:
- /build/release.sh
tags:
- nexus_runner
only:
- master
release_staging:
stage: release
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN gitlab.nexdev.uk:5555
- docker tag $IMAGE_NAME:$CI_COMMIT_SHA $IMAGE_NAME:staging
- docker push $IMAGE_NAME:$CI_COMMIT_SHA
- docker push $IMAGE_NAME:staging
only:
- staging
tags:
- nexus_runner
deploy_staging:
stage: deploy
image: nexusmods/gitlab-ci-kube-deploy
script:
- mkdir /root/.kube
- echo "$STAGING_KUBE_CONFIG" > /root/.kube/config
- kubectl apply -f deploy/staging
- kubectl -n staging-nexus set image deployment/users users=$IMAGE_NAME:$CI_COMMIT_SHA
environment: staging
when: manual
except:
- master
tags:
- nexus_runner
release:
stage: release
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN gitlab.nexdev.uk:5555
- docker tag $IMAGE_NAME:$CI_COMMIT_SHA $IMAGE_NAME:latest
- docker push $IMAGE_NAME:$CI_COMMIT_SHA
- docker push $IMAGE_NAME:latest
only:
- release
- master
tags:
- nexus_runner
deploy_production:
stage: deploy
image: nexusmods/gitlab-ci-kube-deploy
script:
- mkdir /root/.kube
- echo "$KUBE_CONFIG" > /root/.kube/config
- kubectl apply -f deploy/production
- kubectl -n production set image deployment/users users=$IMAGE_NAME:$CI_COMMIT_SHA
environment: production
only:
- master
tags:
- nexus_runner