Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 22 additions & 43 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
# https://github.com/dexpota/cheatsheets/blob/master/pre-commit
exclude: "^tests/data"
fail_fast: true
default_stages: [commit]
default_stages: [pre-commit]
repos:
- repo: local
hooks:
Expand All @@ -47,7 +47,7 @@ repos:
types: [binary]
language: fail
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v6.0.0
hooks:
- id: no-commit-to-branch
args: [--branch, master]
Expand All @@ -62,76 +62,55 @@ repos:
- isort


- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0 # Use the ref you want to point at
hooks:
# Enforce that `# type: ignore` annotations always occur with specific codes.
# Sample annotation: # type: ignore[attr-defined,name-defined]
- id: python-check-blanket-type-ignore


- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.0
rev: v1.17.1
hooks:
- id: mypy
additional_dependencies:
- pyfakefs
- pytest_httpserver
- pytest-subprocess
- types-mock
- types-six
- types-toml


- repo: https://github.com/rcmdnk/pyproject-pre-commit
rev: v0.1.9
rev: v0.4.2
hooks:
- id: shellcheck


- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.42.0
rev: v0.45.0
hooks:
- id: markdownlint


- repo: https://github.com/pycqa/pylint
rev: v2.17.4
hooks:
- id: pylint
args:
[
-sn, # Don't display the score
--load-plugins=pylint.extensions.eq_without_hash,
--ignore-imports=yes,
"--disable=duplicate-code,line-too-long",
]
log_file: ".git/pre-commit-pylint.log"
additional_dependencies:
- pyfakefs
- six
- mock
- pandas
- pytest_forked
- toml
- repo: local
hooks:
- id: pytype
name: pytype (may take up to two minutes)
entry: sh -c "pytype >/dev/tty"
types: [python]
verbose: true
language: python
language_version: python3.8
require_serial: true
additional_dependencies: [pytype]
- id: pytest
name: Check pytest unit tests pass
- id: tox
name: pytest unit tests and static analysis using tox
types: [python]
# entry: sh -c "pytest -x -rf --new-first --show-capture=all >/dev/tty"
entry: sh -c "tox -e py38-covcombine >/dev/tty"
entry: sh -c "tox -e py311-cov-check-pytype-pyright-lint-mdreport >/dev/tty"
verbose: true
language: python
require_serial: true
pass_filenames: false
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0 # Use the ref you want to point at
hooks:
# Enforce that `# type: ignore` annotations always occur with specific codes.
# Sample annotations: # type: ignore[attr-defined] # type: ignore[attr-defined,name-defined]
- id: python-check-blanket-type-ignore
additional_dependencies: [tox]


- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v6.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand Down
15 changes: 10 additions & 5 deletions pylint_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,12 @@ def write_results_as_markdown_tables(branch_url, fp, panda_overview, panda_resul
me = os.path.basename(__file__)
mylink = f"[{me}]({branch_url}/{me})"
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-markdown-content
fp.write(f"### PyLint breakdown from {mylink} on **xcp/\\*\\*/*.py**\n")
fp.write(f"### PyLint summary (by {mylink})\n")
fp.write(panda_overview.to_markdown())
fp.write(f"\n### PyLint results from {mylink} on **xcp/\\*\\*/*.py**\n")
fp.write(panda_results.to_markdown())
fp.write("\n")
if not panda_results.empty:
fp.write("### PyLint results\n")
fp.write(panda_results.to_markdown())


if __name__ == "__main__":
Expand All @@ -242,7 +244,7 @@ def write_results_as_markdown_tables(branch_url, fp, panda_overview, panda_resul
branch = os.environ.get("GITHUB_HEAD_REF", None) or os.environ.get("GITHUB_REF_NAME", None)
ghblob_url = f"{server_url}/{repository}/blob/{branch}"

# Like the previous run-pylint.sh, check the xcp module by default:
# By default, run pylint on xcp/ and tests/
dirs_to_check = sys.argv[1:] if len(sys.argv) > 1 else ["xcp", "tests"]

# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary
Expand All @@ -255,5 +257,8 @@ def write_results_as_markdown_tables(branch_url, fp, panda_overview, panda_resul
#
pylint_txt = os.environ.get("ENVLOGDIR", ".tox") + "/pylint.txt"

print("Checking:", str(dirs_to_check) + "; Writing report to:", step_summary)
print("Checking:", " ".join(dirs_to_check) + ". Writing report to:", step_summary)
main(dirs_to_check, step_summary, pylint_txt, ghblob_url)
# Show the report
with open(step_summary, "r", encoding="utf-8") as fp:
print(fp.read())
Loading