|
| 1 | +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json |
| 2 | + |
| 3 | +# Builds on main to populate the GitHub Actions cache for all Swatinem/rust-cache |
| 4 | +# shared-keys used by PR workflows. Caches saved on `refs/heads/main` are |
| 5 | +# restorable from every PR via the base-branch fallback. PR workflows are |
| 6 | +# configured with `save-if: github.ref == 'refs/heads/main'`, so they only ever |
| 7 | +# read from this cache. |
| 8 | +# |
| 9 | +# No tests are run here. The goal is just to populate dependency build artifacts |
| 10 | +# so that PR jobs start warm. |
| 11 | + |
| 12 | +name: Prime Caches |
| 13 | + |
| 14 | +on: |
| 15 | + push: |
| 16 | + branches: [main] |
| 17 | + workflow_dispatch: |
| 18 | + |
| 19 | +env: |
| 20 | + CARGO_TERM_COLOR: always |
| 21 | + RUST_BACKTRACE: full |
| 22 | + |
| 23 | +permissions: |
| 24 | + contents: read |
| 25 | + |
| 26 | +defaults: |
| 27 | + run: |
| 28 | + shell: bash |
| 29 | + |
| 30 | +jobs: |
| 31 | + # Populate v0-rust-guests-{debug,release}-Linux-x64 caches. |
| 32 | + guests: |
| 33 | + strategy: |
| 34 | + fail-fast: false |
| 35 | + matrix: |
| 36 | + config: [debug, release] |
| 37 | + uses: ./.github/workflows/dep_build_guests.yml |
| 38 | + secrets: inherit |
| 39 | + with: |
| 40 | + config: ${{ matrix.config }} |
| 41 | + |
| 42 | + # Populate v0-rust-code-checks-{linux,windows} caches. |
| 43 | + code-checks: |
| 44 | + uses: ./.github/workflows/dep_code_checks.yml |
| 45 | + secrets: inherit |
| 46 | + |
| 47 | + # Populate v0-rust-{Linux,Windows}-{hypervisor}-{debug,release} caches used |
| 48 | + # by dep_build_test.yml. Linux is primed once per hypervisor because the kvm |
| 49 | + # pools run Ubuntu and the mshv3 pools run Azure Linux 3, and we want each |
| 50 | + # distro to restore a cache produced under its own libc. Only the host |
| 51 | + # dependency graph is built here, no tests are run. |
| 52 | + host: |
| 53 | + strategy: |
| 54 | + fail-fast: false |
| 55 | + matrix: |
| 56 | + include: |
| 57 | + - hypervisor: kvm |
| 58 | + config: debug |
| 59 | + - hypervisor: kvm |
| 60 | + config: release |
| 61 | + - hypervisor: mshv3 |
| 62 | + config: debug |
| 63 | + - hypervisor: mshv3 |
| 64 | + config: release |
| 65 | + - hypervisor: hyperv-ws2025 |
| 66 | + config: debug |
| 67 | + - hypervisor: hyperv-ws2025 |
| 68 | + config: release |
| 69 | + timeout-minutes: 30 |
| 70 | + runs-on: ${{ fromJson( |
| 71 | + format('["self-hosted", "{0}", "X64", "1ES.Pool=hld-{1}-amd", "JobId=prime-cache-{2}-{3}-{4}-{5}-{6}"]', |
| 72 | + matrix.hypervisor == 'hyperv-ws2025' && 'Windows' || 'Linux', |
| 73 | + matrix.hypervisor == 'hyperv-ws2025' && 'win2025' || matrix.hypervisor == 'mshv3' && 'azlinux3-mshv' || matrix.hypervisor, |
| 74 | + matrix.hypervisor, |
| 75 | + matrix.config, |
| 76 | + github.run_id, |
| 77 | + github.run_number, |
| 78 | + github.run_attempt)) }} |
| 79 | + steps: |
| 80 | + - uses: actions/checkout@v6 |
| 81 | + |
| 82 | + - uses: hyperlight-dev/ci-setup-workflow@v1.9.0 |
| 83 | + with: |
| 84 | + rust-toolchain: "1.89" |
| 85 | + env: |
| 86 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 87 | + |
| 88 | + - name: Fix cargo home permissions |
| 89 | + if: runner.os == 'Linux' |
| 90 | + run: | |
| 91 | + sudo chown -R $(id -u):$(id -g) /opt/cargo || true |
| 92 | +
|
| 93 | + - name: Rust cache |
| 94 | + uses: Swatinem/rust-cache@v2 |
| 95 | + with: |
| 96 | + shared-key: "${{ runner.os }}-${{ matrix.hypervisor }}-${{ matrix.config }}" |
| 97 | + cache-on-failure: "true" |
| 98 | + # Only save on main as caches are not shared across branches. |
| 99 | + # https://docs.github.com/en/actions/reference/workflows-and-actions/dependency-caching#restrictions-for-accessing-a-cache |
| 100 | + save-if: ${{ github.ref == 'refs/heads/main' }} |
| 101 | + |
| 102 | + - name: Build host |
| 103 | + run: just build ${{ matrix.config }} |
0 commit comments