Skip to content

Commit

Permalink
[chore] Add CI for doc and clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
Azure-stars committed Nov 10, 2024
1 parent 9aedb12 commit d8f2dbb
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Build & Check CI

on: [push, pull_request]

jobs:
ci:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rust-toolchain: [nightly]
targets: [x86_64-unknown-none, riscv64gc-unknown-none-elf, aarch64-unknown-none-softfloat, aarch64-unknown-linux-gnu]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
toolchain: ${{ matrix.rust-toolchain }}
components: rust-src, clippy, rustfmt
targets: ${{ matrix.targets }}
- name: Check rust version
run: rustc --version --verbose
- name: Check code format
run: cargo fmt --all -- --check
- name: Clippy
run: cargo clippy --target ${{ matrix.targets }} --all-features -- -A clippy::new_without_default
- name: Build
run: cargo build --target ${{ matrix.targets }} --all-features
29 changes: 29 additions & 0 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Build & Deploy docs

on: [push, pull_request]

jobs:
doc:
runs-on: ubuntu-latest
strategy:
fail-fast: false
permissions:
contents: write
env:
default-branch: ${{ format('refs/heads/{0}', github.event.repository.default_branch) }}
RUSTDOCFLAGS: -D rustdoc::broken_intra_doc_links -D missing-docs
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- name: Build docs
continue-on-error: ${{ github.ref != env.default-branch && github.event_name != 'pull_request' }}
run: |
cargo doc --no-deps --all-features
printf '<meta http-equiv="refresh" content="0;url=%s/index.html">' $(cargo tree | head -1 | cut -d' ' -f1) > target/doc/index.html
- name: Deploy to Github Pages
if: ${{ github.ref == env.default-branch }}
uses: JamesIves/github-pages-deploy-action@v4
with:
single-commit: true
branch: gh-pages
folder: target/doc
19 changes: 19 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//! Note:
//! - Interrupt grouping(secure state) is not supported
//! - Interrupt proiority(preempt) is not supported
//!
//! Please contact the developer if you need this function
#![no_std]
Expand Down Expand Up @@ -122,6 +123,24 @@ pub const fn translate_irq(id: usize, int_type: InterruptType) -> Option<usize>
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_translate_irq() {
assert_eq!(translate_irq(0, InterruptType::SGI), Some(0));
assert_eq!(translate_irq(0, InterruptType::PPI), Some(16));
assert_eq!(translate_irq(0, InterruptType::SPI), Some(32));
assert_eq!(translate_irq(16, InterruptType::SGI), None);
assert_eq!(translate_irq(16, InterruptType::PPI), Some(32));
assert_eq!(translate_irq(16, InterruptType::SPI), Some(48));
assert_eq!(translate_irq(32, InterruptType::SGI), None);
assert_eq!(translate_irq(32, InterruptType::PPI), None);
assert_eq!(translate_irq(32, InterruptType::SPI), Some(32));
}
}

impl Debug for IntId {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
if self.0 < Self::PPI_START {
Expand Down

0 comments on commit d8f2dbb

Please sign in to comment.