Skip to content

Commit

Permalink
Improve caching on CI (#5772)
Browse files Browse the repository at this point in the history
* Try to build WASM on Ubuntu

* Align cache keys for performance report/REPL

They can share the cache with the corresponding build jobs.

* Only save caches on master
  • Loading branch information
lukastaegert authored Dec 27, 2024
1 parent 5d37778 commit c54fb1b
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 42 deletions.
74 changes: 51 additions & 23 deletions .github/workflows/build-and-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 22
- name: Cache Node Modules
- name: Restore Node dependencies cache
id: cache-node-modules
uses: actions/cache@v4
uses: actions/cache/restore@v4
with:
path: node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
- name: Install Node dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci --ignore-scripts
- name: Lint
Expand All @@ -64,8 +64,8 @@ jobs:
matrix:
settings:
# WASM
- host: windows-latest
target: x86_64-pc-windows-msvc
- host: ubuntu-latest
target: wasm32-unknown-unknown
name: wasm
is-wasm-build: true
build: >-
Expand All @@ -75,8 +75,8 @@ jobs:
path: |
wasm/
.empty
- host: windows-latest
target: x86_64-pc-windows-msvc
- host: ubuntu-latest
target: wasm32-unknown-unknown
name: wasm-node
is-wasm-build: true
build: >-
Expand Down Expand Up @@ -222,8 +222,8 @@ jobs:
with:
toolchain: stable
targets: ${{ matrix.settings.target }}
- name: Cache cargo
uses: actions/cache@v4
- name: Restore Cargo cache
uses: actions/cache/restore@v4
with:
path: |
~/.cargo/registry/index/
Expand All @@ -241,15 +241,21 @@ jobs:
run: ${{ matrix.settings.setup }}
if: ${{ matrix.settings.setup }}
shell: bash
- name: Cache Node Modules
- name: Restore Node dependencies cache
id: cache-node-modules
uses: actions/cache@v4
uses: actions/cache/restore@v4
with:
path: node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
- name: Install Node dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci --ignore-scripts
- name: Save Node dependencies cache
if: steps.cache-node-modules.outputs.cache-hit != 'true' && github.ref == 'refs/heads/master'
uses: actions/cache/save@v4
with:
path: node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- name: Build in docker
uses: addnab/docker-run-action@v3
if: ${{ matrix.settings.docker }}
Expand All @@ -261,6 +267,17 @@ jobs:
run: ${{ matrix.settings.build }}
if: ${{ !matrix.settings.docker }}
shell: bash
- name: Save Cargo cache
if: github.ref == 'refs/heads/master'
uses: actions/cache/save@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
.cargo-cache
rust/target/
key: ${{ matrix.settings.name || matrix.settings.target }}-cargo-${{ matrix.settings.host }}-${{ hashFiles('rust/Cargo.lock') }}
- name: Upload wasm artifact
uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -295,8 +312,8 @@ jobs:
steps:
- name: Checkout Commit
uses: actions/checkout@v4
- name: Cache cargo
uses: actions/cache@v4
- name: Restore Cargo cache
uses: actions/cache/restore@v4
with:
path: |
~/.cargo/registry/index/
Expand All @@ -317,6 +334,17 @@ jobs:
sudo pkg install -y node npm rust
npm ci --ignore-scripts
npm run build:napi -- --release --target ${{ matrix.settings.target }}
- name: Save Cargo cache
if: github.ref == 'refs/heads/master'
uses: actions/cache/save@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
.cargo-cache
rust/target/
key: ${{ matrix.settings.target }}-cargo-${{ hashFiles('rust/Cargo.lock') }}
- name: Upload napi artifact
uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -365,13 +393,13 @@ jobs:
steps:
- name: Checkout Commit
uses: actions/checkout@v4
- name: Cache Node Modules
- name: Restore Node dependencies cache
id: cache-node-modules
uses: actions/cache@v4
uses: actions/cache/restore@v4
with:
path: node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
- name: Install Node dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci --ignore-scripts
- name: Build JS
Expand Down Expand Up @@ -460,13 +488,13 @@ jobs:
with:
node-version: ${{ matrix.node }}
check-latest: true
- name: Cache Node Modules
- name: Restore Node dependencies cache
id: cache-node-modules
uses: actions/cache@v4
uses: actions/cache/restore@v4
with:
path: node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
- name: Install Node dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci --ignore-scripts
- name: Download napi artifacts
Expand Down Expand Up @@ -515,13 +543,13 @@ jobs:
with:
node-version: ${{ matrix.node }}
check-latest: true
- name: Cache Node Modules
- name: Restore Node dependencies cache
id: cache-node-modules
uses: actions/cache@v4
uses: actions/cache/restore@v4
with:
path: node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
- name: Install Node dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci --ignore-scripts
- name: Download all artifacts
Expand Down
26 changes: 13 additions & 13 deletions .github/workflows/performance-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,28 @@ jobs:
with:
toolchain: stable
targets: x86_64-unknown-linux-gnu
- name: Cache cargo
uses: actions/cache@v4
- name: Restore Cargo cache
uses: actions/cache/restore@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
.cargo-cache
rust/target/
key: cargo-cache-${{ hashFiles('rust/Cargo.lock') }}
restore-keys: cargo-cache
key: x86_64-unknown-linux-gnu-cargo-ubuntu-latest-${{ hashFiles('rust/Cargo.lock') }}
restore-keys: x86_64-unknown-linux-gnu-cargo-ubuntu-latest
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 18
- name: Cache Node Modules
- name: Restore Node dependencies cache
id: cache-node-modules
uses: actions/cache@v4
uses: actions/cache/restore@v4
with:
path: node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
- name: Install Node dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci --ignore-scripts
- name: Build artefacts 123
Expand Down Expand Up @@ -86,24 +86,24 @@ jobs:
with:
toolchain: stable
targets: x86_64-unknown-linux-gnu
- name: Cache cargo
uses: actions/cache@v4
- name: Restore Cargo cache
uses: actions/cache/restore@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
.cargo-cache
rust/target/
key: cargo-cache-${{ hashFiles('rust/Cargo.lock') }}
restore-keys: cargo-cache
key: x86_64-unknown-linux-gnu-cargo-ubuntu-latest-${{ hashFiles('rust/Cargo.lock') }}
restore-keys: x86_64-unknown-linux-gnu-cargo-ubuntu-latest
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 18
- name: Cache Node Modules
- name: Restore Node dependencies cache
id: cache-node-modules
uses: actions/cache@v4
uses: actions/cache/restore@v4
with:
path: node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/repl-artefacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,24 @@ jobs:
with:
toolchain: stable
targets: wasm32-unknown-unknown
- name: Cache cargo
uses: actions/cache@v4
- name: Restore Cargo cache
uses: actions/cache/restore@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
.cargo-cache
rust/target/
key: cargo-cache-${{ hashFiles('rust/Cargo.lock') }}
restore-keys: cargo-cache
key: wasm-cargo-ubuntu-latest-${{ hashFiles('rust/Cargo.lock') }}
restore-keys: wasm-cargo-ubuntu-latest
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 18
- name: Cache Node Modules
- name: Restore Node dependencies cache
id: cache-node-modules
uses: actions/cache@v4
uses: actions/cache/restore@v4
with:
path: node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
Expand Down

0 comments on commit c54fb1b

Please sign in to comment.