Skip to content

Commit 03a3064

Browse files
authored
Cache more in CI (#112)
* Use rust-toolchain.toml in js-compute-runtime I'm also only copying js-compute-runtime.wasm into the job's uploaded artifacts, not any temporary files generated during the build. * Cache Rust dependencies of js-compute-runtime * Use rust-toolchain.toml at top-level ...and also rely on CI-provided versions of rustup, even on Mac. * Share runner's $HOME with Centos container The idea here is to use rustup and the Rust toolchain configured in the outer container, while using the C toolchain from the inner Centos container. * Cache builds on `main` and pull requests If `main` is uncached, then each new pull request starts with an empty cache. But ignore the build cache on tagged releases. This is possibly excessive caution. It ensures that artifacts published with a release of this SDK aren't corrupted by broken caches.
1 parent 9746f80 commit 03a3064

File tree

7 files changed

+40
-39
lines changed

7 files changed

+40
-39
lines changed

.github/actions/binary-compatible-builds/action.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,6 @@ runs:
4343
- if: runner.os == 'Linux'
4444
shell: bash
4545
run: |
46-
# FIXME(rust-lang/rust#80703) LD_LIBRARY_PATH shouldn't be necessary
47-
docker run -di --name centos -v $PWD:$PWD -v $(rustc --print sysroot):/rust:ro \
48-
--env LD_LIBRARY_PATH=/rust/lib \
49-
--env PATH="/opt/rh/devtoolset-8/root/usr/bin:$PATH:/rust/bin" \
50-
binary-compatible-builds
51-
5246
cat >> $GITHUB_ENV <<EOF
5347
CENTOS=$GITHUB_ACTION_PATH/run-linux
5448
python=python3
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1-
#!/bin/sh
1+
#!/usr/bin/env bash
22

3-
exec docker exec --env PREBUILT_ENGINE=${PREBUILT_ENGINE:-} -w $PWD -i centos "$@"
3+
set -euo pipefail
4+
exec docker run -i \
5+
--env PREBUILT_ENGINE="$PREBUILT_ENGINE" \
6+
--env PATH="/opt/rh/devtoolset-8/root/usr/bin:$PATH" \
7+
-v "$HOME:$HOME" --workdir "$PWD" \
8+
binary-compatible-builds "$@"

.github/actions/install-rust/main.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,7 @@ function set_env(name, val) {
66
fs.appendFileSync(process.env['GITHUB_ENV'], `${name}=${val}\n`)
77
}
88

9-
if (process.platform === 'darwin') {
10-
child_process.execSync(`curl https://sh.rustup.rs | sh -s -- -y --default-toolchain=none --profile=minimal`);
11-
const bindir = `${process.env.HOME}/.cargo/bin`;
12-
fs.appendFileSync(process.env['GITHUB_PATH'], `${bindir}\n`);
13-
process.env.PATH = `${process.env.PATH}:${bindir}`;
14-
}
15-
16-
child_process.execFileSync('rustup', ['set', 'profile', 'minimal']);
17-
child_process.execFileSync('rustup', ['update', toolchain, '--no-self-update']);
18-
child_process.execFileSync('rustup', ['default', toolchain]);
9+
child_process.execFileSync('rustup', ['show']);
1910

2011
// Deny warnings on CI to keep our code warning-free as it lands in-tree. Don't
2112
// do this on nightly though since there's a fair amount of warning churn there.

.github/workflows/main.yml

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
path: |
3232
c-dependencies/spidermonkey/${{ matrix.profile }}
3333
key: cache-${{ hashFiles('c-dependencies/spidermonkey/build-engine.sh') }}-${{ hashFiles('c-dependencies/spidermonkey/gecko-revision') }}-${{ hashFiles('c-dependencies/spidermonkey/object-files.list') }}-${{ matrix.profile }}
34+
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
3435

3536
- name: "Build SpiderMonkey"
3637
if: steps.sm-cache.outputs.cache-hit != 'true'
@@ -46,12 +47,10 @@ jobs:
4647
sudo mkdir -p /opt/wasi-sdk
4748
sudo mv wasi-sdk-12.0/* /opt/wasi-sdk/
4849
49-
- name: "Install pinned Rust version and wasm32-wasi target"
50+
- name: "Install pinned Rust version"
5051
run: |
51-
rustup set profile minimal
52-
rustup update 1.57.0 --no-self-update
53-
rustup default 1.57.0
54-
rustup target add wasm32-wasi
52+
cd c-dependencies/js-compute-runtime
53+
rustup show
5554
5655
- name: "Install Binaryen (linux)"
5756
run: |
@@ -60,24 +59,24 @@ jobs:
6059
curl -sS -L "https://github.com/WebAssembly/binaryen/releases/download/version_${BINARYEN_VERSION}/binaryen-version_${BINARYEN_VERSION}-x86_64-linux.tar.gz" | tar xzf - &&
6160
echo "$PWD/binaryen-version_${BINARYEN_VERSION}/bin" >> $GITHUB_PATH
6261
62+
- name: Cache Rust dependencies
63+
uses: actions/cache@v3
64+
with:
65+
path: |
66+
~/.cargo/bin/
67+
~/.cargo/registry/index/
68+
~/.cargo/registry/cache/
69+
~/.cargo/git/db/
70+
c-dependencies/js-compute-runtime/rusturl
71+
key: ${{ runner.os }}-cargo-${{ hashFiles('c-dependencies/js-compute-runtime/**/Cargo.*') }}
72+
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
73+
6374
- name: "Build JS runtime (debug)"
64-
run: |
65-
set -x
66-
mkdir dist
67-
cd dist
68-
DEBUG=1 CXX_OPT="-O1" make -f ../c-dependencies/js-compute-runtime/Makefile
69-
rm *.{d,o}
70-
cd ..
75+
run: DEBUG=1 CXX_OPT="-O1" make -C c-dependencies/js-compute-runtime DESTDIR=$PWD install
7176
if: matrix.profile == 'debug'
7277

7378
- name: "Build JS runtime (release)"
74-
run: |
75-
set -x
76-
mkdir dist
77-
cd dist
78-
make -f ../c-dependencies/js-compute-runtime/Makefile
79-
rm *.{d,o}
80-
cd ..
79+
run: make -C c-dependencies/js-compute-runtime DESTDIR=$PWD install
8180
if: matrix.profile == 'release'
8281

8382
- uses: actions/upload-artifact@v1
@@ -204,7 +203,7 @@ jobs:
204203
~/.cargo/git/db/
205204
target/
206205
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
207-
if: github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/v')
206+
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
208207

209208
# Build `js-compute-runtime`
210209
- run: PREBUILT_ENGINE=engine-release/js-compute-runtime.wasm $CENTOS cargo build --release

c-dependencies/js-compute-runtime/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
SHELL:=/bin/bash
22
INIT_JS ?= test.js
33
WIZER ?= wizer
4+
DESTDIR ?= .
45

56
CXX_OPT ?= -O2
67

@@ -29,7 +30,7 @@ CXX_FLAGS := -std=gnu++17 -Wall -Werror -Qunused-arguments -fno-sized-deallocati
2930
DEFINES ?=
3031
LD_FLAGS := -Wl,-z,noexecstack -Wl,-z,text -Wl,-z,relro -Wl,-z,nocopyreloc -Wl,-z,stack-size=1048576 -Wl,--stack-first
3132

32-
.PHONY: all clean compile_commands.json
33+
.PHONY: all install clean distclean
3334

3435
all: js-compute-runtime.wasm
3536

@@ -65,6 +66,9 @@ js-compute-runtime.wasm: $(FSM_OBJ) $(SM_OBJ) $(RUST_URL_LIB)
6566
initialized-js-compute-runtime.wasm: js-compute-runtime.wasm $(INIT_JS)
6667
cat $(INIT_JS) | $(WIZER) --allow-wasi --dir=. -r _start=wizer.resume -o $@ $<
6768

69+
install: js-compute-runtime.wasm
70+
install -m 444 -Dt $(DESTDIR)/dist js-compute-runtime.wasm
71+
6872
clean:
6973
$(RM) compile_commands.json $(FSM_OBJ)
7074

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[toolchain]
2+
# we're stuck on 1.57 until we can upgrade past wasi-sdk-12
3+
channel = "1.57.0"
4+
targets = [ "wasm32-wasi" ]
5+
profile = "minimal"

rust-toolchain.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[toolchain]
2+
channel = "stable"
3+
profile = "minimal"

0 commit comments

Comments
 (0)