Skip to content

Commit

Permalink
ci: setup ci tests and checks ( PROOF-622 ) (#1)
Browse files Browse the repository at this point in the history
# Rationale for this change

This PR adds the initial CI workflows necessary to ensure code quality.

# What changes are included in this PR?

* Add PR template.
* Add GitHub actions workflow to test, check, and lint the code.

# Are these changes tested?

Yes.
  • Loading branch information
joe-stifler authored Sep 8, 2023
2 parents bcba70e + f88cea6 commit 54889bb
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 1 deletion.
22 changes: 22 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Rationale for this change

<!--
Why are you proposing this change? If this is already explained clearly in the linked Jira ticket then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->

# What changes are included in this PR?

<!--
There is no need to duplicate the description in the ticket here but it is sometimes worth providing a summary of the individual changes in this PR.
-->

# Are these changes tested?

<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
-->
46 changes: 46 additions & 0 deletions .github/workflows/test-check-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Test-Check-Lint

on:
workflow_call:
pull_request:
types:
- opened
- synchronize

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
format-code:
name: Check Code
runs-on: self-hosted
steps:
- name: Checkout Code Format
uses: actions/checkout@v3
- run: docker run --rm -v "$PWD":/src:ro -w /src --privileged spaceandtimelabs/blitzar:12.2.0-cuda-1.71.1-rust-0 /bin/bash -c "cp -av /src/ /src_tmp/; cd /src_tmp; /root/.cargo/bin/cargo fmt --all -- --check"

clippy-code:
name: Clippy Code
runs-on: self-hosted
steps:
- name: Checkout Code
uses: actions/checkout@v3
- run: docker run --rm -v "$PWD":/src:ro -w /src --privileged spaceandtimelabs/blitzar:12.2.0-cuda-1.71.1-rust-0 /bin/bash -c "cp -av /src/ /src_tmp/; cd /src_tmp; /root/.cargo/bin/rustup component add clippy; /root/.cargo/bin/cargo clippy --all-targets --all-features -- -D warnings"

test-cpu:
name: Test the CPU backend
runs-on: self-hosted
steps:
- name: Checkout Code
uses: actions/checkout@v3
- run: docker run --rm -v "$PWD":/src:ro -w /src --privileged spaceandtimelabs/blitzar:12.2.0-cuda-1.71.1-rust-0 /bin/bash -c "cp -av /src/ /src_tmp/; cd /src_tmp; /root/.cargo/bin/cargo test --features cpu"

test-gpu:
name: Test the GPU backend
runs-on: self-hosted
steps:
- name: Checkout Code
uses: actions/checkout@v3
- run: docker run --rm -v "$PWD":/src:ro -w /src --gpus all --privileged spaceandtimelabs/blitzar:12.2.0-cuda-1.71.1-rust-0 /bin/bash -c "nvidia-smi"
- run: docker run --rm -v "$PWD":/src:ro -w /src --gpus all --privileged spaceandtimelabs/blitzar:12.2.0-cuda-1.71.1-rust-0 /bin/bash -c "cp -av /src/ /src_tmp/; cd /src_tmp; /root/.cargo/bin/cargo test --features gpu"
8 changes: 8 additions & 0 deletions ci/run_docker_with_cpu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

set -e

IMAGE=spaceandtimelabs/blitzar:12.2.0-cuda-1.71.1-rust-0

# If you don't have a GPU instance configured in your machine
docker run -v "$PWD":/src -w /src --privileged -it "$IMAGE"
8 changes: 8 additions & 0 deletions ci/run_docker_with_gpu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

set -e

IMAGE=spaceandtimelabs/blitzar:12.2.0-cuda-1.71.1-rust-0

# If you have a GPU instance configured in your machine
docker run -v "$PWD":/src -w /src --gpus all --privileged -it "$IMAGE"
2 changes: 1 addition & 1 deletion src/sequence/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl<'a> Sequence<'a> {
assert!(element_size > 0);
assert!(element_size <= 32);
}
let len = slice.len() * element_size;
let len = std::mem::size_of_val(slice);
let data_slice = unsafe { core::slice::from_raw_parts(slice.as_ptr() as *const u8, len) };
Sequence {
data_slice,
Expand Down

0 comments on commit 54889bb

Please sign in to comment.