-
Notifications
You must be signed in to change notification settings - Fork 33
440 lines (355 loc) · 16.6 KB
/
ci.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
name: PL/Rust
on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop
workflow_dispatch:
env:
RUST_BACKTRACE: 1
SCCACHE_VER: 0.5.4 # Change this to bump the sccache version across all jobs
# CARGO_LOG: cargo::core::compiler::fingerprint=info # Uncomment this to output compiler fingerprint info
jobs:
# This job runs all tasks within an Ubuntu 22.04 image launched in AWS.
# A few things to note about the environment in which these run:
# * Ubuntu AMIs in AWS require extra storage to be mounted via EBS. As such, EBS volumes are pre-mounted
# in these images under /workdir
# * /workdir is the root directory for almost all things CI-build related, such as:
# - The "ubuntu" user's home directory is relocated to /workdir/ubuntu
# - TMPDIR is now set to /workdir/tmp so that Rust builds won't run out of drive space
# - rustup/cargo/etc are now located under various subdirectories of /workdir/ubuntu
# - sccache directory is located under /workdir/sccache
# - Any artifacts that need to be produces (like cache archives) need to be put under /workdir/ubuntu/artifacts
# - Github Actions runner is downloaded and installed to /workdir/ubuntu/actions-runner -- this is also where
# the runner application will be configured and launched
# * Caches are stored to and pulled from private S3 buckets
plrust_arm64_ubuntu:
name: arm64 tests on Ubuntu
runs-on: [self-hosted, linux, ARM64, launch_template_id__lt-0726d9ff7411af069]
defaults:
run:
shell: bash
strategy:
matrix:
version: ["pg13", "pg14", "pg15", "pg16"]
target: ["host", "postgrestd"]
fail-fast: false
env:
ARTIFACTS_DIR: /workdir/ubuntu/artifacts
AWS_CACHE_BUCKET: tcdi-ci-plrust-build-cache.private
CACHE_KEY_VERSION: v0
CI: true
PLRUST_TRUSTED_PGRX_OVERRIDE: "pgrx = { path = '/workdir/ubuntu/actions-runner/_work/plrust/plrust/plrust-trusted-pgrx', package='plrust-trusted-pgrx' }"
RUSTUP_HOME: /workdir/ubuntu/.rustup
RUSTC_WRAPPER: sccache
RUSTFLAGS: -Copt-level=0 -Dwarnings
SCCACHE_BIN_DIR: /workdir/ubuntu/.local/bin
SCCACHE_CACHE_SIZE: 20G
SCCACHE_DIR: /workdir/sccache
SCCACHE_IDLE_TIMEOUT: 0
WORK_DIR: /workdir/ubuntu/actions-runner/_work/plrust/plrust
TMPDIR: /workdir/tmp
steps:
- uses: actions/checkout@v3
- name: Generate cache filenames
run: |
cd $WORK_DIR
shopt -s globstar
checksum=$(cat **/Cargo.lock **/rust-toolchain.toml .github/workflows/ci.yml .cargo/config | sha256sum | awk '{print $1}')
echo "CACHE_KEY_CHECKSUM=$checksum" >> $GITHUB_ENV
echo "CARGO_CACHE_KEY=plrust-arm64-ubuntu-cargo-cache-$CACHE_KEY_VERSION-$checksum.tar.lz4" >> $GITHUB_ENV
echo "SCCACHE_CACHE_KEY=plrust-arm64-ubuntu-sccache-cache-$CACHE_KEY_VERSION-$checksum.tar.lz4" >> $GITHUB_ENV
mkdir -p $ARTIFACTS_DIR
- name: Set up (Linux) prerequisites and environment
run: |
echo ""
echo "----- Set up dynamic variables -----"
export PG_VER=$(echo ${{ matrix.version }} | cut -c 3-)
echo "PG_VER=$PG_VER" >> $GITHUB_ENV
echo "MAKEFLAGS=$MAKEFLAGS -j $(grep -c ^processor /proc/cpuinfo)" >> $GITHUB_ENV
cat $GITHUB_ENV
echo ""
echo "----- Install sccache -----"
mkdir -p $SCCACHE_BIN_DIR
curl -L "https://github.com/mozilla/sccache/releases/download/v$SCCACHE_VER/sccache-v$SCCACHE_VER-aarch64-unknown-linux-musl.tar.gz" | tar xz
mv -f "sccache-v$SCCACHE_VER-aarch64-unknown-linux-musl/sccache" "$SCCACHE_BIN_DIR/sccache"
chmod +x "$SCCACHE_BIN_DIR/sccache"
echo "$SCCACHE_BIN_DIR" >> "$GITHUB_PATH"
mkdir -p "$SCCACHE_DIR"
echo ""
echo "----- Remove old postgres and libraries -----"
sudo apt remove -y '^postgres.*' '^libpq.*' '^clang.*' '^llvm.*' '^libclang.*' '^libllvm.*' # '^mono-llvm.*'
echo ""
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 | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg >/dev/null
sudo apt-get update -y -qq --fix-missing
echo ""
echo "----- Install system dependencies and PostgreSQL version $PG_VER -----"
sudo apt-get install -y \
build-essential \
clang-14 \
gcc \
libclang-14-dev \
libssl-dev \
libz-dev \
llvm-14-dev \
lz4 \
make \
pkg-config \
strace \
zlib1g-dev
echo ""
echo "----- Install rustup -----"
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
source "$HOME/.cargo/env"
cargo --version
echo ""
echo "----- Print env -----"
env
echo ""
- name: Load Cargo and sccache caches if available
run: |
# See <plrust-root>/.github/scripts/load_cache.sh for more details
. $WORK_DIR/.github/scripts/load_cache.sh
loadcache $CARGO_CACHE_KEY
loadcache $SCCACHE_CACHE_KEY
- name: Start sccache server
run: sccache --start-server && sccache --show-stats
- name: Create protected files
run: |
sudo mkdir -p /var/ci-stuff/secret_rust_files
sudo echo "const FOO:i32 = 7;" /var/ci-stuff/secret_rust_files/const_foo.rs
sudo echo "const BAR:i32 = 8;" /var/ci-stuff/const_bar.rs
sudo chmod -R 600 /var/ci-stuff/secret_rust_files
if: matrix.target == 'postgrestd'
- name: Install release version of PostgreSQL
run: |
sudo apt-get install -y \
postgresql-"$PG_VER" \
postgresql-server-dev-"$PG_VER"
echo "---- pg_config info ----"
/usr/lib/postgresql/"$PG_VER"/bin/pg_config
- name: Set up Postgres 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/
# See <plrust-root>/.github/scripts/install_cargo_pgrx.sh for more details
- name: Install cargo-pgrx defined in plrust/Cargo.toml
run: |
. $GITHUB_WORKSPACE/.github/scripts/install_cargo_pgrx.sh
install_cargo_pgrx
- name: Print sccache stats
run: sccache --show-stats
- name: Install llvm-tools-preview
run: rustup component add llvm-tools-preview rustc-dev
- name: Create protected files
run: |
sudo mkdir -p /var/ci-stuff/secret_rust_files
sudo echo "const FOO:i32 = 7;" /var/ci-stuff/secret_rust_files/const_foo.rs
sudo echo "const BAR:i32 = 8;" /var/ci-stuff/const_bar.rs
sudo chmod -R 600 /var/ci-stuff/secret_rust_files
if: matrix.target == 'postgrestd'
- name: Test plrustc
run: cd plrustc && cargo test -p plrustc
- name: Print sccache stats
run: sccache --show-stats
- name: Test plrustc
run: cd plrustc && cargo test
- name: Print sccache stats
run: sccache --show-stats
- name: Install plrustc
run: cd plrustc && ./build.sh && cp ../build/bin/plrustc ~/.cargo/bin
- name: Print sccache stats
run: sccache --show-stats
- name: Run 'cargo pgrx init' against system-level ${{ matrix.version }}
run: cargo pgrx init --pg$PG_VER $(which pg_config)
- name: Install PL/Rust as "trusted"
if: matrix.target == 'postgrestd'
run: cd plrust && STD_TARGETS="aarch64-postgres-linux-gnu" ./build && echo "\q" | cargo pgrx run "pg$PG_VER" --features "trusted"
- name: Test PL/Rust package as "trusted"
if: matrix.target == 'postgrestd'
run: cd plrust && cargo test --no-default-features --features "pg$PG_VER trusted"
- name: Run PL/Rust integration tests as "trusted"
if: matrix.target == 'postgrestd'
run: cd plrust && echo "\q" | cargo pgrx run "pg$PG_VER" --features "trusted" && cd ../plrust-tests && cargo test --no-default-features --features "pg$PG_VER trusted"
- name: Install PL/Rust as "untrusted"
if: matrix.target == 'host'
run: cd plrust && STD_TARGETS="aarch64-postgres-linux-gnu" ./build && echo "\q" | cargo pgrx run "pg$PG_VER"
- name: Test PL/Rust package as "untrusted"
if: matrix.target == 'host'
run: cd plrust && cargo test --no-default-features --features "pg$PG_VER"
- name: Run PL/Rust integration tests as "untrusted"
if: matrix.target == 'host'
run: cd plrust && echo "\q" | cargo pgrx run "pg$PG_VER" && cd ../plrust-tests && cargo test --no-default-features --features "pg$PG_VER"
- name: Print sccache stats
run: sccache --show-stats
- name: Stop sccache server
run: sccache --stop-server || true
- name: Store Cargo and sccache caches if applicable
run: |
. $WORK_DIR/.github/scripts/save_cache.sh
# See <plrust-root>/.github/scripts/save_cache.sh for more details
cargo_dirs=( \
$HOME/.cargo/ \
)
savecache $CARGO_CACHE_KEY "${cargo_dirs[@]}"
sccache_dirs=($SCCACHE_DIR)
savecache $SCCACHE_CACHE_KEY "${sccache_dirs[@]}"
plrust_x86_64:
name: x86_64 tests
runs-on: ${{ matrix.os }}
if: "!contains(github.event.head_commit.message, 'nogha')"
env:
PLRUST_TRUSTED_PGRX_OVERRIDE: "pgrx = { path = '/home/runner/work/plrust/plrust/plrust-trusted-pgrx', package='plrust-trusted-pgrx' }"
RUSTC_WRAPPER: sccache
RUSTFLAGS: -Copt-level=0 -Dwarnings
SCCACHE_BIN_DIR: /home/runner/.local/bin
SCCACHE_CACHE_SIZE: 20G
SCCACHE_DIR: /home/runner/.cache/sccache
SCCACHE_IDLE_TIMEOUT: 0
strategy:
matrix:
version: ["pg13", "pg14", "pg15", "pg16"]
os: ["ubuntu-latest"]
# it would be nice to other contributors to return "macos-11" to the above array
target: ["host", "postgrestd"]
fail-fast: false
steps:
- uses: actions/checkout@v3
- name: Set up (Linux) prerequisites and environment
run: |
echo ""
echo "----- Set up dynamic variables -----"
export PG_VER=$(echo ${{ matrix.version }} | cut -c 3-)
echo "PG_VER=$PG_VER" >> $GITHUB_ENV
echo "MAKEFLAGS=$MAKEFLAGS -j $(grep -c ^processor /proc/cpuinfo)" >> $GITHUB_ENV
cat $GITHUB_ENV
echo ""
echo "----- Install sccache -----"
mkdir -p "$SCCACHE_BIN_DIR"
curl -L "https://github.com/mozilla/sccache/releases/download/v$SCCACHE_VER/sccache-v$SCCACHE_VER-x86_64-unknown-linux-musl.tar.gz" | tar xz
mv -f "sccache-v$SCCACHE_VER-x86_64-unknown-linux-musl/sccache" "$SCCACHE_BIN_DIR/sccache"
chmod +x "$SCCACHE_BIN_DIR/sccache"
echo "$SCCACHE_BIN_DIR" >> $GITHUB_PATH
mkdir -p "$SCCACHE_DIR"
echo ""
echo "----- Remove old postgres -----"
sudo apt remove -y '^postgres.*' '^libpq.*' '^clang.*' '^llvm.*' '^libclang.*' '^libllvm.*' '^mono-llvm.*'
echo ""
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 | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg >/dev/null && \
sudo apt-get update -y -qq --fix-missing
echo ""
echo "----- Install system dependencies and PostgreSQL version $PG_VER -----"
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 "----- Installed Packages -----"
sudo apt list --installed
echo ""
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"
echo "---- pg_config info ----"
/usr/lib/postgresql/"$PG_VER"/bin/pg_config
- name: Set up Postgres 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: |
/home/runner/.cargo
key: v0-plrust-x86_64-cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock', '**/rust-toolchain.toml', 'plrustc/.cargo/config.toml', '.github/workflows/ci.yml', '.cargo/config') }}
- name: Cache sccache directory
uses: actions/cache@v3
continue-on-error: false
with:
path: |
/home/runner/.cache/sccache
key: v0-plrust-x86_64-sccache-${{ matrix.target }}-${{ runner.os }}-${{ hashFiles('**/Cargo.lock', '**/rust-toolchain.toml', 'plrustc/.cargo/config.toml', '.github/workflows/ci.yml', '.cargo/config') }}
- name: Start sccache server
run: sccache --start-server && sccache --show-stats
- name: sccache dir
run: ls -lath /home/runner/.cache/sccache
# See <plrust-root>/.github/scripts/install_cargo_pgrx.sh for more details
- name: Install cargo-pgrx defined in plrust/Cargo.toml
run: |
. $GITHUB_WORKSPACE/.github/scripts/install_cargo_pgrx.sh
install_cargo_pgrx
- name: Print sccache stats
run: sccache --show-stats
- name: Install llvm-tools-preview
run: rustup component add llvm-tools-preview rustc-dev
- name: Create protected files
run: |
sudo mkdir -p /var/ci-stuff/secret_rust_files
sudo echo "const FOO:i32 = 7;" /var/ci-stuff/secret_rust_files/const_foo.rs
sudo echo "const BAR:i32 = 8;" /var/ci-stuff/const_bar.rs
sudo chmod -R 600 /var/ci-stuff/secret_rust_files
if: matrix.target == 'postgrestd'
- name: Test plrustc
run: cd plrustc && cargo test -p plrustc
- name: Print sccache stats
run: sccache --show-stats
- name: Test plrustc
run: cd plrustc && cargo test
- name: Install plrustc
run: cd plrustc && ./build.sh && cp ../build/bin/plrustc ~/.cargo/bin
- name: Print sccache stats
run: sccache --show-stats
- name: Run 'cargo pgrx init' against system-level ${{ matrix.version }}
run: cargo pgrx init --pg$PG_VER $(which pg_config)
- name: Install PL/Rust as "trusted"
if: matrix.target == 'postgrestd'
run: cd plrust && STD_TARGETS="x86_64-postgres-linux-gnu" ./build && echo "\q" | cargo pgrx run "pg$PG_VER" --features "trusted"
- name: Test PL/Rust package as "trusted"
if: matrix.target == 'postgrestd'
run: cd plrust && cargo test --no-default-features --features "pg$PG_VER trusted"
- name: Run PL/Rust integration tests as "trusted"
if: matrix.target == 'postgrestd'
run: cd plrust && echo "\q" | cargo pgrx run "pg$PG_VER" --features "trusted" && cd ../plrust-tests && cargo test --no-default-features --features "pg$PG_VER trusted"
- name: Install PL/Rust as "untrusted"
if: matrix.target == 'host'
run: cd plrust && STD_TARGETS="x86_64-postgres-linux-gnu" ./build && echo "\q" | cargo pgrx run "pg$PG_VER"
- name: Test PL/Rust package as "untrusted"
if: matrix.target == 'host'
run: cd plrust && cargo test --no-default-features --features "pg$PG_VER"
- name: Run PL/Rust integration tests as "untrusted"
if: matrix.target == 'host'
run: cd plrust && echo "\q" | cargo pgrx run "pg$PG_VER" && cd ../plrust-tests && cargo test --no-default-features --features "pg$PG_VER"
- name: Print sccache stats
run: sccache --show-stats
- name: sccache dir
run: ls -lath /home/runner/.cache/sccache
- name: Stop sccache server
run: sccache --stop-server || true