aptos-labs / aptos-core

Aptos is a layer 1 blockchain built to support the widespread use of blockchain through better technology and user experience.
https://aptosfoundation.org
Other
6.19k stars 3.66k forks source link

[Feature Request] `pre-commit` support for CLI #14789

Open alnoki opened 2 months ago

alnoki commented 2 months ago

Todo

cc @aching @banool @chen-robert @crbl69 @davidiw @vineethk @wrwg @xbtmatt

Motivation/pitch

This tooling will make it easier for ecosystem to develop safe code

Additional context

Something like the pre-commit config I currently have for Rust, which has a hooks entry for cargo fmt, cargo check, and clippy all from the top-level repos element pre-commit-rust :

repos:
-
  hooks:
  -
    args:
    - '--manifest-path'
    - 'src/rust/Cargo.toml'
    - '-p'
    - 'allowlister3000'
    - 'broker'
    - '--'
    id: 'fmt'
  -
    args:
    - '--manifest-path'
    - 'src/rust/Cargo.toml'
    - '--'
    id: 'cargo-check'
  -
    args:
    - '--manifest-path'
    - 'src/rust/Cargo.toml'
    - '--'
    - '--deny'
    - 'clippy::all'
    id: 'clippy'
  repo: 'https://github.com/doublify/pre-commit-rust'
  rev: 'v1.0'
banool commented 2 months ago

So you imagine the CLI spits out a template for pre-commit to consume or something?

I feel like some of this functionality could be facilitated more easily in conjunction with a more powerful package manager, e.g. imagine scripts in package.json, the special cased "prepare" script, cargo-like / pnpm-like workspaces, etc.

Then to really bring it all together, some GitHub actions for running testing, linting, formatting, etc.

Just throwing out some additional ideas, really piling on 😛

alnoki commented 2 months ago

a template for pre-commit to consume or something?

Not exactly, the yaml file I provided above is an example of a pre-commit config with several hooks for the pre-commit-rust top-level repos element. Ideally there would be a repos element for aptos with several of its own hooks in a similar form

Then to really bring it all together, some GitHub actions for running testing, linting, formatting, etc.

This is accomplished by simply adding the pre-commit support I suggest, because then someone just has to add a repos element with several hooks to their config

alnoki commented 2 weeks ago

@vineethk per today's Move interest group discussion I've updated the above description to include aptos move lint