This repository has been archived by the owner on Sep 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
97 lines (88 loc) · 2.93 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
image: ruby:3.0.2
cache:
paths:
- vendor/
variables:
DEVISE_SECRET: secret
DISABLE_PROMETHEUS: "true"
DOCKER_DRIVER: overlay2
DOCKER_HOST: tcp://docker:2375
ELASTICSEARCH_URL: "http://localhost:9200"
JWT_ENCRYPTION_TOKEN: secret
POSTGRES_PASSWORD: password
POSTGRES_USER: postgres
POSTGRESQL_ADDRESS: postgres
POSTGRESQL_PASSWORD: password
POSTGRESQL_USERNAME: postgres
SECRET_KEY_BASE: secret
default:
before_script:
- apt-get update -qq && apt-get install -y -qq libvips libvips-dev
- bundle install --deployment --path vendor/bundle
- bundle exec rake db:create
- bundle exec rake db:schema:load
- bundle exec rake db:test:prepare
build:
stage: build
image: docker:18.09.8
services:
- docker:18.09.8-dind
- postgres:12
before_script:
- echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" "$CI_REGISTRY" --password-stdin
script:
- docker pull $CI_REGISTRY_IMAGE:latest || true
- docker build --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA --tag $CI_REGISTRY_IMAGE:latest .
- docker run --network host --env APARTMENT_DISABLE_INIT=true --env DISABLE_PROMETHEUS=true --env POSTGRESQL_ADDRESS --env POSTGRESQL_DATABASE=test --env RAILS_ENV=production --env REDIS_URL=$REDIS_URL --env SECRET_KEY_BASE=secret --env DEVISE_SECRET=secret $CI_REGISTRY_IMAGE:latest ./bin/rails runner "puts 'succeeded'"
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
- docker push $CI_REGISTRY_IMAGE:latest
codeQuality:
stage: test
before_script:
- gem install brakeman
- gem install bundle-audit
- gem install rubocop -v 0.92.0
- gem install rubocop-rails -v 2.5.2
- gem install rubocop-rspec -v 1.39.0
script:
- brakeman -z
- rubocop
- bundle-audit update && bundle-audit check --ignore CVE-2015-9284
spec:
stage: test
services:
- redis:6
- postgres:12
- name: docker.elastic.co/elasticsearch/elasticsearch:6.7.2
alias: elasticsearch
command: [ "bin/elasticsearch", "-Expack.security.enabled=false", "-Ediscovery.type=single-node" ]
script:
- bundle exec license_finder
- bundle exec rake spec
test:
stage: test
services:
- redis:6
- postgres:12
- name: docker.elastic.co/elasticsearch/elasticsearch:6.7.2
alias: elasticsearch
command: [ "bin/elasticsearch", "-Expack.security.enabled=false", "-Ediscovery.type=single-node" ]
script:
- MINITEST_REPORTER=CustomReporter bundle exec rake test
tag:
stage: tag
rules:
- if: $CI_COMMIT_TAG
image: docker:18.09.8
services:
- docker:18.09.8-dind
before_script:
- echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" "$CI_REGISTRY" --password-stdin
script:
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
stages:
- build
- tag
- test