xref: /DragonBoot/.github/workflows/cache-toolchain.yml (revision 0ec3a34a58ffc0a9c51a23a7ee5e7d803a0060cd)
1name: Reusable workflow example
2
3on: workflow_call
4
5jobs:
6    build:
7
8        runs-on: ubuntu-latest
9
10        steps:
11        - uses: actions/checkout@v3
12
13
14        - name: Cache build tools
15          id: cache-build-tools
16          uses: actions/cache@v3
17          env:
18              cache-name: dragon-boot-cache-build-tools
19          with:
20            path: |
21              ~/.cargo
22              ~/.rustup
23              ~/.bashrc
24            key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('.github/workflows/cache-toolchain.yml') }}
25
26        - if: ${{ steps.cache-build-tools.outputs.cache-hit != 'true' }}
27          name: Install toolchain
28          continue-on-error: true
29          run:  |
30            sudo sh -c "apt update && apt install -y llvm-dev libclang-dev clang gcc-multilib libssl-dev pkg-config build-essential gcc-riscv64-unknown-elf"
31            cargo install cargo-binutils
32            rustup toolchain install nightly
33            rustup default nightly
34            rustup component add rust-src
35            rustup component add llvm-tools-preview
36            rustup target add x86_64-unknown-none
37            rustup component add rust-src --toolchain nightly-2023-08-15-x86_64-unknown-linux-gnu
38            rustup target add riscv64gc-unknown-none-elf --toolchain nightly-2023-08-15-riscv64gc-unknown-linux-gnu
39            rustup component add rustfmt --toolchain nightly-2023-08-15-x86_64-unknown-linux-gnu
40
41