Skip to content

Commit

Permalink
Update pre-commit, remove vale (#1282)
Browse files Browse the repository at this point in the history
* Update pre-commit, remove vale

* Add conditional

* run pre-commit on all files

* mdformat fixes

* fix broken link

* chore: format terraform files

* Ignore E402 for jh py configs

Co-authored-by: Christopher Ostrouchov <chris.ostrouchov@gmail.com>
Co-authored-by: HarshCasper <erbeusgriffincasper@gmail.com>
  • Loading branch information
3 people authored May 26, 2022
1 parent dc5218c commit d0cc266
Show file tree
Hide file tree
Showing 181 changed files with 664 additions and 1,577 deletions.
4 changes: 1 addition & 3 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
blank_issues_enabled: false
contact_links:
- name: QHub Documentation 📖
- name: QHub Documentation 📖
url: https://docs.qhub.dev/en/stable/
about: Read QHub docs and development guide.
- name: GitHub discussions 💬
Expand All @@ -9,5 +9,3 @@ contact_links:
- name: "(maintainers only) Blank issue"
url: https://github.com/Quansight/qhub/issues/new
about: For maintainers only - should be used sparingly


39 changes: 0 additions & 39 deletions .github/workflows/docs.yml

This file was deleted.

1 change: 0 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,3 @@ jobs:
# and that the branch release-<version> also points to this tag
# and that terraform-modules tag release-{version} exists.
# See https://github.com/Quansight/qhub/issues/544

23 changes: 23 additions & 0 deletions .github/workflows/run-pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Run pre-commit

on:
push:
branches: [ main ]
pull_request:

jobs:
pre-commit:
if: github.event.pull_request.merged == false
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install pre-commit
run: pip install pre-commit

- name: Run pre-commit
run: pre-commit run --all
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,3 @@ data*
qhub-config.yaml

.vscode/

# Ignore Vale
./vale
6 changes: 0 additions & 6 deletions .hadolint.yaml

This file was deleted.

9 changes: 0 additions & 9 deletions .mdformat.toml

This file was deleted.

126 changes: 78 additions & 48 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,49 +1,79 @@
# These pre-commit hooks are run as CI.

# NOTE: if it can be avoided, add configs/args in pyproject.toml, setup.cfg or below instead of creating a new `.config.file`.


repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
exclude: 'qhub/template/(\.github/.*|infrastructure/jupyterhub.yaml|stages/07-kubernetes-services/modules/kubernetes/services/(clearml/chart/templates/.*|prefect/chart/templates/.*))'
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
exclude: '/qhub/template/'
- repo: https://github.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8
exclude: 'qhub/template'
args: [
"--builtins=c"
]
- repo: https://github.com/hadolint/hadolint.git
rev: v2.3.0
hooks:
- id: hadolint-docker
entry: hadolint/hadolint:v2.3.0 hadolint
args: [
"--ignore", "DL3048",
"--ignore", "DL3008",
"--ignore", "DL3013",
"--ignore", "DL3003",
]
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.13
hooks:
- id: mdformat
files: ^docs/
name: mdformat
description: "CommonMark compliant Markdown formatter"
entry: mdformat
language: python
# This is to support a use case where pre-commit runs in Python 2.
# Should eventually be removed, at latest when `minimum_pre_commit_version`
# is set to 2.0.0.
language_version: python3
types: [markdown]
minimum_pre_commit_version: '1.0.0'
additional_dependencies:
- mdformat-tables
# general
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-json
- id: check-yaml
# jinja2 templates for helm charts
exclude: 'qhub/template/stages/07-kubernetes-services/modules/kubernetes/services/(clearml/chart/templates/.*|prefect/chart/templates/.*)'

- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
hooks:
- id: codespell
# --write (-w) enabled here
# see setup.cfg for more config options
entry: codespell -w
language: python

# python
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black

- repo: https://github.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8
args: [
"--builtins=c"
]

- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
name: isort
args: ["--profile", "black"]

# terraform
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.71.0
hooks:
- id: terraform_fmt
args:
- --args=-write=true

# docker
- repo: https://github.com/hadolint/hadolint.git
rev: v2.10.0
hooks:
- id: hadolint-docker
entry: hadolint/hadolint:v2.10.0 hadolint
args: [
"--failure-threshold", "info", # default: info
"--ignore", "DL3048", # style complaint: Invalid Label Key
]

# markdown
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.14
hooks:
- id: mdformat
files: ^docs/
name: mdformat
entry: mdformat --wrap=180 --number --end-of-line=lf
language: python
types: [markdown]
minimum_pre_commit_version: '2.0.0'
additional_dependencies:
- mdformat-tables
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ python:
- method: pip
path: .
extra_requirements: []
- requirements: docs/requirements.txt
- requirements: docs/requirements.txt
5 changes: 0 additions & 5 deletions .vale.ini

This file was deleted.

2 changes: 1 addition & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ Explicit user facing changes:
- Pin terraform providers by @Adam-D-Lewis in https://github.com/Quansight/qhub/pull/914
- qhub-config.yaml as a secret by @danlester in https://github.com/Quansight/qhub/pull/905
- Setup/Add integration/deployment tests via pytest by @aktech in https://github.com/Quansight/qhub/pull/922
- Disabl/Remove the stale bot by @viniciusdc in https://github.com/Quansight/qhub/pull/923
- Disable/Remove the stale bot by @viniciusdc in https://github.com/Quansight/qhub/pull/923
- Integrates Hadolint for Dockerfile linting by @HarshCasper in https://github.com/Quansight/qhub/pull/917
- Reduce minimum nodes in user and dask node pools to 0 for Azure / GCP by @tarundmsharma in https://github.com/Quansight/qhub/pull/723
- Allow jupyterhub.overrides in qhub-config.yaml by @danlester in https://github.com/Quansight/qhub/pull/930
Expand Down
3 changes: 2 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Configuration file for the Sphinx documentation builder.

import os, sys
import os
import sys

# -- Project information -----------------------------------------------------

Expand Down
1 change: 0 additions & 1 deletion docs/output/.nojekyll
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
jupyter-book
jupyter-book
2 changes: 1 addition & 1 deletion docs/source/admin_guide/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ has an [autoscaler](https://docs.aws.amazon.com/eks/latest/userguide/cluster-aut
between the two availability zones. When large Dask clusters get initialized and destroyed, the autoscaler attempts to reschedule a user pod. This reschedule operation occurs in
the other availability zone. When this happens, Kubernetes doesn't successfully transfer the active pod to the other zone and the pod dies.

To stop this occuring, the autoscaler service "AZRebalance" needs to be manually suspended. Currently this autoscaler service isn't managed by terraform. Disabling it via the
To stop this occurring, the autoscaler service "AZRebalance" needs to be manually suspended. Currently this autoscaler service isn't managed by terraform. Disabling it via the
console is permanent for the life of the cluster. [There is an open issue to permanently fix this via Terraform](https://github.com/Quansight/qhub/issues/786)

To turn off the AZRebalance service, follow the steps in this [AWS documentation](https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-suspend-resume-processes.html) to suspend
Expand Down
2 changes: 1 addition & 1 deletion docs/source/admin_guide/gpu.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ The important section is `CUDA Version`. In general you should install a version
`cudatoolkit-dev` and `cudatoolkit` make sure that they are the same version exactly including minor version. Also in the near future cuda should have better
[ABI compatibility](https://docs.nvidia.com/deploy/cuda-compatibility/index.html).

Bellow is an example gpu environment:
Below is an example gpu environment:

```yaml
name: gpu-environment
Expand Down
31 changes: 2 additions & 29 deletions docs/source/dev_guide/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ export QHUB_K8S_VERSION=1.20

## Modifying Docker Images

All QHub docker images are located in
[`qhub/template/image`](https://github.com/Quansight/qhub/tree/main/qhub/template/image).
You can build any image locally. Additionally, on Pull Requests each Docker-build will be tested.
All QHub docker images are located in [`qhub/template/image`](https://github.com/Quansight/qhub/tree/main/qhub/template/image). You can build any image locally. Additionally, on
Pull Requests each Docker-build will be tested.

```shell
docker build -f Dockerfile.<filename> .
Expand Down Expand Up @@ -129,29 +128,3 @@ JupyterHub or JupyterLab. That will be because your qhub-config.yaml references
to encourage the Docker images to be specified based on the latest development code.

You should always prefer the local testing when possible as it will be easier to debug, may be quicker to deploy, and is likely to be less expensive.

# Docs testing

QHub uses [Vale](https://github.com/errata-ai/vale), a syntax-aware linter to lint documentation and recommend regions that needs improvement. Vale works with the
[Google developer documentation style guide](https://developers.google.com/style), with specific configurations that are specific to Quansight. To test the documentation on the
local machine, follow these steps:

- [Install Vale command-line tool](https://docs.errata.ai/vale/install).
- Run Vale on the entire documentation source or a specific documentation piece.
```sh
# Run Vale on the entire documentation source
$ vale docs/

# Run Vale on a specific file
$ vale README.md
```
- Utilize the errors, warnings and the suggestions to make appropriate changes to the documentation.
- In case of false positives, make appropriate changes to the Vale configurations hosted in the `tests/vale/styles` directory.

Vale runs on the GitHub Actions CI to automatically validate the documentation language. By default, Vale only checks the modified documentation to ensure that Vale doesn't
generate a lot of noise over the Pull Requests.

# Links Testing

Make sure to add tests for any links present in error message displayed to the user. These tests
can be added easily here: `tests/test_links.py`
Loading

0 comments on commit d0cc266

Please sign in to comment.