Make sccache fallback non-fatal in workflows #7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: pnpm/action-setup@v4 | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 20 | |
| cache: pnpm | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Lint | |
| run: pnpm run lint | |
| test: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: pnpm/action-setup@v4 | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 20 | |
| cache: pnpm | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Test | |
| run: pnpm run test | |
| build-native: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: macos-latest | |
| target: x86_64-apple-darwin | |
| cross_compile: false | |
| - os: macos-latest | |
| target: aarch64-apple-darwin | |
| cross_compile: false | |
| - os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| cross_compile: false | |
| - os: windows-latest | |
| target: aarch64-pc-windows-msvc | |
| cross_compile: false | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| cross_compile: false | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-musl | |
| cross_compile: true | |
| - os: ubuntu-24.04-arm | |
| target: aarch64-unknown-linux-gnu | |
| cross_compile: false | |
| - os: ubuntu-24.04-arm | |
| target: aarch64-unknown-linux-musl | |
| cross_compile: true | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: pnpm/action-setup@v4 | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 20 | |
| cache: pnpm | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Install sccache | |
| uses: mozilla-actions/sccache-action@v0.0.7 | |
| - name: Configure sccache | |
| id: sccache | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| echo "SCCACHE_GHA_ENABLED=true" >> "$GITHUB_ENV" | |
| if sccache --start-server >/dev/null 2>&1; then | |
| echo "RUSTC_WRAPPER=sccache" >> "$GITHUB_ENV" | |
| echo "enabled=true" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| echo "SCCACHE_GHA_ENABLED=false" >> "$GITHUB_ENV" | |
| sccache --stop-server >/dev/null 2>&1 || true | |
| if sccache --start-server >/dev/null 2>&1; then | |
| echo "RUSTC_WRAPPER=sccache" >> "$GITHUB_ENV" | |
| echo "enabled=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "enabled=false" >> "$GITHUB_OUTPUT" | |
| echo "sccache unavailable; continuing without RUSTC_WRAPPER" | |
| fi | |
| - name: Cache Rust build | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| shared-key: native-${{ matrix.target }} | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Install Zig | |
| if: matrix.cross_compile | |
| uses: goto-bus-stop/setup-zig@v2 | |
| - name: Build native target | |
| if: ${{ !matrix.cross_compile }} | |
| run: pnpm exec napi build --platform --release --target ${{ matrix.target }} | |
| - name: Build native target (cross) | |
| if: matrix.cross_compile | |
| run: pnpm exec napi build --platform --release --cross-compile --target ${{ matrix.target }} | |
| - name: Upload native artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: native-${{ matrix.target }} | |
| path: slatedb-node.*.node | |
| if-no-files-found: error | |
| - name: Show sccache stats | |
| if: always() && steps.sccache.outputs.enabled == 'true' | |
| run: sccache --show-stats |