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