1313
1414env :
1515 RUST_BACKTRACE : 1
16+ SCCACHE_VER : 0.5.4 # Change this to bump the sccache version across all jobs
1617 # CARGO_LOG: cargo::core::compiler::fingerprint=info # Uncomment this to output compiler fingerprint info
1718
1819jobs :
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]
2637 defaults :
2738 run :
2839 shell : bash
2940
3041 strategy :
3142 matrix :
32- version : ["pg13", "pg14", "pg15"]
43+ version : ["pg13", "pg14", "pg15", "pg16" ]
3344 target : ["host", "postgrestd"]
3445 fail-fast : false
3546
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
4047 env :
48+ ARTIFACTS_DIR : /workdir/ubuntu/artifacts
4149 AWS_CACHE_BUCKET : tcdi-ci-plrust-build-cache.private
4250 CACHE_KEY_VERSION : v0
4351 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
4654 RUSTC_WRAPPER : sccache
4755 RUSTFLAGS : -Copt-level=0 -Dwarnings
48- SCCACHE_BIN_DIR : /home/ec2-user /.local/bin
56+ SCCACHE_BIN_DIR : /workdir/ubuntu /.local/bin
4957 SCCACHE_CACHE_SIZE : 20G
50- SCCACHE_DIR : /home/ec2-user/.cache /sccache
58+ SCCACHE_DIR : /workdir /sccache
5159 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
5362
5463 steps :
5564 - uses : actions/checkout@v3
5665
57- - name : Generate cache filename checksum
66+ - name : Generate cache filenames
5867 run : |
5968 cd $WORK_DIR
6069 shopt -s globstar
6170 checksum=$(cat **/Cargo.lock **/rust-toolchain.toml .github/workflows/ci.yml .cargo/config | sha256sum | awk '{print $1}')
6271 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
6375
6476 - name : Set up (Linux) prerequisites and environment
6577 run : |
6678 echo ""
67- echo "----- Print kernel info -----"
68- uname -a
69- echo ""
7079
7180 echo "----- Set up dynamic variables -----"
7281 export PG_VER=$(echo ${{ matrix.version }} | cut -c 3-)
7382 echo "PG_VER=$PG_VER" >> $GITHUB_ENV
7483 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
7785 echo ""
7886
79- echo "----- Install system dependencies -----"
80- # Add any extra dependencies here if necessary
8187
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 ""
8696
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.*'
8999 echo ""
90100
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
93106 echo ""
94107
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
96122 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 -----"
97132 env
133+ echo ""
98134
99- - name : Load Cargo cache if available
135+ - name : Load Cargo and sccache caches if available
100136 run : |
101137 # See <plrust-root>/.github/scripts/load_cache.sh for more details
102138 . $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
105144
106145 - name : Create protected files
107146 run : |
@@ -111,20 +150,22 @@ jobs:
111150 sudo chmod -R 600 /var/ci-stuff/secret_rust_files
112151 if : matrix.target == 'postgrestd'
113152
114- - name : Load sccache cache if available
153+ - name : Install release version of PostgreSQL
115154 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"
120158
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/
123164
124165 # See <plrust-root>/.github/scripts/install_cargo_pgrx.sh for more details
125166 - name : Install cargo-pgrx defined in plrust/Cargo.toml
126167 run : |
127- . $WORK_DIR /.github/scripts/install_cargo_pgrx.sh
168+ . $GITHUB_WORKSPACE /.github/scripts/install_cargo_pgrx.sh
128169 install_cargo_pgrx
129170
130171 - name : Print sccache stats
@@ -133,19 +174,33 @@ jobs:
133174 - name : Install llvm-tools-preview
134175 run : rustup component add llvm-tools-preview rustc-dev
135176
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+
136185 - name : Test plrustc
137186 run : cd plrustc && cargo test -p plrustc
138187
139188 - name : Print sccache stats
140189 run : sccache --show-stats
141190
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
143198 run : cd plrustc && ./build.sh && cp ../build/bin/plrustc ~/.cargo/bin
144199
145200 - name : Print sccache stats
146201 run : sccache --show-stats
147202
148- - name : Run cargo pgrx init
203+ - name : Run ' cargo pgrx init' against system-level ${{ matrix.version }}
149204 run : cargo pgrx init --pg$PG_VER $(which pg_config)
150205
151206 - name : Install PL/Rust as "trusted"
@@ -172,29 +227,23 @@ jobs:
172227 if : matrix.target == 'host'
173228 run : cd plrust && echo "\q" | cargo pgrx run "pg$PG_VER" && cd ../plrust-tests && cargo test --no-default-features --features "pg$PG_VER"
174229
175- - name : Print sccache stats (after build)
230+ - name : Print sccache stats
176231 run : sccache --show-stats
177232
178233 - name : Stop sccache server
179234 run : sccache --stop-server || true
180235
181- - name : Store Cargo cache if applicable
236+ - name : Store Cargo and sccache caches if applicable
182237 run : |
183238 . $WORK_DIR/.github/scripts/save_cache.sh
184239 # 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"
186240 cargo_dirs=( \
187241 $HOME/.cargo/ \
188242 )
189- savecache $cargo_cache_key "${cargo_dirs[@]}"
243+ savecache $CARGO_CACHE_KEY "${cargo_dirs[@]}"
190244
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"
196245 sccache_dirs=($SCCACHE_DIR)
197- savecache $sccache_key "${sccache_dirs[@]}"
246+ savecache $SCCACHE_CACHE_KEY "${sccache_dirs[@]}"
198247
199248 plrust_x86_64 :
200249 name : x86_64 tests
@@ -234,12 +283,12 @@ jobs:
234283
235284
236285 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"
241290 echo "$SCCACHE_BIN_DIR" >> $GITHUB_PATH
242- mkdir -p $SCCACHE_DIR
291+ mkdir -p " $SCCACHE_DIR"
243292 echo ""
244293
245294 echo "----- Remove old postgres -----"
@@ -269,7 +318,7 @@ jobs:
269318 echo "----- Installed Packages -----"
270319 sudo apt list --installed
271320 echo ""
272-
321+
273322 echo "----- Print env -----"
274323 env
275324 echo ""
@@ -290,7 +339,7 @@ jobs:
290339 sudo apt-get install -y \
291340 postgresql-"$PG_VER" \
292341 postgresql-server-dev-"$PG_VER"
293-
342+
294343 echo "---- pg_config info ----"
295344 /usr/lib/postgresql/"$PG_VER"/bin/pg_config
296345
0 commit comments