forked from dependabot/dependabot-core
-
Notifications
You must be signed in to change notification settings - Fork 3
/
config.yml
169 lines (149 loc) · 5.53 KB
/
config.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
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
version: 2
jobs:
build_and_test_reorg:
docker:
# Any image that includes the docker client will do
- image: circleci/ruby
steps:
- checkout
- setup_remote_docker
- run:
name: Log in to the Docker registry
command: |
if [ -n "$DOCKER_USER" ] && [ -n "$DOCKER_PASSWORD" ]; then
docker login -u "$DOCKER_USER" -p "$DOCKER_PASSWORD"
else
echo "No Docker credentials, skipping login"
fi
- run:
name: Prepare environment variables
command: |
BRANCH_TAG="$(echo $CIRCLE_BRANCH | sed -E 's/[^A-Za-z0-9]+/-/g')"
echo "export BRANCH_TAG='$BRANCH_TAG'" >> $BASH_ENV
VERSION="$(grep -Eo "[0-9]+\.[0-9]+\.[0-9]+" common/lib/dependabot/version.rb)"
echo "export VERSION='$VERSION'" >> $BASH_ENV
- run:
name: Pull Docker base images & warm Docker cache
command: |
docker pull ubuntu:18.04
docker pull "dependabot/dependabot-core-ci:core--$BRANCH_TAG" ||
docker pull "dependabot/dependabot-core:latest"
docker pull "dependabot/dependabot-core-ci:ci--$BRANCH_TAG" ||
docker pull "dependabot/dependabot-core-ci:latest" || true
- run:
name: Build dependabot-core image
command: |
docker build \
-t "dependabot/dependabot-core:latest" \
-t "dependabot/dependabot-core:$VERSION" \
-t "dependabot/dependabot-core-ci:core--$BRANCH_TAG" \
--cache-from ubuntu:18.04 \
--cache-from "dependabot/dependabot-core-ci:core--$BRANCH_TAG" \
--cache-from "dependabot/dependabot-core:latest" \
.
- run:
name: Push dependabot-core image to CI cache repo
command: |
if [ -n "$DOCKER_USER" ] && [ -n "$DOCKER_PASSWORD" ]; then
docker push "dependabot/dependabot-core-ci:core--$BRANCH_TAG"
else
echo "No Docker credentials, skipping push"
fi
- run:
name: Build dependabot-core-ci image
command: |
rm .dockerignore # we usually don't want tests etc, but here we do
docker build \
-t "dependabot/dependabot-core-ci:latest" \
-t "dependabot/dependabot-core-ci:ci--$BRANCH_TAG" \
-f Dockerfile.ci \
--cache-from ubuntu:18.04 \
--cache-from "dependabot/dependabot-core:latest" \
--cache-from "dependabot/dependabot-core-ci:ci--$BRANCH_TAG" \
--cache-from "dependabot/dependabot-core-ci:latest" \
.
- run:
name: Rubocop
command: |
docker run \
--env "CIRCLE_COMPARE_URL=$CIRCLE_COMPARE_URL" \
-ti dependabot/dependabot-core-ci \
bash -c "rake ci:rubocop"
- run:
name: RSpec
command: |
docker run \
--env "CIRCLE_COMPARE_URL=$CIRCLE_COMPARE_URL" \
-ti dependabot/dependabot-core-ci \
bash -c "rake ci:rspec"
- run:
name: Push dependabot-core image to Docker hub, if on master
command: |
if [ -n "$DOCKER_USER" ] && [ -n "$DOCKER_PASSWORD" ]; then
if [ "${CIRCLE_BRANCH}" == "master" ]; then
echo "Pushing dependabot-core:{latest,$VERSION}} to registry"
docker push "dependabot/dependabot-core:$VERSION"
docker push "dependabot/dependabot-core:latest"
else
echo "Not on master, skipping deployment"
fi
else
echo "No Docker credentials, skipping push"
fi
- run:
name: Push dependabot-core-ci image to CI cache repo
command: |
if [ -n "$DOCKER_USER" ] && [ -n "$DOCKER_PASSWORD" ]; then
docker push "dependabot/dependabot-core-ci:ci--$BRANCH_TAG"
docker push "dependabot/dependabot-core-ci:latest"
else
echo "No Docker credentials, skipping push"
fi
test_core:
docker:
- image: dependabot/dependabot-core:0.1.47
working_directory: ~/dependabot-core
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ .Branch }}
- v1-dependencies-master
# Install dependencies
- run: cd npm_and_yarn/helpers && yarn install
- save_cache:
key: v1-dependencies-{{ .Branch }}-{{ epoch }}
paths:
- ~/dependabot-core/npm_and_yarn/helpers/node_modules
# Run code formatting linters
- run: cd npm_and_yarn/helpers && yarn lint
# Run tests
- run: cd npm_and_yarn/helpers && yarn test
- store_test_results:
path: ~/rspec
- store_artifacts:
path: ~/rspec
release_gems:
docker:
- image: dependabot/dependabot-core:latest
working_directory: ~/dependabot-core
steps:
- checkout
- run: |
[ -d ~/.gem ] || mkdir ~/.gem
echo "---" > ~/.gem/credentials
echo ":rubygems_api_key: $RUBYGEMS_API_KEY" > ~/.gem/credentials
chmod 0600 ~/.gem/credentials
- run: gem install rake && rake gems:release
workflows:
version: 2
test:
jobs:
- test_core
- build_and_test_reorg
- release_gems:
filters:
branches:
ignore: /.*/
tags:
only: /^v[0-9]+\.[0-9]+\.[0-9]+$/