diff --git a/.github/workflows/lints.yml b/.github/workflows/lints.yml new file mode 100644 index 000000000..0cb0d985c --- /dev/null +++ b/.github/workflows/lints.yml @@ -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 + diff --git a/Makefile.toml b/Makefile.toml index c232d50d0..6e0e2e5b6 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -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"] diff --git a/gkr/Makefile.toml b/gkr/Makefile.toml index f735eb001..5527e0c9b 100644 --- a/gkr/Makefile.toml +++ b/gkr/Makefile.toml @@ -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" diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 000000000..1b31b7d5f --- /dev/null +++ b/rustfmt.toml @@ -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 +