123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 |
- name: CI
- on:
- push:
- branches: [ "main" ]
- pull_request:
- branches: [ "main" ]
- workflow_dispatch:
- env:
- CARGO_UNSTABLE_SPARSE_REGISTRY: true
- CARGO_TERM_COLOR: always
- jobs:
- fmt:
- name: Rustfmt all packages
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v4
- - uses: actions-rust-lang/setup-rust-toolchain@v1
- with:
- components: rustfmt
- - name: Cache Dependencies
- uses: Swatinem/rust-cache@v2
- - name: Rustfmt Check
- uses: actions-rust-lang/rustfmt@v1
- build-rustsbi:
- name: Build rustsbi
- runs-on: ubuntu-latest
- needs: fmt
- strategy:
- matrix:
- TARGET: [riscv64imac-unknown-none-elf, riscv32imac-unknown-none-elf]
- TOOLCHAIN: [stable, nightly]
- steps:
- - uses: actions/checkout@v4
- - uses: actions-rust-lang/setup-rust-toolchain@v1
- with:
- target: ${{ matrix.TARGET }}
- toolchain: ${{ matrix.TOOLCHAIN }}
- - uses: Swatinem/rust-cache@v2
- with:
- key: ${{ matrix.TARGET }}
- - name: Build (no default features)
- run: |
- cargo build --target ${{ matrix.TARGET }} --verbose
- - name: Build (machine)
- run: |
- cargo build --target ${{ matrix.TARGET }} --verbose --features "machine"
- - name: Build (forward)
- run: |
- cargo build --target ${{ matrix.TARGET }} --verbose --features "forward"
- - name: Build (machine + forward)
- run: |
- cargo build --target ${{ matrix.TARGET }} --verbose --features "machine, forward"
- test-rustsbi:
- name: Test rustsbi
- needs: fmt
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v4
- - uses: actions-rust-lang/setup-rust-toolchain@v1
- with:
- toolchain: stable
- - uses: Swatinem/rust-cache@v2
- - name: Run tests (no default features)
- run: |
- cargo test -p rustsbi --verbose
- - name: Run tests (machine)
- run: |
- cargo test -p rustsbi --verbose --features "machine"
- # Don't run tests with rustsbi `forward` features on here: it requires RISC-V targets to build.
- test-sbi-spec:
- name: Test sbi-spec
- needs: fmt
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v4
- - uses: actions-rust-lang/setup-rust-toolchain@v1
- with:
- toolchain: stable
- - uses: Swatinem/rust-cache@v2
- # - name: Check clippy
- # run: cargo clippy -- -D warnings
- - name: Run tests
- run: cargo test -p sbi-spec --verbose
-
- build-sbi-rt:
- name: Build sbi-rt
- needs: fmt
- runs-on: ubuntu-latest
- strategy:
- matrix:
- TARGET: [riscv64imac-unknown-none-elf, riscv32imac-unknown-none-elf]
- steps:
- - uses: actions/checkout@v4
- - uses: actions-rust-lang/setup-rust-toolchain@v1
- with:
- target: ${{ matrix.TARGET }}
- toolchain: stable
- - uses: Swatinem/rust-cache@v2
- - name: Build
- run: |
- cargo build --target ${{ matrix.TARGET }} --verbose -p sbi-rt
- build-sbi-testing:
- name: Build sbi-testing
- needs: fmt
- runs-on: ubuntu-latest
- strategy:
- matrix:
- TARGET: [riscv64imac-unknown-none-elf] #, riscv32imac-unknown-none-elf]
- steps:
- - uses: actions/checkout@v4
- - uses: actions-rust-lang/setup-rust-toolchain@v1
- with:
- target: ${{ matrix.TARGET }}
- toolchain: nightly
- - uses: Swatinem/rust-cache@v2
- - name: Build (no default features)
- run: |
- cargo build --target ${{ matrix.TARGET }} --verbose -p sbi-testing
- - name: Build (log)
- run: |
- cargo build --target ${{ matrix.TARGET }} --verbose -p sbi-testing --features "log"
- check-changelog:
- name: Check if `CHANGELOG.md` is updated
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v4
- - name: Get latest updated files
- run: |
- updated_files=$(git show --name-only --pretty=format: HEAD)
- - name: Check if changlog is updated
- run: |
- if git show --name-only --pretty=format: HEAD | grep -q "CHANGELOG.md"; then
- echo "Main CHANGELOG.md changed in the latest commit."
- else
- echo "Main CHANGELOG.md is not changed in the latest commit."
- exit 1
- fi
- for file in $updated_files; do
- first_path=$(dirname "$file")
- if [[ "$first_path" == *"sbi-rt"* ]]; then
- file_path = "./sbi-rt"
- elif [[ "$first_path" == *"sbi-spec"* ]]; then
- file_path = "./sbi-spec"
- elif [[ "$first_path" == *"sbi-testing"* ]]; then
- file_path = "./sbi-testing"
- else
- file_path = "./"
- fi
- changelog_path="$file_path/CHANGELOG.md"
- # Check if changelog is updated
- if git diff --name-only "$file_path" | grep -q "CHANGELOG.md"; then
- echo "File $changelog_path changed in the latest commit."
- else
- echo "File $changelog_path is not changed in the latest commit."
- exit 1
- fi
- done
- check-commit-signatures:
- name: Check commit signatures
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v4
- - name: Check if commit is signed
- run: |
- COMMIT=$(git log -1)
- if echo "$COMMIT" | grep -q "Author: "; then
- echo "Commit is signed."
- else
- echo "Commit is NOT signed."
- exit 1
- fi
- - name: Print author's information
- run: |
- AUTHOR_NAME=$(git log -1 --format='%an')
- AUTHOR_EMAIL=$(git log -1 --format='%ae')
- echo "Author's name: $AUTHOR_NAME"
- echo "Author's email: $AUTHOR_EMAIL"
- # sbi-testing:
- # name: Run rust-clippy analyzing
- # runs-on: ubuntu-latest
- # permissions:
- # security-events: write
- # steps:
- # - name: Checkout code
- # uses: actions/checkout@v4
- # - name: Check format
- # run: cargo fmt --check
- # - name: Install clippy-sarif
- # uses: actions-rs/install@v0.1
- # with:
- # crate: clippy-sarif
- # version: latest
- # - name: Install sarif-fmt
- # uses: actions-rs/install@v0.1
- # with:
- # crate: sarif-fmt
- # version: latest
- # - name: Run rust-clippy
- # run:
- # cargo clippy
- # --all-featuers
- # --package fast-trap
- # --message-format=json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt
- # continue-on-error: true
- # - name: Upload analysis results to GitHub
- # uses: github/codeql-action/upload-sarif@v2
- # with:
- # sarif_file: rust-clippy-results.sarif
- # wait-for-processing: true
|