atagen

matrix-rust-sdk

public
Star0
Watch0
ssh://brewery@pls.lobotomise.me:33/atagen/matrix-rust-sdk.git
.github/workflows/xtask.ymlYaml82 lines2.5 KB
1
# A reusable github actions workflow that will build xtask, if it is not
2
# already cached.
3
#
4
# It will create a pair of GHA cache entries, if they do not already exist.
5
# The cache keys take the form `xtask-{os}-{hash}`, where "{os}" is "linux"
6
# or "macos", and "{hash}" is the hash of the xtask# directory.
7
#
8
# The cache keys are written to output variables named "cachekey-{os}".
9
#
10
11
name: Build xtask if necessary
12
13
on:
14
  workflow_call:
15
    outputs:
16
      cachekey-linux:
17
        description: "The cache key for the linux build artifact"
18
        value: "${{ jobs.xtask.outputs.cachekey-linux }}"
19
      cachekey-macos:
20
        description: "The cache key for the macos build artifact"
21
        value: "${{ jobs.xtask.outputs.cachekey-macos }}"
22
23
permissions: {}
24
25
env:
26
  CARGO_TERM_COLOR: always
27
28
jobs:
29
  xtask:
30
    name: "xtask-${{ matrix.os-name }}"
31
32
    strategy:
33
      fail-fast: true
34
      matrix:
35
        include:
36
          - os: ubuntu-latest
37
            os-name: 🐧
38
            cachekey-id: linux
39
40
          - os: macos-15
41
            os-name: 🍏
42
            cachekey-id: macos
43
44
    runs-on: "${{ matrix.os }}"
45
46
    steps:
47
      - name: Checkout repo
48
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
49
        with:
50
          persist-credentials: false
51
52
      - name: Calculate cache key
53
        id: cachekey
54
        # set a step output variable "cachekey-{os}" that can be referenced in
55
        # the job outputs below.
56
        run: |
57
          echo "cachekey-${{ matrix.cachekey-id }}=xtask-${{ matrix.cachekey-id }}-${{ hashFiles('Cargo.toml', 'xtask/**') }}" >> $GITHUB_OUTPUT
58
59
      - name: Check xtask cache
60
        uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
61
        id: xtask-cache
62
        with:
63
          path: target/debug/xtask
64
          # use the cache key calculated in the step above. Bit of an awkward
65
          # syntax
66
          key: |
67
            ${{ steps.cachekey.outputs[format('cachekey-{0}', matrix.cachekey-id)] }}
68
69
      - name: Install Rust stable toolchain
70
        if: steps.xtask-cache.outputs.cache-hit != 'true'
71
        uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
72
        with:
73
          toolchain: stable
74
75
      - name: Build
76
        if: steps.xtask-cache.outputs.cache-hit != 'true'
77
        run: |
78
          cargo build -p xtask
79
80
    outputs:
81
      "cachekey-linux": "${{ steps.cachekey.outputs.cachekey-linux }}"
82
      "cachekey-macos": "${{ steps.cachekey.outputs.cachekey-macos }}"