From 6a78e38270aa895a7873de6d3ae6b6ee430f4dbe Mon Sep 17 00:00:00 2001 From: IWonderWhatThisAPIDoes Date: Sun, 20 Jul 2025 23:02:27 +0200 Subject: [PATCH 1/8] Use cache and artifacts correctly --- .github/workflows/ci.yaml | 186 ++++++++++++++++++-------------------- 1 file changed, 88 insertions(+), 98 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index cbfd0b5..71037ae 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -8,20 +8,9 @@ on: jobs: - cache-key: - runs-on: ubuntu-latest - name: Create cache key suffix - outputs: - suffix: ${{ steps.generate.outputs.suffix }} - steps: - - id: generate - name: Generate suffix - run: echo "suffix=$RANDOM" >> $GITHUB_OUTPUT - build-jsapi: runs-on: ubuntu-latest name: Build JSAPI - needs: cache-key steps: - name: Checkout uses: actions/checkout@v4 @@ -32,137 +21,124 @@ jobs: - name: Build run: wasm-pack build jsapi --target bundler --features gdbstate - name: Save build outputs - uses: actions/cache/save@v3 - with: - path: jsapi/pkg - key: jsapi-package-${{ needs.cache-key.outputs.suffix }} - - npm-install: - runs-on: ubuntu-latest - name: Install Node packages - needs: - - build-jsapi - - cache-key - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Load JSAPI package - uses: actions/cache/restore@v3 - with: - path: jsapi/pkg - key: jsapi-package-${{ needs.cache-key.outputs.suffix }} - - name: Install Node.js - uses: actions/setup-node@v4 - - name: Install Node packages - run: npm ci - - name: Cache installed packages - uses: actions/cache/save@v3 - with: - path: node_modules - key: node-modules-${{ needs.cache-key.outputs.suffix }} - - name: Cache Puppeteer cache - uses: actions/cache/save@v3 + uses: actions/upload-artifact@v4 with: - path: ~/.cache/puppeteer - key: puppeteer-cache-${{ needs.cache-key.outputs.suffix }} + name: jsapi + path: jsapi/pkg/ + overwrite: true test-hooligan: runs-on: ubuntu-latest name: Tests (hooligan) - needs: - - npm-install - - cache-key steps: - name: Checkout uses: actions/checkout@v4 - name: Install Node.js uses: actions/setup-node@v4 - name: Load Node packages - uses: actions/cache/restore@v3 + id: cache-npm + uses: actions/cache@v4 with: - path: node_modules - key: node-modules-${{ needs.cache-key.outputs.suffix }} + path: | + node_modules + ~/.cache/puppeteer + key: node-modules-${{ hashFiles('package-lock.json') }} + restore-keys: node-modules- + - name: Install Node packages + if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} + run: npm ci - name: Run tests run: npm test -w hooligan doc-hooligan: runs-on: ubuntu-latest name: Docs (hooligan) - needs: - - npm-install - - cache-key steps: - name: Checkout uses: actions/checkout@v4 - name: Install Node.js uses: actions/setup-node@v4 - name: Load Node packages - uses: actions/cache/restore@v3 + id: cache-npm + uses: actions/cache@v4 with: - path: node_modules - key: node-modules-${{ needs.cache-key.outputs.suffix }} + path: | + node_modules + ~/.cache/puppeteer + key: node-modules-${{ hashFiles('package-lock.json') }} + restore-keys: node-modules- + - name: Install Node packages + if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} + run: npm ci - name: Check documentation run: npm run doc -w hooligan test-vis: runs-on: ubuntu-latest name: Tests (vis) - needs: - - npm-install - - cache-key steps: - name: Checkout uses: actions/checkout@v4 - name: Install Node.js uses: actions/setup-node@v4 - name: Load Node packages - uses: actions/cache/restore@v3 + id: cache-npm + uses: actions/cache@v4 with: - path: node_modules - key: node-modules-${{ needs.cache-key.outputs.suffix }} - - name: Load Puppeteer cache - uses: actions/cache/restore@v3 - with: - path: ~/.cache/puppeteer - key: puppeteer-cache-${{ needs.cache-key.outputs.suffix }} + path: | + node_modules + ~/.cache/puppeteer + key: node-modules-${{ hashFiles('package-lock.json') }} + restore-keys: node-modules- + - name: Install Node packages + if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} + run: npm ci - name: Run tests run: npm test -w vis doc-vis: runs-on: ubuntu-latest name: Docs (vis) - needs: - - npm-install - - cache-key steps: - name: Checkout uses: actions/checkout@v4 - name: Install Node.js uses: actions/setup-node@v4 - name: Load Node packages - uses: actions/cache/restore@v3 + id: cache-npm + uses: actions/cache@v4 with: - path: node_modules - key: node-modules-${{ needs.cache-key.outputs.suffix }} + path: | + node_modules + ~/.cache/puppeteer + key: node-modules-${{ hashFiles('package-lock.json') }} + restore-keys: node-modules- + - name: Install Node packages + if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} + run: npm ci - name: Check documentation run: npm run doc -w vis examples-vis: runs-on: ubuntu-latest name: Examples (vis) - needs: - - npm-install - - cache-key steps: - name: Checkout uses: actions/checkout@v4 - name: Install Node.js uses: actions/setup-node@v4 - name: Load Node packages - uses: actions/cache/restore@v3 + id: cache-npm + uses: actions/cache@v4 with: - path: node_modules - key: node-modules-${{ needs.cache-key.outputs.suffix }} + path: | + node_modules + ~/.cache/puppeteer + key: node-modules-${{ hashFiles('package-lock.json') }} + restore-keys: node-modules- + - name: Install Node packages + if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} + run: npm ci - name: Check examples run: npm run examples -w vis @@ -238,42 +214,51 @@ jobs: name: Build Demo needs: - build-jsapi - - npm-install - - cache-key steps: - name: Checkout uses: actions/checkout@v4 - name: Install Node.js uses: actions/setup-node@v4 - name: Load Node packages - uses: actions/cache/restore@v3 + id: cache-npm + uses: actions/cache@v4 with: - path: node_modules - key: node-modules-${{ needs.cache-key.outputs.suffix }} + path: | + node_modules + ~/.cache/puppeteer + key: node-modules-${{ hashFiles('package-lock.json') }} + restore-keys: node-modules- + - name: Install Node packages + if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} + run: npm ci - name: Load JSAPI - uses: actions/cache/restore@v3 + uses: actions/download-artifact@v4 with: + name: jsapi path: jsapi/pkg - key: jsapi-package-${{ needs.cache-key.outputs.suffix }} - name: Build Demo run: npm run build -w demo doc-debugger: runs-on: ubuntu-latest name: Docs (debugger) - needs: - - npm-install - - cache-key steps: - name: Checkout uses: actions/checkout@v4 - name: Install Node.js uses: actions/setup-node@v4 - name: Load Node packages - uses: actions/cache/restore@v3 + id: cache-npm + uses: actions/cache@v4 with: - path: node_modules - key: node-modules-${{ needs.cache-key.outputs.suffix }} + path: | + node_modules + ~/.cache/puppeteer + key: node-modules-${{ hashFiles('package-lock.json') }} + restore-keys: node-modules- + - name: Install Node packages + if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} + run: npm ci - name: Check documentation run: npm run doc -w debugger @@ -282,23 +267,28 @@ jobs: name: Build Debugger needs: - build-jsapi - - npm-install - - cache-key steps: - name: Checkout uses: actions/checkout@v4 - name: Install Node.js uses: actions/setup-node@v4 - name: Load Node packages - uses: actions/cache/restore@v3 + id: cache-npm + uses: actions/cache@v4 with: - path: node_modules - key: node-modules-${{ needs.cache-key.outputs.suffix }} + path: | + node_modules + ~/.cache/puppeteer + key: node-modules-${{ hashFiles('package-lock.json') }} + restore-keys: node-modules- + - name: Install Node packages + if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} + run: npm ci - name: Load JSAPI - uses: actions/cache/restore@v3 + uses: actions/download-artifact@v4 with: + name: jsapi path: jsapi/pkg - key: jsapi-package-${{ needs.cache-key.outputs.suffix }} - name: Build Debugger run: npm run build -w debugger - name: Upload artifact From 86c1cb57c553d4b89ca300ef61fb36e9a360d683 Mon Sep 17 00:00:00 2001 From: IWonderWhatThisAPIDoes Date: Sun, 20 Jul 2025 23:38:51 +0200 Subject: [PATCH 2/8] Cache Cargo dependencies --- .github/workflows/ci.yaml | 54 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 71037ae..2d998fa 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,6 +14,15 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + - name: Load Cargo cache + uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + key: cargo-crates-${{ hashFiles('Cargo.lock') }} - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable - name: Install wasm-pack @@ -148,6 +157,15 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + - name: Load Cargo cache + uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + key: cargo-crates-${{ hashFiles('Cargo.lock') }} - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable - name: Run tests, except GDBState @@ -161,6 +179,15 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + - name: Load Cargo cache + uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + key: cargo-crates-${{ hashFiles('Cargo.lock') }} - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable - name: Update package manager @@ -176,6 +203,15 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + - name: Load Cargo cache + uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + key: cargo-crates-${{ hashFiles('Cargo.lock') }} - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable with: @@ -189,6 +225,15 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + - name: Load Cargo cache + uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + key: cargo-crates-${{ hashFiles('Cargo.lock') }} - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable with: @@ -202,6 +247,15 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + - name: Load Cargo cache + uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + key: cargo-crates-${{ hashFiles('Cargo.lock') }} - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable with: From 68ae77a7f56db5a86ff650a13fd96e6235529830 Mon Sep 17 00:00:00 2001 From: IWonderWhatThisAPIDoes Date: Sun, 20 Jul 2025 23:45:52 +0200 Subject: [PATCH 3/8] Use rustdoc for documentation --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2d998fa..ed76462 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -259,7 +259,7 @@ jobs: - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable with: - components: rustfmt + components: rustdoc - name: Check documentation run: RUSTDOCFLAGS="-D warnings" cargo doc --workspace --document-private-items --no-deps --all-features From 58cfd2fef8a8844bdb9d0a026717f6a2749e9c2d Mon Sep 17 00:00:00 2001 From: IWonderWhatThisAPIDoes Date: Sun, 20 Jul 2025 23:51:49 +0200 Subject: [PATCH 4/8] Cache dependencies compiled to wasm --- .github/workflows/ci.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ed76462..f55bd7f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -23,6 +23,12 @@ jobs: ~/.cargo/registry/cache/ ~/.cargo/git/db/ key: cargo-crates-${{ hashFiles('Cargo.lock') }} + - name: Load cached build outputs + uses: actions/cache@v4 + with: + path: target/wasm32-unknown-unknown + key: target-wasm-${{ hashFiles('Cargo.lock') }} + restore-keys: target-wasm- - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable - name: Install wasm-pack From 24054ac9daa822156d07db59043f35ce4c0871af Mon Sep 17 00:00:00 2001 From: IWonderWhatThisAPIDoes Date: Sun, 20 Jul 2025 23:52:52 +0200 Subject: [PATCH 5/8] Add restore key to cargo cache --- .github/workflows/ci.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f55bd7f..7f3aa07 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -23,6 +23,7 @@ jobs: ~/.cargo/registry/cache/ ~/.cargo/git/db/ key: cargo-crates-${{ hashFiles('Cargo.lock') }} + restore-keys: cargo-crates- - name: Load cached build outputs uses: actions/cache@v4 with: @@ -172,6 +173,7 @@ jobs: ~/.cargo/registry/cache/ ~/.cargo/git/db/ key: cargo-crates-${{ hashFiles('Cargo.lock') }} + restore-keys: cargo-crates- - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable - name: Run tests, except GDBState @@ -194,6 +196,7 @@ jobs: ~/.cargo/registry/cache/ ~/.cargo/git/db/ key: cargo-crates-${{ hashFiles('Cargo.lock') }} + restore-keys: cargo-crates- - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable - name: Update package manager @@ -218,6 +221,7 @@ jobs: ~/.cargo/registry/cache/ ~/.cargo/git/db/ key: cargo-crates-${{ hashFiles('Cargo.lock') }} + restore-keys: cargo-crates- - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable with: @@ -240,6 +244,7 @@ jobs: ~/.cargo/registry/cache/ ~/.cargo/git/db/ key: cargo-crates-${{ hashFiles('Cargo.lock') }} + restore-keys: cargo-crates- - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable with: @@ -262,6 +267,7 @@ jobs: ~/.cargo/registry/cache/ ~/.cargo/git/db/ key: cargo-crates-${{ hashFiles('Cargo.lock') }} + restore-keys: cargo-crates- - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable with: From e7fd997e0555f85cab70ed4c7032c6cfcaed973b Mon Sep 17 00:00:00 2001 From: IWonderWhatThisAPIDoes Date: Sun, 20 Jul 2025 23:56:17 +0200 Subject: [PATCH 6/8] Rustdoc is a default component --- .github/workflows/ci.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7f3aa07..a6909b9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -270,8 +270,6 @@ jobs: restore-keys: cargo-crates- - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable - with: - components: rustdoc - name: Check documentation run: RUSTDOCFLAGS="-D warnings" cargo doc --workspace --document-private-items --no-deps --all-features From bf898d501c699007d34135813fb7a1628fa52bb7 Mon Sep 17 00:00:00 2001 From: IWonderWhatThisAPIDoes Date: Mon, 21 Jul 2025 21:41:35 +0200 Subject: [PATCH 7/8] Include release directory in wasm build cache --- .github/workflows/ci.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a6909b9..06352c6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -27,7 +27,9 @@ jobs: - name: Load cached build outputs uses: actions/cache@v4 with: - path: target/wasm32-unknown-unknown + path: | + target/wasm32-unknown-unknown + target/release key: target-wasm-${{ hashFiles('Cargo.lock') }} restore-keys: target-wasm- - name: Install Rust toolchain From 3565fd04b376a7efda84f9e786af23332b2937e9 Mon Sep 17 00:00:00 2001 From: IWonderWhatThisAPIDoes Date: Thu, 21 Aug 2025 20:13:24 +0200 Subject: [PATCH 8/8] ci: Cache cargo build outputs --- .github/workflows/ci.yaml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 06352c6..507a0ae 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -176,6 +176,13 @@ jobs: ~/.cargo/git/db/ key: cargo-crates-${{ hashFiles('Cargo.lock') }} restore-keys: cargo-crates- + - name: Load cached build outputs + uses: actions/cache@v4 + with: + path: | + target/debug + key: target-debug-${{ hashFiles('Cargo.lock') }} + restore-keys: target-debug- - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable - name: Run tests, except GDBState @@ -199,6 +206,15 @@ jobs: ~/.cargo/git/db/ key: cargo-crates-${{ hashFiles('Cargo.lock') }} restore-keys: cargo-crates- + - name: Load cached build outputs + # Never save the cache from this job, as it does not + # generate all the build outputs (let some other job save it) + uses: actions/cache/restore@v4 + with: + path: | + target/debug + key: target-debug-${{ hashFiles('Cargo.lock') }} + restore-keys: target-debug- - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable - name: Update package manager @@ -224,6 +240,13 @@ jobs: ~/.cargo/git/db/ key: cargo-crates-${{ hashFiles('Cargo.lock') }} restore-keys: cargo-crates- + - name: Load cached build outputs + uses: actions/cache@v4 + with: + path: | + target/debug + key: target-debug-${{ hashFiles('Cargo.lock') }} + restore-keys: target-debug- - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable with: