|
| 1 | +name: Bazel patch compatibility (Cargo) |
| 2 | + |
| 3 | +# The Cargo flows of the real-Bazel tests (`cargo::` in `e2e_bazel_build`): |
| 4 | +# hosted and vendored mode for a crate that rules_rust's crate_universe |
| 5 | +# resolves from a Cargo workspace (`crate.from_cargo`, with the project's |
| 6 | +# cargo config and no cargo-bazel lock), on each Bazel release below. |
| 7 | +# bazel-compatibility.yml holds the legs and what every ecosystem shares; |
| 8 | +# this file says when the Cargo legs run and on which releases. |
| 9 | +# |
| 10 | +# Beyond what every leg needs, a Cargo leg downloads the Rust toolchain |
| 11 | +# from static.rust-lang.org, the cargo-bazel binary and ruleset archives |
| 12 | +# from github.com, and the crates rules_rust builds its own tools from, from |
| 13 | +# static.crates.io (60 of them with rules_rust 0.75.0, one with 0.56.0). |
| 14 | +# Its repository cache holds all of it. For the era of rules_rust 0.75.0 |
| 15 | +# it comes to about 230 MB after one Bazel release and about 240 MB once |
| 16 | +# both releases of the era have used it, and to about 155 MB for the era of |
| 17 | +# 0.56.0 (macOS arm64). Every workspace copy unpacks the toolchain for |
| 18 | +# itself, about 1.8 GB, and a leg has two at a time, one per test: a test |
| 19 | +# removes its first copy before its second machine builds (3.6 GB at the |
| 20 | +# peak on Bazel 9.3.2, macOS arm64). |
| 21 | +# |
| 22 | +# No leg asks crates.io about the crate under test. cargo-bazel's cargo |
| 23 | +# reads no downloader config, so the test's workspace names a mirror of |
| 24 | +# crates.io in its `.cargo/config.toml`, the loopback stand-in, and the |
| 25 | +# crate has a name crates.io cannot hold. A crate file under test passes |
| 26 | +# through the repository cache as well: Bazel's downloader fetches it and |
| 27 | +# keeps it under its sha256. So a test builds the upstream crate file and |
| 28 | +# each patched one anew, with an id of the run in the library, and writes |
| 29 | +# the upstream checksum into the Cargo.lock of its workspace copy. No cache |
| 30 | +# holds a crate file of the run, and the test counts the requests for the |
| 31 | +# upstream one. |
| 32 | +# |
| 33 | +# Not required for merge: no `merge_group` trigger, and no job here is a |
| 34 | +# `needs` of ci.yml's `ci-ok`. |
| 35 | + |
| 36 | +on: |
| 37 | + pull_request: |
| 38 | + types: [opened, synchronize, reopened, ready_for_review] |
| 39 | + # What a pull request run covers: the Cargo flows and their fixture, the |
| 40 | + # harness and the workflows that run it, the Bazel installer and its |
| 41 | + # pins, and the Cargo files of socket-patch-core, which the two globs |
| 42 | + # name by the `cargo` in a file's or a directory's name: the Cargo.lock |
| 43 | + # and Cargo.toml models with the hosted planner and the reader of a |
| 44 | + # source replacement (formats/cargo/), the vendored backend |
| 45 | + # (vendor/cargo*, the lock inventory), the upstream restore of |
| 46 | + # `rollback`, the crawler every `scan` starts, the cargo home and |
| 47 | + # workspace lookups, and the reader of a Cargo project that `vex` runs |
| 48 | + # (vex/discover/cargo.rs). They also match Cargo files no flow runs |
| 49 | + # (agent mode's sidecars and build cache), which are no other |
| 50 | + # ecosystem's either. One more file is here for what the flows |
| 51 | + # run through: patch/user_patches.rs, the inspection of the project's |
| 52 | + # own patches, which reads the Cargo.toml and the cargo config of every |
| 53 | + # scan. That file also holds the npm, Composer and Go parts of the |
| 54 | + # gate, so a change to those starts the Cargo legs too. The globs name |
| 55 | + # that one crate, so no bench fixture is here, and nothing another |
| 56 | + # ecosystem's flow owns: a change to one ecosystem starts that |
| 57 | + # ecosystem's legs only. |
| 58 | + # |
| 59 | + # What it does not cover: shared engine code (patch/redirect/mod.rs, |
| 60 | + # the rest of vendor/, hosted/, commands/), the shared test helpers and |
| 61 | + # the toolchain files. A change there gets its run on the push to main |
| 62 | + # (when the file is in the list below) or in the nightly run, not on the |
| 63 | + # pull request: that is the price of not running every ecosystem's legs |
| 64 | + # on every shared change. On demand, workflow_dispatch runs the legs on |
| 65 | + # any branch. |
| 66 | + paths: |
| 67 | + - '.github/workflows/bazel-cargo.yml' |
| 68 | + - '.github/workflows/bazel-compatibility.yml' |
| 69 | + - 'scripts/install-bazel.sh' |
| 70 | + - 'scripts/bazel-pins.txt' |
| 71 | + - 'crates/socket-patch-cli/tests/e2e_bazel_build/cargo.rs' |
| 72 | + - 'crates/socket-patch-cli/tests/e2e_bazel_build/harness.rs' |
| 73 | + - 'crates/socket-patch-cli/tests/fixtures/bazel/rules_rust/**' |
| 74 | + - 'crates/socket-patch-core/src/**/*cargo*' |
| 75 | + - 'crates/socket-patch-core/src/**/*cargo*/**' |
| 76 | + - 'crates/socket-patch-core/src/patch/user_patches.rs' |
| 77 | + push: |
| 78 | + branches: [main] |
| 79 | + # The pull request paths, and what only a push to main covers: the |
| 80 | + # root of the test target (it changes when an ecosystem's module is |
| 81 | + # added; ci.yml builds the target and runs its hermetic tests on every |
| 82 | + # pull request), the shared engine code and test helpers the flows run |
| 83 | + # through, and the toolchain files. A main push outside this list waits |
| 84 | + # for the nightly run below. |
| 85 | + paths: |
| 86 | + - '.github/workflows/bazel-cargo.yml' |
| 87 | + - '.github/workflows/bazel-compatibility.yml' |
| 88 | + - 'scripts/install-bazel.sh' |
| 89 | + - 'scripts/bazel-pins.txt' |
| 90 | + - 'crates/socket-patch-cli/tests/e2e_bazel_build/cargo.rs' |
| 91 | + - 'crates/socket-patch-cli/tests/e2e_bazel_build/harness.rs' |
| 92 | + - 'crates/socket-patch-cli/tests/fixtures/bazel/rules_rust/**' |
| 93 | + - 'crates/socket-patch-core/src/**/*cargo*' |
| 94 | + - 'crates/socket-patch-core/src/**/*cargo*/**' |
| 95 | + - 'crates/socket-patch-core/src/patch/user_patches.rs' |
| 96 | + - 'crates/socket-patch-cli/tests/e2e_bazel_build/main.rs' |
| 97 | + - 'crates/socket-patch-core/src/patch/redirect/**' |
| 98 | + - 'crates/socket-patch-core/src/vendor/**' |
| 99 | + - 'crates/socket-patch-core/src/hosted/**' |
| 100 | + - 'crates/socket-patch-cli/src/commands/**' |
| 101 | + - 'crates/socket-patch-cli/tests/common/**' |
| 102 | + - 'crates/socket-patch-cli/tests/hosted_memory_common/**' |
| 103 | + - 'Cargo.lock' |
| 104 | + - 'Cargo.toml' |
| 105 | + - 'crates/*/Cargo.toml' |
| 106 | + - 'rust-toolchain.toml' |
| 107 | + - '.cargo/**' |
| 108 | + schedule: |
| 109 | + # Nightly, so a main change outside the push list still gets a run |
| 110 | + # within a day. The macOS leg runs here and on demand only. |
| 111 | + - cron: '57 4 * * *' |
| 112 | + workflow_dispatch: |
| 113 | + |
| 114 | +permissions: |
| 115 | + contents: read |
| 116 | + |
| 117 | +# The nightly run has a group of its own. A group holds one pending run, so |
| 118 | +# in the group of main's pushes a second push would replace a nightly that |
| 119 | +# waits behind the first, and the nightly is the only run with the macOS leg. |
| 120 | +concurrency: |
| 121 | + group: bazel-cargo-${{ github.event.pull_request.number || github.ref }}${{ github.event_name == 'schedule' && '-nightly' || '' }} |
| 122 | + cancel-in-progress: ${{ github.event_name == 'pull_request' }} |
| 123 | + |
| 124 | +jobs: |
| 125 | + cargo: |
| 126 | + uses: ./.github/workflows/bazel-compatibility.yml |
| 127 | + with: |
| 128 | + eco: cargo |
| 129 | + fixtures: rules_rust/bzlmod |
| 130 | + # One leg per line: a Bazel release, and the era of the fixture that |
| 131 | + # `cargo::FIXTURE` gives it. |
| 132 | + releases: >- |
| 133 | + [ |
| 134 | + {"bazel": "9.3.2", "era": "e9"}, |
| 135 | + {"bazel": "8.8.2", "era": "e9"}, |
| 136 | + {"bazel": "7.7.2", "era": "e7"} |
| 137 | + ] |
| 138 | + macos: >- |
| 139 | + [ |
| 140 | + {"bazel": "9.3.2", "era": "e9"} |
| 141 | + ] |
0 commit comments