diff --git a/.github/workflows/CMake.yml b/.github/workflows/CMake.yml index a0465043..04f97c8a 100644 --- a/.github/workflows/CMake.yml +++ b/.github/workflows/CMake.yml @@ -3,10 +3,7 @@ name: CMake Build Test on: - push: - branches: [ "main", "dev" ] - pull_request: - branches: [ "main", "dev" ] + workflow_call: env: # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) diff --git a/.github/workflows/Cargo.yml b/.github/workflows/Cargo.yml new file mode 100644 index 00000000..bcf77d3d --- /dev/null +++ b/.github/workflows/Cargo.yml @@ -0,0 +1,39 @@ +name: Cargo Test + +on: + workflow_call: + +env: + CARGO_TERM_COLOR: always + RUSTFLAGS: + +jobs: + fmt: + name: Rustfmt all packages + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: nightly + components: rustfmt + - name: Rustfmt Check + run: cargo fmt --all -- --check + + make: + name: Cargo Make + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: nightly-2024-10-01 + - name: Setup env + run: | + rustup component add llvm-tools-preview + rustup target add riscv64imac-unknown-none-elf + cargo install cargo-binutils + - name: Cargo Make + run: | + rustc -vV + cargo make --release \ No newline at end of file diff --git a/.github/workflows/Check.yml b/.github/workflows/Check.yml new file mode 100644 index 00000000..312d729e --- /dev/null +++ b/.github/workflows/Check.yml @@ -0,0 +1,41 @@ +name: Check + +on: + push: + branches: [ "main", "dev" ] + pull_request: + branches: [ "main", "dev" ] + +jobs: + check: + runs-on: ubuntu-latest + + outputs: + is_rust: ${{ steps.check_type.outputs.is_rust }} + + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 2 + + - name: Determine Rust or C check + id: check_type + run: | + PREV_SHA=$(git rev-parse HEAD^) + if git diff --name-only $PREV_SHA ${{ github.sha }} | \ + grep -qE '^(rust/|board/100ask-d1-h-rs/)'; then + echo "::set-output name=is_rust::true" + else + echo "::set-output name=is_rust::false" + fi + + cargo_check: + needs: check + if: ${{ needs.check.outputs.is_rust == 'true' }} + uses: ./.github/workflows/Cargo.yml + + cmake_check: + needs: check + if: ${{ needs.check.outputs.is_rust == 'false' }} + uses: ./.github/workflows/CMake.yml