This repository has been archived by the owner on Jul 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
circle.yml
140 lines (115 loc) · 3.14 KB
/
circle.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
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
app_image: &app_image
docker:
- image: circleci/ruby:2.5-node
environment:
RAILS_ENV: test
DB_HOST: localhost
DB_PORT: 5432
DB_NAME: projectname_test
DB_USERNAME: postgres
DB_PASSWORD: postgres
SECRET_KEY_BASE: SECRET_KEY_BASE
DEVISE_SECRET_KEY: DEVISE_SECRET_KEY
- image: circleci/postgres:9.6
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: projectname_test
deploy_image: &deploy_image
docker:
- image: circleci/python:3.7
caches:
- &bundle_cache projectname-bundle-v1-{{ checksum "Gemfile.lock" }}
- &docker_images_cache projectname-docker-v1-{{ checksum "Gemfile.lock" }}-{{ checksum "Dockerfile" }}
- &deploy_dependencies_cache projectname-pip-v1-{{ checksum "config/deploy/dependencies.txt" }}
steps:
- &restore_bundle_cache
restore_cache:
name: Restore bundle cache
keys:
- *bundle_cache
- &store_bundle_cache
save_cache:
name: Store bundle cache
key: *bundle_cache
paths:
- vendor/bundle
- &restore_docker_images_cache
restore_cache:
name: Restore docker images cache
keys:
- *docker_images_cache
- &store_docker_images_cache
save_cache:
name: Store docker images cache
key: *docker_images_cache
paths:
- images
- &load_docker_image
run:
name: Load Docker image layer cache
command: set +o pipefail && docker load -i images/spreeproject_server_app-$CIRCLE_BRANCH.tar | true
- &save_docker_image
run:
name: Save Docker image layer cache
command: mkdir -p images && docker save -o images/spreeproject_server_app-$CIRCLE_BRANCH.tar spreeproject_server_app:$CIRCLE_BRANCH
- &restore_deploy_dependencies_cache
restore_cache:
name: Restore deploy dependecies
keys:
- *deploy_dependencies_cache
- &store_deploy_dependencies_cache
save_cache:
name: Store deploy dependecies
key: *deploy_dependencies_cache
paths:
- venv
- &bundle_install
run: bundle install --path vendor/bundle
- &migrate_db
run: bundle exec rails db:migrate
- &run_test
run:
name: Run tests
command: bundle exec rspec --color -f d spec
- &deploy
run:
name: Deploy
command: config/deploy/$CIRCLE_BRANCH.sh
version: 2
jobs:
build_and_test:
<<: *app_image
steps:
- checkout
- *restore_bundle_cache
- *bundle_install
- *store_bundle_cache
- *migrate_db
- *run_test
deploy:
<<: *deploy_image
steps:
- checkout
- setup_remote_docker
- *restore_deploy_dependencies_cache
- *restore_docker_images_cache
- *load_docker_image
- *deploy
- *save_docker_image
- *store_docker_images_cache
- *store_deploy_dependencies_cache
workflows:
version: 2
build:
jobs:
- build_and_test
- deploy:
requires:
- build_and_test
filters:
branches:
only:
- dev
- staging
- production