Skip to content

Commit

Permalink
clippy & format on ci
Browse files Browse the repository at this point in the history
  • Loading branch information
hero78119 committed Jun 13, 2024
1 parent b73cf09 commit 5b447a6
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 1 deletion.
66 changes: 66 additions & 0 deletions .github/workflows/lints.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Lints

# We only run these lints on trial-merges of PRs to reduce noise.
on:
merge_group:
pull_request:
types: [synchronize, opened, reopened, ready_for_review]
push:
branches:
- master

jobs:
skip_check:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5
with:
cancel_others: 'true'
concurrent_skipping: 'same_content_newer'
paths_ignore: '["**/README.md"]'

lints:
needs: [skip_check]
if: |
github.event.pull_request.draft == false &&
(github.event.action == 'ready_for_review' || needs.skip_check.outputs.should_skip != 'true')
name: Various lints
timeout-minutes: 30
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
components: rustfmt, clippy
override: false
- name: Cargo cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: lint-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Install cargo make
run: |
cargo install --force cargo-make
- name: Check code format
uses: actions-rs/cargo@v1
with:
command: make
args: fmt

- name: Run clippy
uses: actions-rs/cargo@v1
with:
command: make
args: clippy

9 changes: 9 additions & 0 deletions Makefile.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
[env]
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
CORE = { script = ["grep ^cpu\\scores /proc/cpuinfo | uniq | awk '{print $4}'"] }
RAYON_NUM_THREADS = "${CORE}"

[tasks.test]
command = "cargo"
args = ["test", "--release", "--all", "--all-features"]

[tasks.fmt]
command = "cargo"
args = ["fmt", "--all", "--", "--check"]

[tasks.clippy]
command = "cargo"
args = ["clippy", "--all-features", "--all-targets", "--", "-D", "warnings"]
2 changes: 1 addition & 1 deletion gkr/Makefile.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[env]
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
CORE = { script = ["grep ^cpu\\scores /proc/cpuinfo | uniq | awk '{print $4}'"] }
RAYON_NUM_THREADS = "${CORE}"
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true

[tasks.gkr_bench]
command = "cargo"
Expand Down
10 changes: 10 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
edition = "2021"

comment_width = 100
imports_granularity = "Crate"
max_width = 100
newline_style = "Unix"
normalize_comments = true
reorder_imports = true
wrap_comments = true

0 comments on commit 5b447a6

Please sign in to comment.