|
| 1 | +name: Cache Rust compilation |
| 2 | +description: Share completed compiler objects across Cargo, uv, maturin, and Make builds. |
| 3 | +inputs: |
| 4 | + suffix: |
| 5 | + description: Job and matrix partition for the compiler cache. |
| 6 | + required: true |
| 7 | +outputs: |
| 8 | + key: |
| 9 | + description: Key used by the Boxington action. |
| 10 | + value: ${{ steps.cache.outputs.cache-primary-key }} |
| 11 | +runs: |
| 12 | + using: composite |
| 13 | + steps: |
| 14 | + # Upstream 1.11.0 publishes ARM macOS binaries, but no Intel macOS binary. |
| 15 | + # Bootstrap that host once, then reuse the pinned executable across jobs. |
| 16 | + - uses: actions/cache/restore@v4 |
| 17 | + if: runner.os == 'macOS' && runner.arch == 'X64' |
| 18 | + id: intel |
| 19 | + with: |
| 20 | + path: ${{ runner.temp }}/mbx-intel/bin/mbx |
| 21 | + key: mbx-1.11.0-macos-x64-v1 |
| 22 | + |
| 23 | + - name: Build Boxington for Intel macOS |
| 24 | + if: runner.os == 'macOS' && runner.arch == 'X64' && steps.intel.outputs.cache-hit != 'true' |
| 25 | + shell: bash |
| 26 | + run: cargo install --git https://github.com/jdx/mr-boxington --rev 4ebd2af1eb7e70fee37ec8678c30c0619f5ed5af --locked --root "$RUNNER_TEMP/mbx-intel" mbx |
| 27 | + |
| 28 | + - uses: actions/cache/save@v4 |
| 29 | + if: runner.os == 'macOS' && runner.arch == 'X64' && steps.intel.outputs.cache-hit != 'true' |
| 30 | + with: |
| 31 | + path: ${{ runner.temp }}/mbx-intel/bin/mbx |
| 32 | + key: mbx-1.11.0-macos-x64-v1 |
| 33 | + |
| 34 | + - name: Enable pinned Intel Boxington |
| 35 | + if: runner.os == 'macOS' && runner.arch == 'X64' |
| 36 | + shell: bash |
| 37 | + run: | |
| 38 | + test "$("$RUNNER_TEMP/mbx-intel/bin/mbx" --version)" = 'mbx 1.11.0' |
| 39 | + echo "$RUNNER_TEMP/mbx-intel/bin" >> "$GITHUB_PATH" |
| 40 | +
|
| 41 | + - uses: jdx/mr-boxington-action@a20e1ffcd962370fb2b6045c13b7b349f7b03386 |
| 42 | + id: cache |
| 43 | + env: |
| 44 | + MBX_CACHE_DIR: ${{ github.workspace }}/.ci-mbx |
| 45 | + MBX_TARGET_VIEWS: '0' |
| 46 | + with: |
| 47 | + version: ${{ (runner.os != 'macOS' || runner.arch != 'X64') && '1.11.0' || '' }} |
| 48 | + github-cache-mode: objects |
| 49 | + cache-generation: sidemantic-v1-${{ inputs.suffix }} |
| 50 | + |
| 51 | + - name: Remove imported Rust cache archive |
| 52 | + env: |
| 53 | + MBX_CACHE_DIR: ${{ github.workspace }}/.ci-mbx |
| 54 | + shell: bash |
| 55 | + run: | |
| 56 | + # The pinned action imports this transport archive but leaves it on disk. |
| 57 | + # Export writes a new full-size temporary tar before replacing this path; |
| 58 | + # keep the imported objects and targets, not a second copy of their bytes. |
| 59 | + rm -f -- "$(mbx cache dir)/github-actions-cache-v1.tar" |
| 60 | +
|
| 61 | + - name: Enable Cargo subprocess caching |
| 62 | + shell: bash |
| 63 | + run: | |
| 64 | + # mbx dispatches as a Cargo shim when invoked under Cargo's filename. |
| 65 | + # Keep the shim in the workspace so maturin's workspace mount can use it too. |
| 66 | + shim_dir="$GITHUB_WORKSPACE/.ci-cache-bin" |
| 67 | + mkdir -p "$shim_dir" |
| 68 | + if [ "$RUNNER_OS" = Windows ]; then |
| 69 | + cp "$(command -v mbx)" "$shim_dir/cargo.exe" |
| 70 | + else |
| 71 | + cp "$(command -v mbx)" "$shim_dir/cargo" |
| 72 | + chmod +x "$shim_dir/cargo" |
| 73 | + fi |
| 74 | + echo "$shim_dir" >> "$GITHUB_PATH" |
| 75 | + echo "MBX_CACHE_DIR=$GITHUB_WORKSPACE/.ci-mbx" >> "$GITHUB_ENV" |
| 76 | + echo "MBX_TARGET_VIEWS=0" >> "$GITHUB_ENV" |
0 commit comments