Skip to content

Repository files navigation

Pre-Submit Checks for Repositories

A single extensible tool for linting and fixing your code in several contexts (manual, git pre-commit, GitHub Action).

Supported Checks

Usage

Install the checker CLI:

# From Source
git clone https://github.com/AlexanderGH/presubmitchecks.git
cd presubmitchecks
./gradlew :presubmitchecks-cli:installDist
./presubmitchecks-cli/build/install/presubmitchecks-cli/bin/presubmitchecks-cli

# Download Release Artifact presubmitchecks-cli-standalone.jar
wget https://github.com/AlexanderGH/presubmitchecks/releases/download/<release>/presubmitchecks-cli-standalone.jar
java -jar presubmitchecks-cli-standalone.jar

# Download Release Artifact presubmitchecks-cli.zip
wget https://github.com/AlexanderGH/presubmitchecks/releases/download/<release>/presubmitchecks-cli.zip
unzip presubmitchecks-cli.zip
./presubmitchecks-cli/bin/presubmitchecks-cli

You can verify the integrity and provenance of an artifact using its associated cryptographically signed attestations (not available for pre-release/SNAPSHOT artifacts):

gh attestation verify presubmitchecks-cli-standalone.jar
gh attestation verify presubmitchecks-cli.zip

Check Files

./presubmitchecks-cli files '**.json' '!**/dist/**'

Git Pre-Commit

# Automatic diff:
./presubmitchecks-cli git-pre-commit

# From stdin:
git diff main | ./presubmitchecks-cli git-pre-commit --diff -

# From a file:
./presubmitchecks-cli git-pre-commit --diff changes.diff

GitHub Action

To run the presubmit checks as part of a GitHub Action pull_request trigger:

./presubmitchecks-cli github-action

Or, use our pre-configured GitHub Action:

    steps:
      - name: Run Presubmit Checks
        uses: 'AlexanderGH/presubmitchecks@main'
        id: presubmitchecks
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}

See GitHub Action Setup for more examples.

Fixes

By default, presubmitchecks operates in report-only mode and will only list issues. In order for it to make changes that attempt to fix issues, you must pass --fix to the CLI or the apply-fixes input for the GitHub Action.

Configuration

A configuration file can be specified with --config, e.g. --config .github/presubmitchecks.json. When using the GitHub action, it can be specified using the config-file input.

The default configuration can be found here. A more complex configuration is used by this repo's own presubmit checks.

Example Configuration

{
  "checkerConfigs": {
    // One of more checker configurations can be set here.
  }
}

About

A single extensible tool for linting and fixing your code in several contexts (manual, git pre-commit, GitHub Action).

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages