diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index cbfd0b5..507a0ae 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -8,23 +8,30 @@ 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 + - 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') }} + restore-keys: cargo-crates- + - name: Load cached build outputs + uses: actions/cache@v4 + with: + path: | + target/wasm32-unknown-unknown + target/release + key: target-wasm-${{ hashFiles('Cargo.lock') }} + restore-keys: target-wasm- - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable - name: Install wasm-pack @@ -32,137 +39,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 @@ -172,6 +166,23 @@ 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') }} + 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 @@ -185,6 +196,25 @@ 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') }} + 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 @@ -200,6 +230,23 @@ 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') }} + 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: @@ -213,6 +260,16 @@ 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') }} + restore-keys: cargo-crates- - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable with: @@ -226,10 +283,18 @@ 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') }} + restore-keys: cargo-crates- - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable - with: - components: rustfmt - name: Check documentation run: RUSTDOCFLAGS="-D warnings" cargo doc --workspace --document-private-items --no-deps --all-features @@ -238,42 +303,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 +356,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