-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathMakefile.toml
414 lines (348 loc) · 11.1 KB
/
Makefile.toml
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
# Copyright 2015-2019 Benjamin Fry <[email protected]>
#
# Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
# http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
# http://opensource.org/licenses/MIT>, at your option. This file may not be
# copied, modified, or distributed except according to those terms.
# This is a Makefile for `cargo make`, to use it first install cargo-make with `cargo install cargo-make`
[config]
skip_core_tasks = true
on_error_task = "on_error"
[config.modify_core_tasks]
# if true, all core tasks are set to private (default false)
private = true
## General environment configuration
[env]
TARGET_DIR = "${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target"
CARGO_MAKE_WORKSPACE_TARGET_DIRECTORY = "${TARGET_DIR}"
CARGO_MAKE_WORKSPACE_SKIP_MEMBERS = "examples/*"
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = "true"
CARGO_MAKE_KCOV_INSTALLATION_DIRECTORY = "${TARGET_DIR}/kcov"
CARGO_MAKE_KCOV_DOWNLOAD_DIRECTORY = "${TARGET_DIR}/kcov-dl"
CARGO_MAKE_KCOV_VERSION = "37"
# This can be overriden (e.g. in pg-extend crate) to specify a more limited set of features
# because we use features for enabling different versions of pg, this should not be --all-features in general
#ALL_FEATURES = ""
# Defaults are all for postgres version 12
PG_VERSION = { source = "${CARGO_MAKE_PROFILE}", default_value = "12.1", mapping = { v10 = "10.11", v11 = "11.6" }}
PGPORT = { source = "${CARGO_MAKE_PROFILE}", default_value = "5444", mapping = { v10 = "5442", v11 = "5443" }}
PGSERVICE = { unset = true }
PGHOST = "/tmp/"
PGDATABASE = "postgres"
PSQLRC = "/dev/null" # This ensures that every psql invocation will skip the user's .psqlrc file"
ALL_FEATURES = { source = "${CARGO_MAKE_PROFILE}", default_value = "", mapping = { v10 = "--features=fdw", v11 = "--features=fdw" }}
PG_DIR = "${TARGET_DIR}/postgres"
PG_DL_DIR = "${PG_DIR}"
PG_BUILD_DIR = "${PG_DIR}/postgres_build_${PG_VERSION}"
PG_INSTALL_DIR = "${PG_DIR}/postgres_${PG_VERSION}"
PG_BIN_DIR = "${PG_INSTALL_DIR}/bin"
PG_DB_DIR = "${TARGET_DIR}/postgres_db_${PG_VERSION}"
POSTGRES_TEST_DB = "pg_extend_rs_test_db"
PG_LOGPATH = "${TARGET_DIR}/postgres-${PG_VERSION}.log"
PATH = "${PG_BIN_DIR}:${PATH}"
PG_CONFIG = "${PG_BIN_DIR}/pg_config"
##
## Installation tasks
##
[tasks.install-openssl]
description = "Installs OpenSSL on Windows"
workspace = false
env = { OPENSSL_VERSION = "1_1_1d", OPENSSL_DIR = "${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}\\target\\OpenSSL" }
condition = { platforms = ["windows"], files_not_exist = ["${OPENSSL_DIR}"] }
script_runner = "powershell"
script_extension = "ps1"
script = [
'''
mkdir ${env:CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}\\target
mkdir ${env:CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}\\target\OpenSSL
Invoke-WebRequest -URI "http://slproweb.com/download/Win64OpenSSL-${env:OPENSSL_VERSION}.exe" -OutFile "${env:CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}\target\OpenSSL.exe"
Start-Process -FilePath "${env:CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}\target\OpenSSL.exe" -ArgumentList "/SILENT /VERYSILENT /SP- /DIR=${env:OPENSSL_DIR}"
Invoke-WebRequest "https://curl.haxx.se/ca/cacert.pem" -O "${env:OPENSSL_DIR}\cacert.pem"
'''
]
[tasks.install-postgres]
description = "Installs Postgres"
workspace = false
windows_alias = "empty"
script_runner = "@shell"
script = [
'''
set -e
if ${PG_BIN_DIR}/postgres --version ; then exit 0 ; fi
echo "Installing Postgres ${PG_VERSION:?} into ${PG_INSTALL_DIR:?}"
# download
PG_DL_PATH="${PG_DL_DIR:?}/postgres_${PG_VERSION}.tar.bz2"
PG_URL=https://ftp.postgresql.org/pub/source/v${PG_VERSION:?}/postgresql-${PG_VERSION:?}.tar.bz2
if ! [ -f "${PG_DL_PATH:?}" ]; then
echo "Retrieving ${PG_URL:?}"
mkdir -p ${PG_DL_DIR:?}
curl -s -o ${PG_DL_PATH:?} ${PG_URL:?}
fi
# build
echo "Building ${PG_BUILD_DIR:?}"
mkdir -p ${PG_BUILD_DIR:?}
current_dir=${PWD}
cd ${PG_BUILD_DIR:?}
bunzip2 -k -d -f ${PG_DL_PATH:?}
PG_TAR_PATH="${PG_DL_DIR}/postgres_${PG_VERSION}.tar"
tar -xf ${PG_TAR_PATH:?}
cd postgresql-${PG_VERSION}
./configure --prefix=${PG_INSTALL_DIR} --with-pgport=${PGPORT} --enable-cassert --without-readline
make install
cd ${current_dir:?}
${PG_BIN_DIR}/postgres --version
rm -r ${PG_BUILD_DIR:?}
rm ${PG_TAR_PATH:?}
rm ${PG_DL_PATH:?}
'''
]
[tasks.install-audit]
description = "Installs cargo-audit"
workspace = false
condition_script = ["if cargo audit --version ; then exit 1 ; else exit 0 ; fi"]
command = "cargo"
args = ["install", "cargo-audit"]
[tasks.install-with]
description = "Installs cargo-with"
workspace = false
condition_script = ["if cargo with --version ; then exit 1 ; else exit 0 ; fi"]
command = "cargo"
args = ["install", "cargo-with", "--git=https://github.com/bluejekyll/cargo-with.git", "--branch=master"]
##
## Postgres operations
[tasks.pg-init-db-dir]
description = "Creates the test DB used by the integration tests"
workspace = false
condition = { files_not_exist = ["${PG_DB_DIR}/pg_wal"] }
dependencies = ["install-postgres"]
script_runner = "@shell"
script = [
'''
set -e
echo "Intializing postgres db ${PG_DB_DIR:?}"
rm -rf ${PG_DB_DIR:?}
mkdir -p ${PG_DB_DIR:?}
${PG_BIN_DIR}/pg_ctl init -D ${PG_DB_DIR:?} -l ${PG_LOGPATH}
'''
]
[tasks.pg-start]
description = "Starts Postgres"
workspace = false
dependencies = ["pg-init-db-dir"]
script_runner = "@shell"
script = [
'''
set -e
if ${PG_BIN_DIR}/pg_isready ; then exit 0 ; fi
echo "Starting postgres ${PG_DB_DIR:?}"
mkdir -p ${PG_DB_DIR:?}
cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY:?}/integration-tests/postgresql.conf ${PG_DB_DIR:?}/
mv ${PG_LOGPATH:?} ${PG_LOGPATH}.bak || true
${PG_BIN_DIR}/pg_ctl start -D ${PG_DB_DIR:?} -l ${PG_LOGPATH:?}
${PG_BIN_DIR}/pg_isready -t 5
${PG_BIN_DIR}/psql postgres -o /dev/null -c "SELECT 1" # check the connection works
'''
]
[tasks.pg-create-db]
description = "Creates the test DB used by the integration tests"
workspace = false
dependencies = ["pg-start"]
script_runner = "@shell"
script = [
'''
set -e
echo "Creating DB ${POSTGRES_TEST_DB:?}"
${PG_BIN_DIR}/psql postgres -o /dev/null -c "SELECT 1" # check the connection works
${PG_BIN_DIR}/psql postgres -c "CREATE DATABASE ${POSTGRES_TEST_DB:?};" || true
'''
]
[tasks.pg-drop-db]
description = "Creates the test DB used by the integration tests"
workspace = false
dependencies = ["pg-start"]
script_runner = "@shell"
script = [
'''
set -e
echo "Dropping DB ${POSTGRES_TEST_DB:?}"
${PG_BIN_DIR}/psql postgres -o /dev/null -c "SELECT 1" # check the connection works
${PG_BIN_DIR}/psql postgres -c "DROP DATABASE ${POSTGRES_TEST_DB:?};" || true
'''
]
[tasks.pg-stop]
description = "Starts Postgres"
workspace = false
dependencies = ["pg-init-db-dir"]
script_runner = "@shell"
script = [
'''
set -e
echo "Stopping postgres ${PG_DB_DIR:?}"
${PG_BIN_DIR}/pg_ctl stop -D ${PG_DB_DIR:?} -l ${PG_LOGPATH} || true
'''
]
[tasks.psql]
description = "Connects psql to"
dependencies = ["pg-create-db"]
workspace = false
script_runner = "@shell"
script = [
'''
set -e
echo "Connection to postgres ${PG_DB_DIR:?} ${POSTGRES_TEST_DB:?}"
${PG_BIN_DIR}/psql ${POSTGRES_TEST_DB:?}
'''
]
##
## Standard tasks for testing, building, etc.
##
# TODO: actually make this await rather than sleep
[tasks.await-update]
description = "awaits the package to show up in crates.io"
script_runner = "@shell"
script = [
'''
sleep 10
'''
]
[tasks.clean-kcov]
description = "Remove the kcov installation"
workspace = false
script_runner = "@shell"
script = [
'''
rm -rf ${CARGO_MAKE_KCOV_INSTALLATION_DIRECTORY:?}
'''
]
[tasks.clean]
description = "Remove only the current workspace member"
command = "cargo"
args = ["clean", "-p", "${CARGO_MAKE_CRATE_NAME}"]
[tasks.clean-build]
description = "Remove only the current workspace member"
workspace = false
script_runner = "@shell"
script = [
'''
rm -rf ${TARGET_DIR:?}/debug
'''
]
[tasks.clean-db]
description = "Removes the DB directory"
workspace = false
script_runner = "@shell"
script = [
'''
rm -rf ${PG_DB_DIR:?}
'''
]
[tasks.clean-all]
description = "Remove only the current workspace member"
workspace = false
script_runner = "@shell"
script = [
'''
rm -rf ${TARGET_DIR:?}
rm -rf target
'''
]
[tasks.update]
description = "Update dependencies"
command = "cargo"
args = ["update", "-p", "${CARGO_MAKE_CRATE_NAME}"]
[tasks.fmt]
description = "Check formatting with rustfmt"
command = "cargo"
args = ["fmt", "--", "--check"]
[tasks.check]
description = "Run a quick check on all the crates"
dependencies = ["install-postgres"]
command = "cargo"
args = ["check", "--all-targets", "@@remove-empty(FEATURES)"]
[tasks.doc]
description = "Run a quick check on all the crates"
dependencies = ["install-postgres"]
command = "cargo"
args = ["doc", "@@remove-empty(FEATURES)"]
[tasks.build]
description = "Build all the crates"
dependencies = ["install-postgres"]
command = "cargo"
args = ["build", "--all-targets", "@@remove-empty(FEATURES)"]
[tasks.test]
description = "Run tests on all the crates"
command = "cargo"
args = ["test", "--all-targets", "@@remove-empty(FEATURES)"]
[tasks.clippy]
description = "Run the clippy linter on all crates"
#dependencies = ["clean", "install-postgres"]
dependencies = ["clean-build", "install-postgres"]
command = "cargo"
#args = ["clippy", "--all-targets", "${ALL_FEATURES}", "--", "-D", "warnings"]
# FIXME: the cbove command is correct, but seems to hit an issue with clippy and library paths, not clear why...
workspace = false
args = ["clippy", "--all", "--all-targets", "--", "-D", "warnings"]
[tasks.build-bench]
description = "Check that all benchmarks compile"
dependencies = ["clean", "install-postgres"]
command = "cargo"
toolchain = "nightly"
args = ["bench", "--no-run"]
[tasks.audit]
description = "Run cargo audit on all crates"
workspace = false
dependencies = ["check", "install-audit"]
command = "cargo"
args = ["audit", "--deny-warnings", "--ignore=RUSTSEC-2020-0016"]
[tasks.all]
description = "Run check, build, and test on all crates"
dependencies = ["check", "build", "test"]
[tasks.default]
description = "Run the all task"
run_task = "all"
[tasks.on_error]
description = "Dumps addition information to the CLI on failure"
workspace = false
script_runner = "@shell"
script = [
'''
echo "!!!!Dumping PG log after failure!!!!"
cat ${PG_LOGPATH} || true
'''
]
##
## All feature testing builds
##
[tasks.default-features]
description = "Run all with default features"
dependencies = ["install-openssl"]
env = { FEATURES = "" }
run_task = { name = "all", fork = true }
[tasks.no-default-features]
description = "Run all with --no-default-features"
dependencies = ["install-openssl"]
env = { FEATURES = "--no-default-features" }
run_task = { name = "all", fork = true }
[tasks.all-features]
description = "Run all with --all-features"
dependencies = ["install-openssl"]
env = { FEATURES = "${ALL_FEATURES}" }
run_task = { name = "all", fork = true }
##
## publishing
##
[tasks.package]
description = "package artifacts for each crate"
command = "cargo"
args = ["package", "--locked"]
[tasks.inner_publish]
description = "publish next release"
dependencies = ["await-update", "update", "check", "package"]
private = true
command = "cargo"
args = ["publish", "--verbose", "--locked"]
[tasks.publish]
description = "publish next release"
workspace = false
env = { CARGO_MAKE_WORKSPACE_SKIP_MEMBERS = "integration-tests/*;examples/*"}
run_task = { name = "inner_publish", fork = true }