Skip to content

Commit 6833620

Browse files
committed
ci(gitlab-ci): improve caching for bundler and test_conversion job
1 parent b268512 commit 6833620

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

.gitlab-ci.yml

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,23 @@
3030
variables_bundler: &variables_bundler
3131
BUNDLE_CACHE_PATH: '${CI_PROJECT_DIR}/.cache/bundler'
3232
BUNDLE_WITHOUT: 'production'
33-
# `cache`
3433
cache_bundler: &cache_bundler
35-
key: '${CI_JOB_STAGE}'
34+
key:
35+
files:
36+
- 'Gemfile.lock'
37+
prefix: 'bundler'
3638
paths:
3739
- '${BUNDLE_CACHE_PATH}'
40+
# https://pre-commit.com/#gitlab-ci-example
41+
variables_pre-commit: &variables_pre-commit
42+
PRE_COMMIT_HOME: '${CI_PROJECT_DIR}/.cache/pre-commit'
43+
cache_pre-commit: &cache_pre-commit
44+
key:
45+
files:
46+
- '.pre-commit-config.yaml'
47+
prefix: 'pre-commit'
48+
paths:
49+
- '${PRE_COMMIT_HOME}'
3850

3951
###############################################################################
4052
# Define stages and global variables
@@ -78,15 +90,8 @@ pre-commit:
7890
stage: *stage_lint
7991
image: *image_precommit
8092
# https://pre-commit.com/#gitlab-ci-example
81-
variables:
82-
PRE_COMMIT_HOME: '${CI_PROJECT_DIR}/.cache/pre-commit'
83-
cache:
84-
key:
85-
files:
86-
- .pre-commit-config.yaml
87-
prefix: pre-commit
88-
paths:
89-
- '${PRE_COMMIT_HOME}'
93+
variables: *variables_pre-commit
94+
cache: *cache_pre-commit
9095
script:
9196
- 'pre-commit run --all-files --color always --verbose'
9297
- 'pre-commit run --color always --hook-stage manual commitlint-ci'
@@ -137,8 +142,13 @@ rubocop:
137142
stage: *stage_test
138143
image: *image_dindrubybionic
139144
services: *services_docker_dind
140-
variables: *variables_bundler
141-
cache: *cache_bundler
145+
variables:
146+
<<: [*variables_bundler, *variables_pre-commit]
147+
cache:
148+
- <<: *cache_bundler
149+
policy: 'pull'
150+
- <<: *cache_pre-commit
151+
policy: 'pull'
142152
before_script:
143153
- 'export CONVERTED=test-the-use_this_template-button'
144154
- 'git clone . /tmp/"${CONVERTED}"-formula'

0 commit comments

Comments
 (0)