Skip to content

Commit

Permalink
Add some CI (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
EricLBuehler authored Dec 18, 2024
1 parent 371dded commit af10470
Show file tree
Hide file tree
Showing 5 changed files with 198 additions and 2 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/analysis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Analysis
on:
pull_request_target

jobs:
comment:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Rust and Cargo
run: |
curl -sSf https://sh.rustup.rs | sh -s -- -y
source $HOME/.cargo/env
- name: Install Tokei
run: cargo install tokei

- name: Run Tokei and get the lines of code
run: tokei . > tokei_output.txt

- name: Comment or Update PR
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const tokeiOutput = fs.readFileSync('tokei_output.txt', 'utf8');
const uniqueIdentifier = 'Code Metrics Report';
const codeReport = `
<details>
<summary>${uniqueIdentifier}</summary>
<pre>
${tokeiOutput}
</pre>
</details>
`;
const issue_number = context.issue.number;
const { owner, repo } = context.repo;
const comments = await github.rest.issues.listComments({
issue_number,
owner,
repo
});
const existingComment = comments.data.find(comment => comment.body.includes(uniqueIdentifier));
if (existingComment) {
await github.rest.issues.updateComment({
owner,
repo,
comment_id: existingComment.id,
body: codeReport
});
} else {
await github.rest.issues.createComment({
issue_number,
owner,
repo,
body: codeReport
});
}
121 changes: 121 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
on:
schedule:
- cron: '0 0 * * 1'
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:

name: Continuous integration

jobs:
check:
name: Check
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
rust: [stable]
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- uses: actions-rs/cargo@v1
with:
command: check

test:
name: Test Suite
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
rust: [stable]
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- uses: actions-rs/cargo@v1
env:
TESTS_HF_TOKEN: ${{ secrets.HF_TOKEN }}
with:
command: test
args: --workspace

fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add clippy
- uses: actions-rs/cargo@v1
with:
command: clippy
args: --workspace --tests --examples -- -D warnings

docs:
name: Docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: doc
args: --workspace

typos:
name: Typos
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Typos check with custom config file
uses: crate-ci/typos@master
with:
config: .typos.toml

# run `mlc` (`cargo install mlc`)
# markdown-link-check:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: gaurav-nelson/github-action-markdown-link-check@v1
11 changes: 11 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[default]
extend-ignore-identifiers-re = [
"Mmaped",
"mmaped",
"arange",
"Nd",
"nin",
]

[files]
extend-exclude = []
2 changes: 1 addition & 1 deletion diffusers_backend/src/metal_kernels/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub enum MetalKernelError {
FailedToCreatePipeline(String),
#[error("dtype mismatch, got {got:?}, expected {expected:?}")]
DTypeMismatch { expected: Vec<DType>, got: DType },
#[error("Sdpa {variation} head size was {got}, expectd {expected:?}")]
#[error("Sdpa {variation} head size was {got}, expected {expected:?}")]
SdpaHeadSizeMismatch {
variation: &'static str,
got: usize,
Expand Down
2 changes: 1 addition & 1 deletion diffusers_backend/src/metal_kernels/sdpa.metal
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ struct BlockLoaderFA {
tmp_val[j] = src[(tmp_idx[j] ? i * src_ld + j : 0)];
}

// Zero out uneeded values
// Zero out unneeded values
STEEL_PRAGMA_UNROLL
for (short j = 0; j < vec_size; j++) {
tmp_val[j] = tmp_idx[j] ? tmp_val[j] : T(0);
Expand Down

0 comments on commit af10470

Please sign in to comment.