-
Notifications
You must be signed in to change notification settings - Fork 2
/
.drone.yml
206 lines (175 loc) · 6.27 KB
/
.drone.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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# -----------------------------------------------------------------------------
# SETTINGS
# -----------------------------------------------------------------------------
# Drone matrix: Additional ENV vars for substitution - http://docs.drone.io/matrix-builds/
# Will be evaluated BEFORE the YAML is parsed, ONLY strings allowed, NO substitutions ${XXX} here.
matrix:
include:
- BUILD_ENV: all
# YAML Configuration anchors - https://learnxinyminutes.com/docs/yaml/
# Will be evaluated WHILE the YAML is parsed, any valid yaml allowed, substitutions ${XXX} allowed.
alias:
# ENV variables for executing yarn:test (typically only the DB connector is relevant)
- &TEST_ENV
CI: ${CI}
PGHOST: &PGHOST database
PGUSER: &PGUSER postgres
PGPASSWORD: &PGPASSWORD test
PGDATABASE: &PGDATABASE test
# Which build events should trigger the main pipeline (defaults to all)
- &BUILD_EVENTS [push, pull_request, tag]
# Pipeline merge helper: only execute if build event received
- &WHEN_BUILD_EVENT
when:
event: *BUILD_EVENTS
# The actual pipeline building our product
pipeline:
# ---------------------------------------------------------------------------
# BUILD Monorepo
# ---------------------------------------------------------------------------
"docker build":
group: build-monorepo
image: docker:latest
volumes:
- /var/run/docker.sock:/var/run/docker.sock
commands:
- "docker build --compress -t ${DRONE_REPO,,}-monorepo ."
<<: *WHEN_BUILD_EVENT
"bootstrap":
group: bootstrap
image: ${DRONE_REPO,,}-monorepo
commands:
- node -v
- npm -v
- yarn --version
- yarn bootstrap
<<: *WHEN_BUILD_EVENT
"build":
group: pre-check
image: ${DRONE_REPO,,}-monorepo
commands:
- yarn tsc
- yarn tsc-sync
<<: *WHEN_BUILD_EVENT
"database connection":
group: pre-check
image: postgres:alpine
commands:
# wait for postgres service to become available
- |
until psql -U $PGUSER -d $PGDATABASE -h database \
-c "SELECT 1;" >/dev/null 2>&1; do sleep 1; done
# query the database
- |
psql -U $PGUSER -d $PGDATABASE -h database \
-c "SELECT name, setting FROM pg_settings;"
environment: *TEST_ENV
<<: *WHEN_BUILD_EVENT
# ---------------------------------------------------------------------------
# CHECK Monorepo
# ---------------------------------------------------------------------------
# "npm audit":
# group: check-monorepo
# image: ${DRONE_REPO,,}-monorepo
# commands:
# - "synp --source-file yarn.lock" # setup a package-lock.json
# - "npm audit --registry=https://registry.npmjs.org || true" # run audit with lock from above
# environment: *TEST_ENV
# <<: *WHEN_BUILD_EVENT
# "yarn audit":
# group: check-monorepo
# image: ${DRONE_REPO,,}-monorepo
# commands:
# # "yarn audit" currently fails with 503 on monorepos
# # see https://github.com/yarnpkg/yarn/issues/7025
# - "yarn audit --registry=https://registry.npmjs.org || true" # run audit with lock from above
# environment: *TEST_ENV
# <<: *WHEN_BUILD_EVENT
"test":
group: check-monorepo
image: ${DRONE_REPO,,}-monorepo
commands:
# use _test to prevent concurrent rimraf and cabgen copy execution
- yarn _test
- yarn _coverage:summary
environment: *TEST_ENV
<<: *WHEN_BUILD_EVENT
"lint":
group: check-monorepo
image: ${DRONE_REPO,,}-monorepo
commands:
- yarn lint
<<: *WHEN_BUILD_EVENT
"check-package-validity":
group: check-monorepo
image: ${DRONE_REPO,,}-monorepo
commands:
- yarn check-package-validity && git status
# error out if our git is no longer clean!
- git diff --exit-code
<<: *WHEN_BUILD_EVENT
"create-aaa-backend":
group: check-monorepo
image: ${DRONE_REPO,,}-monorepo
commands:
- cd packages/create-aaa-backend
- yarn create-aaa-backend-local-monorepo
# don't reuse the monorepos node_modules
# fully reinstall from the current latest.
- rm -rf aaa-backend/node_modules
<<: *WHEN_BUILD_EVENT
# ---------------------------------------------------------------------------
# LERNA
# ---------------------------------------------------------------------------
"lerna updated":
group: post-check
image: ${DRONE_REPO,,}-monorepo
commands:
- lerna updated
<<: *WHEN_BUILD_EVENT
# ---------------------------------------------------------------------------
# BUILD scaffolded project
# ---------------------------------------------------------------------------
"docker build (scaffolded template)":
group: post-check
image: docker:latest
volumes:
- /var/run/docker.sock:/var/run/docker.sock
commands:
- "cd packages/create-aaa-backend/aaa-backend"
- "docker build --compress -t ${DRONE_REPO,,}-template:${DRONE_COMMIT_SHA} ."
# ---------------------------------------------------------------------------
# CHECK scaffolded project
# ---------------------------------------------------------------------------
"test (scaffolded template)":
group: check-template
image: "${DRONE_REPO,,}-template:${DRONE_COMMIT_SHA}"
commands:
- cd /app
- yarn test:nocheck
- yarn coverage:summary
environment: *TEST_ENV
"lint (scaffolded template)":
group: check-template
image: "${DRONE_REPO,,}-template:${DRONE_COMMIT_SHA}"
commands:
- cd /app
- yarn lint
# Long living services where the startup order does not matter (otherwise use detach: true)
services:
# ---------------------------------------------------------------------------
# SERVICES
# ---------------------------------------------------------------------------
"env":
image: alpine
commands:
- "env | sort"
"database":
image: postgres:alpine
environment:
POSTGRES_USER: *PGUSER
POSTGRES_PASSWORD: *PGPASSWORD
POSTGRES_DB: *PGDATABASE
# Apply some performance improvements to pg as these guarantees are not needed while running integration tests
command: "-c 'shared_buffers=128MB' -c 'fsync=off' -c 'synchronous_commit=off' -c 'full_page_writes=off' -c 'max_connections=100' -c 'client_min_messages=warning'"
<<: *WHEN_BUILD_EVENT