|
| 1 | +# This workflow _produces_ caches which are used to speed up pull request builds. |
| 2 | +# The caches are split by Rust version (stable vs MSRV per crate) because those caches cannot share any artifacts. |
| 3 | + |
| 4 | +name: Cache factory |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - master # Caches are only created on master branch. |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 13 | + cancel-in-progress: true |
| 14 | + |
| 15 | +jobs: |
| 16 | + gather_msrv_versions: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + outputs: |
| 19 | + versions: ${{ steps.find-rust-versions.outputs.versions }} |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v3 |
| 22 | + |
| 23 | + - id: find-rust-versions |
| 24 | + run: | |
| 25 | + RUST_VERSIONS=$(cargo metadata --format-version=1 --no-deps | jq -c '.packages | map(.rust_version) | unique | del(..|nulls)') |
| 26 | + echo "versions=${RUST_VERSIONS}" >> $GITHUB_OUTPUT |
| 27 | +
|
| 28 | + make_msrv_cache: |
| 29 | + runs-on: ubuntu-latest |
| 30 | + needs: gather_msrv_versions |
| 31 | + strategy: |
| 32 | + fail-fast: false |
| 33 | + matrix: |
| 34 | + rust: ${{ fromJSON(needs.gather_msrv_versions.outputs.versions) }} |
| 35 | + steps: |
| 36 | + - name: Install Protoc |
| 37 | + uses: arduino/setup-protoc@64c0c85d18e984422218383b81c52f8b077404d3 # v1.1.2 |
| 38 | + |
| 39 | + - uses: actions/checkout@v3 |
| 40 | + |
| 41 | + - uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7 |
| 42 | + with: |
| 43 | + toolchain: ${{ matrix.rust }} |
| 44 | + |
| 45 | + - uses: Swatinem/rust-cache@359a70e43a0bb8a13953b04a90f76428b4959bb6 # v2.2.0 |
| 46 | + with: |
| 47 | + shared-key: msrv-cache |
| 48 | + |
| 49 | + - name: Compile all crates which have MSRV ${{ matrix.rust }} |
| 50 | + run: | |
| 51 | + cargo metadata --format-version=1 --no-deps | \ |
| 52 | + jq -r '.packages[] | select(.rust_version == "${{ matrix.rust }}") | "+\(.rust_version) build --all-features --package \(.name)"' | |
| 53 | + xargs --verbose -L 1 cargo |
| 54 | +
|
| 55 | + make_stable_rust_cache: |
| 56 | + runs-on: ubuntu-latest |
| 57 | + steps: |
| 58 | + - name: Install Protoc |
| 59 | + uses: arduino/setup-protoc@64c0c85d18e984422218383b81c52f8b077404d3 # v1.1.2 |
| 60 | + |
| 61 | + - uses: actions/checkout@v3 |
| 62 | + |
| 63 | + - uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7 |
| 64 | + with: |
| 65 | + toolchain: stable |
| 66 | + |
| 67 | + - uses: Swatinem/rust-cache@359a70e43a0bb8a13953b04a90f76428b4959bb6 # v2.2.0 |
| 68 | + with: |
| 69 | + shared-key: stable-cache |
| 70 | + |
| 71 | + - name: Compile workspace with stable Rust |
| 72 | + run: cargo test --all-features --all-targets --workspace --no-run |
| 73 | + |
| 74 | + - name: Render docs |
| 75 | + run: cargo doc --all-features --workspace |
| 76 | + |
| 77 | + - name: Install tools |
| 78 | + run: cargo install cargo-semver-checks --locked |
0 commit comments