-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adopt lintrunner and enable github actions lint checks 1/2 #16
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
39571d2
Adopt lintrunner and enable more ruff rules
justinchuby cb05f01
Lint
justinchuby c773275
Delete .pre-commit-config.yaml
justinchuby 929f139
Merge branch 'main' into justinchu/lintrunner
justinchuby 771a1bd
Format
justinchuby af8bba7
Update evaluator.py
justinchuby File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# Copyright (c) ONNX Neural Compressor Project Contributors | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
name: Lint | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
merge_group: | ||
|
||
permissions: # set top-level default permissions as security best practice | ||
contents: read | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name == 'workflow_dispatch' }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
optional-lint: | ||
name: Optional Lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
- name: misspell # Check spellings as well | ||
uses: reviewdog/action-misspell@5bd7be2fc7ae56a517184f5c4bbcf2fd7afe3927 # v1.17.0 | ||
with: | ||
github_token: ${{ secrets.github_token }} | ||
locale: "US" | ||
reporter: github-pr-check | ||
level: info | ||
filter_mode: diff_context | ||
- name: shellcheck # Static check shell scripts | ||
uses: reviewdog/action-shellcheck@72365a51bf6476fe952a117c3ff703eb7775e40a # v1.20.0 | ||
with: | ||
github_token: ${{ secrets.github_token }} | ||
reporter: github-pr-check | ||
level: info | ||
filter_mode: diff_context | ||
|
||
enforce-style: | ||
name: Enforce style | ||
runs-on: ubuntu-latest | ||
permissions: | ||
security-events: write | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
- name: Setup Python | ||
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 | ||
with: | ||
python-version: "3.12" | ||
- name: Install ONNX Neural Compressor | ||
run: | | ||
pip install . | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install lintrunner lintrunner-adapters | ||
lintrunner init | ||
- name: Run lintrunner on all files | ||
run: | | ||
set +e | ||
if ! lintrunner --force-color --all-files --tee-json=lint.json -v; then | ||
echo "" | ||
echo -e "\e[1m\e[36mYou can reproduce these results locally by using \`lintrunner\`.\e[0m" | ||
echo -e "\e[1m\e[36mSee https://github.com/onnx/neural-compressor/blob/main/.lintrunner.toml for setup instructions.\e[0m" | ||
exit 1 | ||
fi | ||
- name: Produce SARIF | ||
if: always() | ||
run: | | ||
python -m lintrunner_adapters to-sarif lint.json lintrunner.sarif | ||
- name: Upload SARIF file | ||
# Use always() to always upload SARIF even if lintrunner returns with error code | ||
# To toggle linter comments in the files page, press `i` on the keyboard | ||
if: always() | ||
continue-on-error: true | ||
uses: github/codeql-action/upload-sarif@cdcdbb579706841c47f7063dda365e292e5cad7a # v2.13.4 | ||
with: | ||
# Path to SARIF file relative to the root of the repository | ||
sarif_file: lintrunner.sarif | ||
category: lintrunner | ||
checkout_path: ${{ github.workspace }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# Configuration for lintrunner https://github.com/suo/lintrunner | ||
# You can install the dependencies and initialize with | ||
# | ||
# ```sh | ||
# pip install lintrunner lintrunner-adapters | ||
# lintrunner init | ||
# ``` | ||
# | ||
# This will install lintrunner on your system and download all the necessary | ||
# dependencies to run linters locally. | ||
# If you want to see what lintrunner init will install, run | ||
# `lintrunner init --dry-run`. | ||
# | ||
# To lint local changes: | ||
# | ||
# ```bash | ||
# lintrunner | ||
# ``` | ||
# | ||
# To lint all files: | ||
# | ||
# ```bash | ||
# lintrunner --all-files | ||
# ``` | ||
# | ||
# To format files: | ||
# | ||
# ```bash | ||
# lintrunner -a | ||
# ``` | ||
# | ||
# To read more about lintrunner, see [wiki](https://github.com/pytorch/pytorch/wiki/lintrunner). | ||
# To update an existing linting rule or create a new one, modify this file or create a | ||
# new adapter following examples in https://github.com/justinchuby/lintrunner-adapters. | ||
merge_base_with = 'main' | ||
|
||
[[linter]] | ||
code = 'RUFF' | ||
include_patterns = [ | ||
'**/*.py', | ||
'**/*.pyi', | ||
] | ||
exclude_patterns = [ | ||
'*_pb2*', | ||
'.setuptools-cmake-build/*', | ||
'docs/**', | ||
] | ||
command = [ | ||
'python', | ||
'-m', | ||
'lintrunner_adapters', | ||
'run', | ||
'ruff_linter', | ||
'--config=pyproject.toml', | ||
'@{{PATHSFILE}}' | ||
] | ||
init_command = [ | ||
'python', | ||
'-m', | ||
'lintrunner_adapters', | ||
'run', | ||
'pip_init', | ||
'--dry-run={{DRYRUN}}', | ||
'--requirement=requirements-lintrunner.txt', | ||
] | ||
is_formatter = true | ||
|
||
[[linter]] | ||
code = 'BLACK-ISORT' | ||
include_patterns = [ | ||
'**/*.py', | ||
] | ||
exclude_patterns = [ | ||
'*_pb2*', | ||
'.setuptools-cmake-build/*', | ||
'cmake/**', | ||
'docs/**', | ||
] | ||
command = [ | ||
'python', | ||
'-m', | ||
'lintrunner_adapters', | ||
'run', | ||
'black_isort_linter', | ||
'--', | ||
'@{{PATHSFILE}}' | ||
] | ||
init_command = [ | ||
'python', | ||
'-m', | ||
'lintrunner_adapters', | ||
'run', | ||
'pip_init', | ||
'--dry-run={{DRYRUN}}', | ||
'--requirement=requirements-lintrunner.txt', | ||
] | ||
is_formatter = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is handled by ruff