13
13
14
14
env :
15
15
RUST_BACKTRACE : 1
16
+ SCCACHE_VER : 0.5.4 # Change this to bump the sccache version across all jobs
16
17
# CARGO_LOG: cargo::core::compiler::fingerprint=info # Uncomment this to output compiler fingerprint info
17
18
18
19
jobs :
19
- # A job for running tasks on an Amazon Linux 2 instance, which are self-hosted runners on another cloud service.
20
- # The image created for running these tasks already have a majority of the dependencies installed, such as system
21
- # libraries, sccache, github runners, rust, etc. This is to cut back on the amount of time it takes to launch a runner.
22
- # If something is missing, it can be added here or baked into a new image outside of Github Actions.
23
- plrust_arm64_amzn2 :
24
- name : aarch64 tests (amzn2)
25
- runs-on : [self-hosted, linux, ARM64, launch_template_id__lt-0013395587950cb5d]
20
+ # This job runs all tasks within an Ubuntu 22.04 image launched in AWS.
21
+ # A few things to note about the environment in which these run:
22
+ # * Ubuntu AMIs in AWS require extra storage to be mounted via EBS. As such, EBS volumes are pre-mounted
23
+ # in these images under /workdir
24
+ # * /workdir is the root directory for almost all things CI-build related, such as:
25
+ # - The "ubuntu" user's home directory is relocated to /workdir/ubuntu
26
+ # - TMPDIR is now set to /workdir/tmp so that Rust builds won't run out of drive space
27
+ # - rustup/cargo/etc are now located under various subdirectories of /workdir/ubuntu
28
+ # - sccache directory is located under /workdir/sccache
29
+ # - Any artifacts that need to be produces (like cache archives) need to be put under /workdir/ubuntu/artifacts
30
+ # - Github Actions runner is downloaded and installed to /workdir/ubuntu/actions-runner -- this is also where
31
+ # the runner application will be configured and launched
32
+ # * Caches are stored to and pulled from private S3 buckets
33
+ plrust_arm64_ubuntu :
34
+ name : arm64 tests on Ubuntu
35
+
36
+ runs-on : [self-hosted, linux, ARM64, launch_template_id__lt-0726d9ff7411af069]
26
37
defaults :
27
38
run :
28
39
shell : bash
29
40
30
41
strategy :
31
42
matrix :
32
- version : ["pg13", "pg14", "pg15"]
43
+ version : ["pg13", "pg14", "pg15", "pg16" ]
33
44
target : ["host", "postgrestd"]
34
45
fail-fast : false
35
46
36
- # Note about environment variables: Even though a majority of these environment variables are baked into the runner image,
37
- # Github Actions seemingly runs self-hosted tasks in a different manner such that even baken-in environment variables are
38
- # removed. Howevever, they can be declared here and persist through all tasks. Assume that the home directory for the
39
- # runner is /home/ec2-user
40
47
env :
48
+ ARTIFACTS_DIR : /workdir/ubuntu/artifacts
41
49
AWS_CACHE_BUCKET : tcdi-ci-plrust-build-cache.private
42
50
CACHE_KEY_VERSION : v0
43
51
CI : true
44
- PLRUST_TRUSTED_PGRX_OVERRIDE : " pgrx = { path = '/home/ec2-user /actions-runner/_work/plrust/plrust/plrust-trusted-pgrx', package='plrust-trusted-pgrx' }"
45
- RUSTUP_HOME : /home/ec2-user /.rustup
52
+ PLRUST_TRUSTED_PGRX_OVERRIDE : " pgrx = { path = '/workdir/ubuntu /actions-runner/_work/plrust/plrust/plrust-trusted-pgrx', package='plrust-trusted-pgrx' }"
53
+ RUSTUP_HOME : /workdir/ubuntu /.rustup
46
54
RUSTC_WRAPPER : sccache
47
55
RUSTFLAGS : -Copt-level=0 -Dwarnings
48
- SCCACHE_BIN_DIR : /home/ec2-user /.local/bin
56
+ SCCACHE_BIN_DIR : /workdir/ubuntu /.local/bin
49
57
SCCACHE_CACHE_SIZE : 20G
50
- SCCACHE_DIR : /home/ec2-user/.cache /sccache
58
+ SCCACHE_DIR : /workdir /sccache
51
59
SCCACHE_IDLE_TIMEOUT : 0
52
- WORK_DIR : /home/ec2-user/actions-runner/_work/plrust/plrust
60
+ WORK_DIR : /workdir/ubuntu/actions-runner/_work/plrust/plrust
61
+ TMPDIR : /workdir/tmp
53
62
54
63
steps :
55
64
- uses : actions/checkout@v3
56
65
57
- - name : Generate cache filename checksum
66
+ - name : Generate cache filenames
58
67
run : |
59
68
cd $WORK_DIR
60
69
shopt -s globstar
61
70
checksum=$(cat **/Cargo.lock **/rust-toolchain.toml .github/workflows/ci.yml .cargo/config | sha256sum | awk '{print $1}')
62
71
echo "CACHE_KEY_CHECKSUM=$checksum" >> $GITHUB_ENV
72
+ echo "CARGO_CACHE_KEY=plrust-arm64-ubuntu-cargo-cache-$CACHE_KEY_VERSION-$checksum.tar.lz4" >> $GITHUB_ENV
73
+ echo "SCCACHE_CACHE_KEY=plrust-arm64-ubuntu-sccache-cache-$CACHE_KEY_VERSION-$checksum.tar.lz4" >> $GITHUB_ENV
74
+ mkdir -p $ARTIFACTS_DIR
63
75
64
76
- name : Set up (Linux) prerequisites and environment
65
77
run : |
66
78
echo ""
67
- echo "----- Print kernel info -----"
68
- uname -a
69
- echo ""
70
79
71
80
echo "----- Set up dynamic variables -----"
72
81
export PG_VER=$(echo ${{ matrix.version }} | cut -c 3-)
73
82
echo "PG_VER=$PG_VER" >> $GITHUB_ENV
74
83
echo "MAKEFLAGS=$MAKEFLAGS -j $(grep -c ^processor /proc/cpuinfo)" >> $GITHUB_ENV
75
- echo "$SCCACHE_BIN_DIR" >> $GITHUB_PATH
76
- echo "PATH=$HOME/.cargo/bin:$PATH" >> $GITHUB_ENV
84
+ cat $GITHUB_ENV
77
85
echo ""
78
86
79
- echo "----- Install system dependencies -----"
80
- # Add any extra dependencies here if necessary
81
87
82
- echo "----- Install PostgreSQL $PG_VER -----"
83
- sudo yum install -y "postgresql$PG_VER" "postgresql$PG_VER-server" "postgresql$PG_VER-devel"
84
- export PATH="/usr/pgsql-$PG_VER/bin/:$PATH"
85
- echo "/usr/pgsql-$PG_VER/bin/" >> $GITHUB_PATH
88
+ echo "----- Install sccache -----"
89
+ mkdir -p $SCCACHE_BIN_DIR
90
+ curl -L "https://github.com/mozilla/sccache/releases/download/v$SCCACHE_VER/sccache-v$SCCACHE_VER-aarch64-unknown-linux-musl.tar.gz" | tar xz
91
+ mv -f "sccache-v$SCCACHE_VER-aarch64-unknown-linux-musl/sccache" "$SCCACHE_BIN_DIR/sccache"
92
+ chmod +x "$SCCACHE_BIN_DIR/sccache"
93
+ echo "$SCCACHE_BIN_DIR" >> "$GITHUB_PATH"
94
+ mkdir -p "$SCCACHE_DIR"
95
+ echo ""
86
96
87
- echo "----- Set postgres permissions -----"
88
- sudo chmod a+rwx `$(which pg_config) --pkglibdir` `$(which pg_config) --sharedir`/extension
97
+ echo "----- Remove old postgres and libraries -----"
98
+ sudo apt remove -y '^postgres.*' '^libpq.*' '^clang.*' '^llvm.*' '^libclang.*' '^libllvm.*' # '^mono-llvm.*'
89
99
echo ""
90
100
91
- echo "----- Create artifacts directory -----"
92
- mkdir -p $HOME/artifacts
101
+ echo "----- Set up PostgreSQL Apt repository -----"
102
+ sudo apt-get install -y wget gnupg
103
+ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
104
+ 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
105
+ sudo apt-get update -y -qq --fix-missing
93
106
echo ""
94
107
95
- cat $GITHUB_ENV
108
+ echo "----- Install system dependencies and PostgreSQL version $PG_VER -----"
109
+ sudo apt-get install -y \
110
+ build-essential \
111
+ clang-14 \
112
+ gcc \
113
+ libclang-14-dev \
114
+ libssl-dev \
115
+ libz-dev \
116
+ llvm-14-dev \
117
+ lz4 \
118
+ make \
119
+ pkg-config \
120
+ strace \
121
+ zlib1g-dev
96
122
echo ""
123
+
124
+ echo "----- Install rustup -----"
125
+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
126
+ echo "$HOME/.cargo/bin" >> $GITHUB_PATH
127
+ source "$HOME/.cargo/env"
128
+ cargo --version
129
+ echo ""
130
+
131
+ echo "----- Print env -----"
97
132
env
133
+ echo ""
98
134
99
- - name : Load Cargo cache if available
135
+ - name : Load Cargo and sccache caches if available
100
136
run : |
101
137
# See <plrust-root>/.github/scripts/load_cache.sh for more details
102
138
. $WORK_DIR/.github/scripts/load_cache.sh
103
- cargo_cache_key="plrust-arm64-amzn2-cargo-cache-$CACHE_KEY_VERSION-$CACHE_KEY_CHECKSUM.tar.lz4"
104
- loadcache $cargo_cache_key
139
+ loadcache $CARGO_CACHE_KEY
140
+ loadcache $SCCACHE_CACHE_KEY
141
+
142
+ - name : Start sccache server
143
+ run : sccache --start-server && sccache --show-stats
105
144
106
145
- name : Create protected files
107
146
run : |
@@ -111,20 +150,22 @@ jobs:
111
150
sudo chmod -R 600 /var/ci-stuff/secret_rust_files
112
151
if : matrix.target == 'postgrestd'
113
152
114
- - name : Load sccache cache if available
153
+ - name : Install release version of PostgreSQL
115
154
run : |
116
- # See <plrust-root>/.github/scripts/load_cache.sh for more details
117
- . $WORK_DIR/.github/scripts/load_cache.sh
118
- sccache_key="plrust-arm64-amzn2-sccache-cache-$CACHE_KEY_VERSION-$CACHE_KEY_CHECKSUM.tar.lz4"
119
- loadcache $sccache_key
155
+ sudo apt-get install -y \
156
+ postgresql-"$PG_VER" \
157
+ postgresql-server-dev-"$PG_VER"
120
158
121
- - name : Start sccache server
122
- run : sccache --start-server && sccache --show-stats
159
+ echo "---- pg_config info ----"
160
+ /usr/lib/postgresql/"$PG_VER"/bin/pg_config
161
+
162
+ - name : Set up Postgres permissions
163
+ 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/
123
164
124
165
# See <plrust-root>/.github/scripts/install_cargo_pgrx.sh for more details
125
166
- name : Install cargo-pgrx defined in plrust/Cargo.toml
126
167
run : |
127
- . $WORK_DIR /.github/scripts/install_cargo_pgrx.sh
168
+ . $GITHUB_WORKSPACE /.github/scripts/install_cargo_pgrx.sh
128
169
install_cargo_pgrx
129
170
130
171
- name : Print sccache stats
@@ -133,19 +174,33 @@ jobs:
133
174
- name : Install llvm-tools-preview
134
175
run : rustup component add llvm-tools-preview rustc-dev
135
176
177
+ - name : Create protected files
178
+ run : |
179
+ sudo mkdir -p /var/ci-stuff/secret_rust_files
180
+ sudo echo "const FOO:i32 = 7;" /var/ci-stuff/secret_rust_files/const_foo.rs
181
+ sudo echo "const BAR:i32 = 8;" /var/ci-stuff/const_bar.rs
182
+ sudo chmod -R 600 /var/ci-stuff/secret_rust_files
183
+ if : matrix.target == 'postgrestd'
184
+
136
185
- name : Test plrustc
137
186
run : cd plrustc && cargo test -p plrustc
138
187
139
188
- name : Print sccache stats
140
189
run : sccache --show-stats
141
190
142
- - name : install plrustc
191
+ - name : Test plrustc
192
+ run : cd plrustc && cargo test
193
+
194
+ - name : Print sccache stats
195
+ run : sccache --show-stats
196
+
197
+ - name : Install plrustc
143
198
run : cd plrustc && ./build.sh && cp ../build/bin/plrustc ~/.cargo/bin
144
199
145
200
- name : Print sccache stats
146
201
run : sccache --show-stats
147
202
148
- - name : Run cargo pgrx init
203
+ - name : Run ' cargo pgrx init' against system-level ${{ matrix.version }}
149
204
run : cargo pgrx init --pg$PG_VER $(which pg_config)
150
205
151
206
- name : Install PL/Rust as "trusted"
@@ -172,29 +227,23 @@ jobs:
172
227
if : matrix.target == 'host'
173
228
run : cd plrust && echo "\q" | cargo pgrx run "pg$PG_VER" && cd ../plrust-tests && cargo test --no-default-features --features "pg$PG_VER"
174
229
175
- - name : Print sccache stats (after build)
230
+ - name : Print sccache stats
176
231
run : sccache --show-stats
177
232
178
233
- name : Stop sccache server
179
234
run : sccache --stop-server || true
180
235
181
- - name : Store Cargo cache if applicable
236
+ - name : Store Cargo and sccache caches if applicable
182
237
run : |
183
238
. $WORK_DIR/.github/scripts/save_cache.sh
184
239
# See <plrust-root>/.github/scripts/save_cache.sh for more details
185
- cargo_cache_key="plrust-arm64-amzn2-cargo-cache-$CACHE_KEY_VERSION-$CACHE_KEY_CHECKSUM.tar.lz4"
186
240
cargo_dirs=( \
187
241
$HOME/.cargo/ \
188
242
)
189
- savecache $cargo_cache_key "${cargo_dirs[@]}"
243
+ savecache $CARGO_CACHE_KEY "${cargo_dirs[@]}"
190
244
191
- - name : Store sccache if applicable
192
- run : |
193
- # See <plrust-root>/.github/scripts/save_cache.sh for more details
194
- . $WORK_DIR/.github/scripts/save_cache.sh
195
- sccache_key="plrust-arm64-amzn2-sccache-cache-$CACHE_KEY_VERSION-$CACHE_KEY_CHECKSUM.tar.lz4"
196
245
sccache_dirs=($SCCACHE_DIR)
197
- savecache $sccache_key "${sccache_dirs[@]}"
246
+ savecache $SCCACHE_CACHE_KEY "${sccache_dirs[@]}"
198
247
199
248
plrust_x86_64 :
200
249
name : x86_64 tests
@@ -234,12 +283,12 @@ jobs:
234
283
235
284
236
285
echo "----- Install sccache -----"
237
- mkdir -p $SCCACHE_BIN_DIR
238
- curl -L https://github.com/mozilla/sccache/releases/download/v0.5.0 /sccache-v0.5.0 -x86_64-unknown-linux-musl.tar.gz | tar xz
239
- mv -f sccache-v0.5.0 -x86_64-unknown-linux-musl/sccache $SCCACHE_BIN_DIR/sccache
240
- chmod +x $SCCACHE_BIN_DIR/sccache
286
+ mkdir -p " $SCCACHE_BIN_DIR"
287
+ 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
288
+ mv -f " sccache-v$SCCACHE_VER -x86_64-unknown-linux-musl/sccache" " $SCCACHE_BIN_DIR/sccache"
289
+ chmod +x " $SCCACHE_BIN_DIR/sccache"
241
290
echo "$SCCACHE_BIN_DIR" >> $GITHUB_PATH
242
- mkdir -p $SCCACHE_DIR
291
+ mkdir -p " $SCCACHE_DIR"
243
292
echo ""
244
293
245
294
echo "----- Remove old postgres -----"
@@ -269,7 +318,7 @@ jobs:
269
318
echo "----- Installed Packages -----"
270
319
sudo apt list --installed
271
320
echo ""
272
-
321
+
273
322
echo "----- Print env -----"
274
323
env
275
324
echo ""
@@ -290,7 +339,7 @@ jobs:
290
339
sudo apt-get install -y \
291
340
postgresql-"$PG_VER" \
292
341
postgresql-server-dev-"$PG_VER"
293
-
342
+
294
343
echo "---- pg_config info ----"
295
344
/usr/lib/postgresql/"$PG_VER"/bin/pg_config
296
345
0 commit comments