Skip to content

Commit

Permalink
update formatting, add pre-commit hooks and ci
Browse files Browse the repository at this point in the history
  • Loading branch information
mazziechai committed Mar 27, 2024
1 parent cfeda5b commit b085a76
Show file tree
Hide file tree
Showing 12 changed files with 2,616 additions and 1,721 deletions.
5 changes: 5 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/env sh

cargo fmt || exit 1
cargo check || exit 1
cargo check --release || exit 1
3 changes: 3 additions & 0 deletions .githooks/pre-commit.wrapper
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/env sh

exec .githooks/pre-commit
66 changes: 66 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
on:
workflow_dispatch:
push:
pull_request:
branches: [main]

name: Build

jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install nightly toolchain
uses: dtolnay/rust-toolchain@nightly

- uses: Swatinem/rust-cache@v2
with:
shared-key: "build"

- name: Run check
run: cargo check

test:
name: Test
runs-on: ubuntu-latest
env:
RUST_BACKTRACE: 1
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install nightly toolchain
uses: dtolnay/rust-toolchain@nightly

- uses: Swatinem/rust-cache@v2
with:
shared-key: "build"

- name: Run cargo test
run: cargo test --workspace

lints:
name: Lints
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install nightly toolchain
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt, clippy

- uses: Swatinem/rust-cache@v2
with:
shared-key: "build"

- name: Run cargo fmt
run: cargo fmt --all --check

- name: Run cargo clippy
run: cargo clippy --workspace -- -D warnings
9 changes: 1 addition & 8 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
use_small_heuristics = "Max"
enum_discrim_align_threshold = 16
struct_field_align_threshold = 16
fn_params_layout = "Compressed"

brace_style = "PreferSameLine"
fn_single_line = true
max_width = 150
hard_tabs = true
6 changes: 6 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/env sh

chmod 744 .githooks/pre-commit
chmod 744 .githooks/pre-commit.wrapper
cp .githooks/pre-commit.wrapper .git/hooks/pre-commit
chmod 744 .git/hooks/pre-commit
Loading

0 comments on commit b085a76

Please sign in to comment.