xref: /DragonReach/.github/workflows/cache-toolchain.yml (revision e945c217b313a00a228c454741360ee9a74397d2)
1236b9b4fSLoGinname: Reusable workflow example
2236b9b4fSLoGin
3236b9b4fSLoGinon: workflow_call
4236b9b4fSLoGin
5236b9b4fSLoGinjobs:
6236b9b4fSLoGin    build:
7236b9b4fSLoGin
8236b9b4fSLoGin        runs-on: ubuntu-latest
9236b9b4fSLoGin
10236b9b4fSLoGin        steps:
11236b9b4fSLoGin        - uses: actions/checkout@v3
12236b9b4fSLoGin
13236b9b4fSLoGin
14236b9b4fSLoGin        - name: Cache build tools
15236b9b4fSLoGin          id: cache-build-tools
16236b9b4fSLoGin          uses: actions/cache@v3
17236b9b4fSLoGin          env:
18236b9b4fSLoGin              cache-name: cache-build-tools
19236b9b4fSLoGin              dadk_version: 0.1.2
20236b9b4fSLoGin          with:
21236b9b4fSLoGin            path: |
22236b9b4fSLoGin              ~/.cargo
23236b9b4fSLoGin              ~/.rustup
24236b9b4fSLoGin              ~/.bashrc
25236b9b4fSLoGin            key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.dadk_version }}-${{ hashFiles('.github/workflows/cache-toolchain.yml') }}
26236b9b4fSLoGin
27236b9b4fSLoGin        - if: ${{ steps.cache-build-tools.outputs.cache-hit != 'true' }}
28236b9b4fSLoGin          name: Install toolchain
29236b9b4fSLoGin          continue-on-error: true
30236b9b4fSLoGin          run:  |
31236b9b4fSLoGin            sudo sh -c "apt update && apt install -y llvm-dev libclang-dev clang gcc-multilib libssl-dev pkg-config"
32236b9b4fSLoGin            cargo install cargo-binutils
33236b9b4fSLoGin            rustup toolchain install nightly
34236b9b4fSLoGin            rustup default nightly
35236b9b4fSLoGin            rustup component add rust-src
36236b9b4fSLoGin            rustup component add llvm-tools-preview
37236b9b4fSLoGin            rustup target add x86_64-unknown-none
38*e945c217SLoGin            rustup component add rust-src --toolchain nightly-2024-11-05-x86_64-unknown-linux-gnu
39236b9b4fSLoGin            rustup component add rustfmt
40dfd3fd98S裕依2439
41*e945c217SLoGin            rustup toolchain install nightly-2024-11-05-x86_64-unknown-linux-gnu
42*e945c217SLoGin            rustup component add rust-src --toolchain nightly-2024-11-05-x86_64-unknown-linux-gnu
43*e945c217SLoGin            rustup target add x86_64-unknown-linux-musl --toolchain nightly-2024-11-05-x86_64-unknown-linux-gnu
44dfd3fd98S裕依2439            rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu
45dfd3fd98S裕依2439
46236b9b4fSLoGin            cargo install dadk --version 0.1.2