diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 9d09df0..cdc9b7d 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,50 +1,65 @@ name: Release permissions: - pull-requests: write - contents: write + pull-requests: write + contents: write on: - push: - branches: - - release + push: + branches: + - release jobs: - # Release unpublished packages. - release-plz-release: - name: Release-plz release - runs-on: self-hosted - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Run release-plz - uses: release-plz/action@v0.5 - with: - command: release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_TOKEN }} + # Release unpublished packages. + release-plz-release: + name: Release-plz release + runs-on: self-hosted + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Run release-plz + uses: release-plz/action@v0.5 + with: + command: release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_TOKEN }} - # Create a PR with the new versions and changelog, preparing the next release. - release-plz-pr: - name: Release-plz PR - runs-on: self-hosted - concurrency: - group: release-plz-${{ github.ref }} - cancel-in-progress: false - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@stable - - name: Run release-plz - uses: release-plz/action@v0.5 - with: - command: release-pr - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_TOKEN }} + # Create a PR with the new versions and changelog, preparing the next release. + release-plz-pr: + name: Release-plz PR + runs-on: self-hosted + concurrency: + group: release-plz-${{ github.ref }} + cancel-in-progress: false + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + - name: Run release-plz + uses: release-plz/action@v0.5 + with: + command: release-pr + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_TOKEN }} + + docs: + runs-on: self-hosted + steps: + - uses: actions/checkout@v3 + - name: Generate Docs + run: cargo doc --no-deps --document-private-items + - name: Add index.html + run: | + echo '' > target/doc/index.html + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./target/doc diff --git a/src/core/hip_call.rs b/src/core/hip_call.rs new file mode 100644 index 0000000..5bb0354 --- /dev/null +++ b/src/core/hip_call.rs @@ -0,0 +1,35 @@ +use super::{sys, HipResult, Result}; + +#[macro_export] +macro_rules! hip_call { + ($call:expr) => {{ + let code = unsafe { $call }; + ((), code).to_result() + }}; +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_hip_call_simple() { + let result = hip_call!(sys::hipDeviceSynchronize()); + assert!(result.is_ok()); + } + + #[test] + fn test_hip_call_with_value() { + let mut count = 0; + let result = hip_call!(sys::hipGetDeviceCount(&mut count)); + assert!(result.is_ok()); + assert!(count > 0); + } + + #[test] + fn test_hip_call_error() { + // Call with invalid device ID should return error + let result = hip_call!(sys::hipSetDevice(99)); + assert!(result.is_err()); + } +} diff --git a/src/core/mod.rs b/src/core/mod.rs index 41ed661..2e30cac 100644 --- a/src/core/mod.rs +++ b/src/core/mod.rs @@ -1,6 +1,7 @@ mod device; mod device_types; mod flags; +mod hip_call; mod init; mod memory; mod result; @@ -11,6 +12,7 @@ pub mod sys; pub use device::*; pub use device_types::*; pub use flags::*; +pub use hip_call::*; pub use init::*; pub use memory::*; pub use result::*;