-
-
Notifications
You must be signed in to change notification settings - Fork 249
491 lines (386 loc) · 16.7 KB
/
tests.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
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
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
name: Run PGRX tests
on:
push:
branches:
- develop
pull_request:
branches:
- develop
env:
# NB: Don't modify `RUSTFLAGS` here, since it would override the ones
# configured by `.cargo/config.toml` on macOS.
RUST_BACKTRACE: 1
CARGO_INCREMENTAL: "false"
SCCACHE_MAX_FRAME_LENGTH: 100000000
# CARGO_LOG: cargo::core::compiler::fingerprint=info # Uncomment this to output compiler fingerprint info
jobs:
pgrx_tests:
name: pgrx-tests & examples
runs-on: PGRX
if: "!contains(github.event.head_commit.message, 'nogha')"
env:
RUSTC_WRAPPER: sccache
SCCACHE_DIR: /home/runner/.cache/sccache
strategy:
matrix:
version: ["postgres-12", "postgres-13", "postgres-14", "postgres-15", "postgres-16"]
steps:
- uses: actions/checkout@v3
- name: Set up prerequisites and environment
run: |
echo ""
echo "----- Install sccache -----"
mkdir -p $HOME/.local/bin
curl -L https://github.com/mozilla/sccache/releases/download/v0.2.15/sccache-v0.2.15-x86_64-unknown-linux-musl.tar.gz | tar xz
mv -f sccache-v0.2.15-x86_64-unknown-linux-musl/sccache $HOME/.local/bin/sccache
chmod +x $HOME/.local/bin/sccache
echo "$HOME/.local/bin" >> $GITHUB_PATH
mkdir -p /home/runner/.cache/sccache
echo ""
echo "----- Set up dynamic variables -----"
export PG_VER=$(echo ${{ matrix.version }} | cut -d '-' -f2)
echo "PG_VER=$PG_VER" >> $GITHUB_ENV
echo "MAKEFLAGS=$MAKEFLAGS -j $(grep -c ^processor /proc/cpuinfo)" >> $GITHUB_ENV
cat $GITHUB_ENV
echo ""
echo "----- Remove old postgres -----"
sudo apt remove -y '^postgres.*' '^libpq.*' '^clang.*' '^llvm.*' '^libclang.*' '^libllvm.*' '^mono-llvm.*'
echo ""
echo "----- Install system dependencies -----"
sudo apt-get install -y \
build-essential \
llvm-14-dev libclang-14-dev clang-14 \
gcc \
libssl-dev \
libz-dev \
make \
pkg-config \
strace \
zlib1g-dev
echo ""
echo "----- Set up cross compilation -----"
sudo apt-get install -y --fix-missing crossbuild-essential-arm64
rustup target add aarch64-unknown-linux-gnu
echo 'CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc' >> $GITHUB_ENV
# TODO: not all of these should be needed, but for now it's likely fine.
echo 'BINDGEN_EXTRA_CLANG_ARGS_aarch64-unknown-linux-gnu=-target aarch64-unknown-linux-gnu -isystem /usr/aarch64-linux-gnu/include/ -ccc-gcc-name aarch64-linux-gnu-gcc' >> $GITHUB_ENV
echo "----- Print env -----"
env
echo ""
echo "----- Get cargo version -----"
cargo --version
echo ""
- name: Install release version of PostgreSQL
run: |
echo "----- Set up PostgreSQL Apt repository -----"
sudo apt-get install -y wget gnupg
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update -y -qq --fix-missing
echo ""
sudo apt-get install -y \
postgresql-$PG_VER \
postgresql-server-dev-$PG_VER
- name: Set up PostgreSQL permissions
run: sudo chmod a+rwx `/usr/lib/postgresql/$PG_VER/bin/pg_config --pkglibdir` `/usr/lib/postgresql/$PG_VER/bin/pg_config --sharedir`/extension /var/run/postgresql/
- name: Cache cargo registry
uses: actions/cache@v3
continue-on-error: false
with:
path: |
~/.cargo/registry
~/.cargo/git
key: pgrx-tests-cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock', '.github/workflows/tests.yml') }}
- name: Cache sccache directory
uses: actions/cache@v3
continue-on-error: false
with:
path: /home/runner/.cache/sccache
key: pgrx-tests-sccache-${{ runner.os }}-${{ hashFiles('**/Cargo.lock', '.github/workflows/tests.yml') }}
- name: Start sccache server
run: sccache --start-server
- name: Print sccache stats (before run)
run: sccache --show-stats
- name: Install cargo-pgrx
run: cargo install --path cargo-pgrx/ --debug --force
- name: Run 'cargo pgrx init' against system-level ${{ matrix.version }}
run: cargo pgrx init --pg$PG_VER /usr/lib/postgresql/$PG_VER/bin/pg_config
- name: Run base-level tests
run: |
cargo test \
--features "pg$PG_VER" \
--package cargo-pgrx \
--package pgrx \
--package pgrx-macros \
--package pgrx-pg-sys \
--package pgrx-sql-entity-graph
- name: Check that cross-compiled pgrx-tests can build
run: |
cargo build --tests \
--features "pg$PG_VER" \
--package pgrx-tests \
--target aarch64-unknown-linux-gnu
- name: Run pgrx-tests with cshim enabled
run: |
cargo test \
--features "pg$PG_VER cshim proptest" \
--package pgrx-tests
- name: Run pgrx-tests with cshim disabled
run: |
cargo test \
--features "pg$PG_VER" \
--package pgrx-tests
- name: Run aggregate example tests
run: cargo test --package aggregate --features "pg$PG_VER" --no-default-features
- name: Run arrays example tests
run: cargo test --package arrays --features "pg$PG_VER" --no-default-features
- name: Run bad_ideas example tests
run: cargo test --package bad_ideas --features "pg$PG_VER" --no-default-features
- name: Run bgworker example tests
run: cargo test --package bgworker --features "pg$PG_VER" --no-default-features
- name: Run bytea example tests
run: cargo test --package bytea --features "pg$PG_VER" --no-default-features
- name: Run composite_type example tests
run: cargo test --package composite_type --features "pg$PG_VER" --no-default-features
- name: Run custom_libname example tests
run: cargo test --package custom_libname --features "pg$PG_VER" --no-default-features
- name: Run custom_types example tests
run: cargo test --package custom_types --features "pg$PG_VER" --no-default-features
- name: Run custom_types without schema generation example tests
run: cargo test --package custom_types --features "pg$PG_VER no-schema-generation" --no-default-features
- name: Run custom_sql example tests
run: cargo test --package custom_sql --features "pg$PG_VER" --no-default-features
- name: Run datetime example tests
run: cargo test --package datetime --features "pg$PG_VER" --no-default-features
- name: Run errors example tests
run: cargo test --package errors --features "pg$PG_VER" --no-default-features
- name: Run nostd example tests
run: cargo test --package nostd --features "pg$PG_VER" --no-default-features
- name: Run numeric example tests
run: cargo test --package numeric --features "pg$PG_VER" --no-default-features
- name: Run pgtrybuilder example tests
run: cargo test --package pgtrybuilder --features "pg$PG_VER" --no-default-features
- name: Run operators example tests
run: cargo test --package operators --features "pg$PG_VER" --no-default-features
- name: Run range example tests
run: cargo test --package range --features "pg$PG_VER" --no-default-features
- name: Run schemas example tests
run: cargo test --package schemas --features "pg$PG_VER" --no-default-features
- name: Run shmem example tests
run: cargo test --package shmem --features "pg$PG_VER" --no-default-features
- name: Run spi example tests
run: cargo test --package spi --features "pg$PG_VER" --no-default-features
- name: Run spi_srf example tests
run: cargo test --package spi_srf --features "pg$PG_VER" --no-default-features
- name: Run srf example tests
run: cargo test --package srf --features "pg$PG_VER" --no-default-features
- name: Run strings example tests
run: cargo test --package strings --features "pg$PG_VER" --no-default-features
- name: Run triggers example tests
run: cargo test --package triggers --features "pg$PG_VER" --no-default-features
- name: Run versioned_custom_libname_so example tests
run: cargo test --package versioned_custom_libname_so --features "pg$PG_VER" --no-default-features
- name: Run versioned_so example tests
run: cargo test --package versioned_so --features "pg$PG_VER" --no-default-features
# Attempt to make the cache payload slightly smaller.
- name: Clean up built PGRX files
run: |
cd target/debug/deps/
for built_file in $(find * -type f -executable -print | grep -v "\.so$"); do
base_name=$(echo $built_file | cut -d- -f1);
for basefile in "$base_name".*; do
[ -f "$basefile" ] || continue;
echo "Removing $basefile"
rm $basefile
done;
echo "Removing $built_file"
rm $built_file
done
- name: Stop sccache server
run: sccache --stop-server || true
cargo_pgrx_init:
name: cargo pgrx init
runs-on: PGRX
if: "!contains(github.event.head_commit.message, 'nogha')"
env:
RUSTC_WRAPPER: sccache
SCCACHE_DIR: /home/runner/.cache/sccache
strategy:
matrix:
version: ["postgres-15"]
steps:
- uses: actions/checkout@v3
- name: Set up prerequisites and environment
run: |
echo ""
echo "----- Install / Set up sccache -----"
mkdir -p $HOME/.local/bin
curl -L https://github.com/mozilla/sccache/releases/download/v0.2.15/sccache-v0.2.15-x86_64-unknown-linux-musl.tar.gz | tar xz
mv -f sccache-v0.2.15-x86_64-unknown-linux-musl/sccache $HOME/.local/bin/sccache
chmod +x $HOME/.local/bin/sccache
echo "$HOME/.local/bin" >> $GITHUB_PATH
mkdir -p /home/runner/.cache/sccache
echo ""
# https://stackoverflow.com/questions/57968497/how-do-i-set-an-env-var-with-a-bash-expression-in-github-actions/57969570#57969570
echo "----- Set up MAKEFLAGS -----"
echo "MAKEFLAGS=$MAKEFLAGS -j $(grep -c ^processor /proc/cpuinfo)" >> $GITHUB_ENV
cat $GITHUB_ENV
echo ""
echo "----- Set up PG_VER variable -----"
echo "PG_VER=$(echo ${{ matrix.version }} | cut -d '-' -f2)" >> $GITHUB_ENV
cat $GITHUB_ENV
echo ""
echo "----- Remove old postgres -----"
sudo apt remove -y '^postgres.*' '^libpq.*' '^clang.*' '^llvm.*' '^libclang.*' '^libllvm.*' '^mono-llvm.*'
echo ""
echo "----- Install system dependencies -----"
sudo apt-get install -y \
build-essential \
llvm-14-dev libclang-14-dev clang-14 \
gcc \
libssl-dev \
libz-dev \
make \
pkg-config \
strace \
zlib1g-dev
echo ""
echo "----- Output Cargo version -----"
cargo --version
echo ""
echo "----- Outputting env -----"
env
echo ""
- name: Cache cargo registry
uses: actions/cache@v3
continue-on-error: false
with:
path: |
~/.cargo/registry
~/.cargo/git
key: pgrx-cargo_init_tests-cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock', '.github/workflows/tests.yml') }}
- name: Cache sccache directory
uses: actions/cache@v3
continue-on-error: false
with:
path: /home/runner/.cache/sccache
key: pgrx-cargo_init_tests-sccache-${{ runner.os }}-${{ hashFiles('**/Cargo.lock', '.github/workflows/tests.yml') }}
- name: Start sccache server
run: sccache --start-server
- name: Print sccache stats (before)
run: sccache --show-stats
- name: Run rustfmt
run: cargo fmt --all -- --check
- name: Install cargo-pgrx
run: cargo install --path cargo-pgrx/ --debug --force
- name: Run 'cargo pgrx init' for ${{ matrix.version }}
run: cargo pgrx init --pg$PG_VER download
- name: Clippy -Awarnings
run: cargo clippy -p pgrx --features pg$PG_VER -- -Awarnings
- name: Check doc-links
run: |
cargo rustdoc -p pgrx --features pg$PG_VER -- \
--document-private-items \
-Drustdoc::broken-intra-doc-links \
-Drustdoc::invalid-html-tags
- name: create new sample extension
run: cd /tmp/ && cargo pgrx new sample
# hack Cargo.toml to use this version of pgrx from github
- name: hack Cargo.toml
run: |
echo "[patch.crates-io]" >> /tmp/sample/Cargo.toml
echo "pgrx = { path = \"${GITHUB_WORKSPACE}/pgrx\" }" >> /tmp/sample/Cargo.toml
echo "pgrx-macros = { path = \"${GITHUB_WORKSPACE}/pgrx-macros\" }" >> /tmp/sample/Cargo.toml
echo "pgrx-tests = { path = \"${GITHUB_WORKSPACE}/pgrx-tests\" }" >> /tmp/sample/Cargo.toml
- name: show Cargo.toml
run: cat /tmp/sample/Cargo.toml
- name: Test sample for ${{ matrix.version }}
run: cd /tmp/sample && cargo pgrx test pg$PG_VER
- name: Stop sccache server
run: sccache --stop-server || true
build_mac:
name: MacOS build & test
runs-on: ${{ matrix.os }}
if: "!contains(github.event.head_commit.message, 'nogha')"
env:
RUSTC_WRAPPER: sccache
SCCACHE_DIR: /Users/runner/Library/Caches/Mozilla.sccache
SCCACHE_IDLE_TIMEOUT: 0
strategy:
matrix:
os: ["macos-13"]
# Since Postgres 16 on macOS the dynamic library extension is "dylib" (instead of "so" on older versions),
# so it's important to test against both versions (with "old" and "new" extensions).
#
# See https://github.com/pgcentralfoundation/pgrx/pull/1300
postgresql: [ 15, 16 ]
steps:
- uses: Homebrew/actions/setup-homebrew@master
# Although we don't use Python per se, if Homebrew has an updated version of Python,
# the following steps could fail because GitHub Actions mixed up the linkage.
- name: Workaround GitHub Actions Python issues
run: brew unlink python && brew link --overwrite python
- name: brew install postgresql
run: |
brew install ${FORMULA}
echo "$(brew --prefix ${FORMULA})/bin" >> $GITHUB_PATH
env:
FORMULA: postgresql@${{ matrix.postgresql }}
- uses: actions/checkout@v3
- name: Set up prerequisites and environment
run: |
echo ""
echo "----- Install sccache -----"
curl -L https://github.com/mozilla/sccache/releases/download/v0.5.4/sccache-v0.5.4-x86_64-apple-darwin.tar.gz | tar xz
mv -f sccache-v0.5.4-x86_64-apple-darwin/sccache /usr/local/bin
chmod +x /usr/local/bin/sccache
mkdir -p $SCCACHE_DIR
sccache --version
# https://stackoverflow.com/questions/57968497/how-do-i-set-an-env-var-with-a-bash-expression-in-github-actions/57969570#57969570
echo "----- Getting pre-installed Postgres major version -----"
PG_VER=$(pg_config --version | awk '{split($2,a,"."); print a[1]}')
echo "PG_VER=$PG_VER" >> $GITHUB_ENV
cat $GITHUB_ENV
echo "----- Set up Postgres permissions -----"
sudo chmod a+rwx `$(which pg_config) --pkglibdir` `$(which pg_config) --sharedir`/extension
# ls -lath `$(which pg_config) --pkglibdir` `$(which pg_config) --sharedir`/extension
echo ""
echo "----- Stable Rust ----"
rustup update stable
rustup default stable
rustc -vV
cargo -vV
echo ""
echo "----- Outputting env -----"
env
echo ""
- name: Cache sccache directory
uses: actions/cache@v3
continue-on-error: false
with:
path: /Users/runner/Library/Caches/Mozilla.sccache
key: pgrx-sccache-macos-11-${{ hashFiles('**/Cargo.lock', '.github/workflows/tests.yml', '.cargo/config.toml') }}
- name: Cache cargo directory
uses: actions/cache@v3
with:
path: |
~/.cargo
key: pgrx-cargo-macos-11-tests-${{ hashFiles('**/Cargo.lock', '.github/workflows/tests.yml', '.cargo/config.toml') }}
- name: Start sccache server
run: sccache --start-server
- name: Print sccache stats
run: sccache --show-stats
- name: Install cargo-pgrx
run: cargo install --path cargo-pgrx/ --debug --force
- name: Print sccache stats
run: sccache --show-stats
- name: Run 'cargo pgrx init'
run: |
set -x
cargo pgrx init --pg$PG_VER $(which pg_config)
- name: Run tests
run: cargo test --all --features "pg$PG_VER pg_test cshim proptest" --no-default-features
- name: Print sccache stats
run: sccache --show-stats
- name: Stop sccache server
run: sccache --stop-server || true