Unverified Commit 97ff7087 authored by James Lamb's avatar James Lamb Committed by GitHub
Browse files

[ci] use 'pre-commit' to run 'rstcheck' (#6989)


Co-authored-by: default avatarNikita Titov <nekit94-08@mail.ru>
parent ccc06d19
...@@ -115,7 +115,7 @@ if [[ $TASK == "lint" ]]; then ...@@ -115,7 +115,7 @@ if [[ $TASK == "lint" ]]; then
# shellcheck disable=SC1091 # shellcheck disable=SC1091
source activate "${CONDA_ENV}" source activate "${CONDA_ENV}"
echo "Linting Python and bash code" echo "Linting Python and bash code"
bash ./.ci/lint-python-bash.sh || exit 1 bash ./.ci/run-pre-commit-mypy.sh || exit 1
echo "Linting R code" echo "Linting R code"
Rscript ./.ci/lint-r-code.R "${BUILD_DIRECTORY}" || exit 1 Rscript ./.ci/lint-r-code.R "${BUILD_DIRECTORY}" || exit 1
echo "Linting C++ code" echo "Linting C++ code"
...@@ -129,19 +129,8 @@ if [[ $TASK == "check-docs" ]] || [[ $TASK == "check-links" ]]; then ...@@ -129,19 +129,8 @@ if [[ $TASK == "check-docs" ]] || [[ $TASK == "check-links" ]]; then
conda env create \ conda env create \
-n "${CONDA_ENV}" \ -n "${CONDA_ENV}" \
--file ./docs/env.yml || exit 1 --file ./docs/env.yml || exit 1
conda install \
-q \
-y \
-n "${CONDA_ENV}" \
'doxygen>=1.10.0' \
'rstcheck>=6.2.4' || exit 1
# shellcheck disable=SC1091 # shellcheck disable=SC1091
source activate "${CONDA_ENV}" source activate "${CONDA_ENV}"
# check reStructuredText formatting
find "${BUILD_DIRECTORY}/python-package" -type f -name "*.rst" \
-exec rstcheck --report-level warning {} \+ || exit 1
find "${BUILD_DIRECTORY}/docs" -type f -name "*.rst" \
-exec rstcheck --report-level warning --ignore-directives=autoclass,autofunction,autosummary,doxygenfile {} \+ || exit 1
# build docs # build docs
make -C docs html || exit 1 make -C docs html || exit 1
if [[ $TASK == "check-links" ]]; then if [[ $TASK == "check-links" ]]; then
......
...@@ -27,6 +27,15 @@ repos: ...@@ -27,6 +27,15 @@ repos:
hooks: hooks:
- id: yamllint - id: yamllint
args: ["--strict"] args: ["--strict"]
- repo: https://github.com/rstcheck/rstcheck
rev: v6.2.5
hooks:
- id: rstcheck
args: ["--config", "./python-package/pyproject.toml"]
additional_dependencies:
- breathe>=4.36.0
- sphinx>=8.1.3
- sphinx_rtd_theme>=3.0.1
- repo: https://github.com/astral-sh/ruff-pre-commit - repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version. # Ruff version.
rev: v0.12.5 rev: v0.12.5
......
...@@ -3,7 +3,8 @@ channels: ...@@ -3,7 +3,8 @@ channels:
- nodefaults - nodefaults
- conda-forge - conda-forge
dependencies: dependencies:
- breathe>=4.35 - breathe>=4.36
- doxygen>=1.13.2
- python=3.12 - python=3.12
- r-base>=4.3.3 - r-base>=4.3.3
- r-data.table=1.16.4 - r-data.table=1.16.4
......
...@@ -346,7 +346,7 @@ To check that a contribution to the package matches its style expectations, run ...@@ -346,7 +346,7 @@ To check that a contribution to the package matches its style expectations, run
.. code:: sh .. code:: sh
bash .ci/lint-python-bash.sh bash .ci/run-pre-commit-mypy.sh
To run the tests locally and compute test coverage, install the Python package using one of the options mentioned above. To run the tests locally and compute test coverage, install the Python package using one of the options mentioned above.
Then run the following from the root of the repo. Then run the following from the root of the repo.
......
...@@ -91,6 +91,15 @@ disallow_untyped_defs = true ...@@ -91,6 +91,15 @@ disallow_untyped_defs = true
exclude = 'build/*|compile/*|docs/*|examples/*|external_libs/*|lightgbm-python/*|tests/*' exclude = 'build/*|compile/*|docs/*|examples/*|external_libs/*|lightgbm-python/*|tests/*'
ignore_missing_imports = true ignore_missing_imports = true
[tool.rstcheck]
report_level = "WARNING"
ignore_directives = [
"autoclass",
"autofunction",
"autosummary",
"doxygenfile"
]
[tool.ruff] [tool.ruff]
exclude = [ exclude = [
"build", "build",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment