Skip to content

Commit

Permalink
Merge pull request #141 from sevetis/main
Browse files Browse the repository at this point in the history
[ci] update github actions to support Rust compile-time checks
  • Loading branch information
luojia65 authored Oct 8, 2024
2 parents d0ed118 + f0d11d0 commit 0045805
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 4 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/CMake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.)
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/Cargo.yml
Original file line number Diff line number Diff line change
@@ -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
41 changes: 41 additions & 0 deletions .github/workflows/Check.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0045805

Please sign in to comment.