From c257c27e319bb9d2fc16d209aea2ff1da3517cca Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Tue, 20 Oct 2020 23:09:10 +0100 Subject: [PATCH 1/5] Workflow improvements * dependabot for dependencies * pre-commit for local workflow, plus configuration files - note, no onboarding instructions yet - things are assumed to be installable via pre-commit or on PATH already. --- .editorconfig | 10 ++++++ .flake8 | 5 +++ .gitattributes | 11 +++++++ .github/dependabot.yml | 11 +++++++ .pre-commit-config.yaml | 73 +++++++++++++++++++++++++++++++++++++++++ .yamllint.yaml | 18 ++++++++++ ci/requirements.txt | 1 + 7 files changed, 129 insertions(+) create mode 100644 .editorconfig create mode 100644 .flake8 create mode 100644 .gitattributes create mode 100644 .github/dependabot.yml create mode 100644 .pre-commit-config.yaml create mode 100644 .yamllint.yaml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..b05a9ee --- /dev/null +++ b/.editorconfig @@ -0,0 +1,10 @@ +# editorconfig.org +root = true + +[*] +indent_style = space +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +indent_size = 2 diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..20ec88e --- /dev/null +++ b/.flake8 @@ -0,0 +1,5 @@ +# https://flake8.pycqa.org/en/latest/user/configuration.html#configuration-locations +[flake8] +ignore = + # don't care about line length. + E501 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..7fd0f73 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,11 @@ +# make github collapse diffs for generated files within PRs +# https://github.com/github/linguist#generated-code + +# make github know about vendored code +# https://github.com/github/linguist#vendored-code +**/vendor/** linguist-vendored + +# OWNERS files are YAML +OWNERS linguist-language=Yaml +**/OWNERS linguist-language=Yaml +OWNERS_ALIASES linguist-language=Yaml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..08afe93 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +--- +version: 2 +updates: + - package-ecosystem: pip + directory: /ci + schedule: + interval: daily + - package-ecosystem: pip + directory: /python + schedule: + interval: daily diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..f8100e0 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,73 @@ +--- +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks + +# ignore: +# vendor'd code (that has vendor in its path) +exclude: vendor + +repos: + - repo: https://github.com/adrienverge/yamllint + rev: v1.20.0 + hooks: + - id: yamllint + args: + - --format=parsable + - --strict + + - repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt + rev: 0.0.10 # or higher tag + hooks: + - id: yamlfmt + args: + - --mapping=2 + - --sequence=4 + - --offset=2 + - --width=1200 # match .yamllint.yaml; we don't care about line-length. + exclude: repocop.yaml + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.4.0 + hooks: + - id: check-added-large-files + - id: check-byte-order-marker + - id: check-case-conflict + - id: check-executables-have-shebangs + - id: check-json + - id: check-merge-conflict + - id: check-symlinks + - id: detect-private-key + - id: end-of-file-fixer + - id: forbid-new-submodules + - id: mixed-line-ending + - id: pretty-format-json + args: + - --autofix + - id: trailing-whitespace + + - repo: https://github.com/syntaqx/git-hooks + rev: v0.0.16 + hooks: + - id: forbid-binary + # Exclude png and snapshots forbid, we can check these in. + exclude: ^.+\.(png|snapshot)$ + # See checks in shellcheck wiki: https://github.com/koalaman/shellcheck/wiki/ + - id: shellcheck + - id: shfmt + # do not use these args (yet): + # -s, simplify code + # -mn, minify to reduce its size + args: + - -w # autofix in place + - -d # show diff + - -i=2 # indent 2 spaces + + - repo: https://github.com/PyCQA/pylint + rev: pylint-2.6.0 + hooks: + - id: pylint + + - repo: https://gitlab.com/pycqa/flake8 + rev: 3.8.4 + hooks: + - id: flake8 diff --git a/.yamllint.yaml b/.yamllint.yaml new file mode 100644 index 0000000..6b2085f --- /dev/null +++ b/.yamllint.yaml @@ -0,0 +1,18 @@ +--- +# https://yamllint.readthedocs.io/en/stable/configuration.html#default-configuration +extends: default + +yaml-files: + - .toolsharerc + - .yamllint.yaml + - '*.yaml' + - '*.yml' + - OWNERS_ALIASES + - OWNERS + +rules: + document-start: + level: error + line-length: + max: 1200 + level: warning diff --git a/ci/requirements.txt b/ci/requirements.txt index 97c9348..5d0190c 100644 --- a/ci/requirements.txt +++ b/ci/requirements.txt @@ -1,2 +1,3 @@ +pre-commit==2.7.1 pytest==4.5.0 pylint==2.3.1 From 657436abc3f22b63eee1941a797aeec9ccb7f2db Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Tue, 20 Oct 2020 23:25:06 +0100 Subject: [PATCH 2/5] You had me at 'The Uncompromising Code Formatter'. --- .pre-commit-config.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f8100e0..3d66bd3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -71,3 +71,8 @@ repos: rev: 3.8.4 hooks: - id: flake8 + + - repo: https://github.com/psf/black + rev: 20.8b1 + hooks: + - id: black From 73ec64c2d55350708ccbd8995b6b6fe4ea5a88b2 Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Tue, 20 Oct 2020 23:30:22 +0100 Subject: [PATCH 3/5] latest versions since everything's new anyway --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3d66bd3..694f621 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,7 +8,7 @@ exclude: vendor repos: - repo: https://github.com/adrienverge/yamllint - rev: v1.20.0 + rev: v1.25.0 hooks: - id: yamllint args: @@ -16,7 +16,7 @@ repos: - --strict - repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt - rev: 0.0.10 # or higher tag + rev: 0.1.0 # or higher tag hooks: - id: yamlfmt args: @@ -27,7 +27,7 @@ repos: exclude: repocop.yaml - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.4.0 + rev: v3.3.0 hooks: - id: check-added-large-files - id: check-byte-order-marker From f081580b09530c6770c2b802e5194918c87462ff Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Wed, 21 Oct 2020 15:56:59 +0100 Subject: [PATCH 4/5] tweak python rules --- .flake8 | 8 +++++--- .pre-commit-config.yaml | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.flake8 b/.flake8 index 20ec88e..7a4edca 100644 --- a/.flake8 +++ b/.flake8 @@ -1,5 +1,7 @@ # https://flake8.pycqa.org/en/latest/user/configuration.html#configuration-locations +# + +# https://github.com/psf/black/blob/master/docs/the_black_code_style.md#line-length [flake8] -ignore = - # don't care about line length. - E501 +# black wraps at 88 +max-line-length = 90 +extend-ignore = E203 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 694f621..cf499cf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -76,3 +76,5 @@ repos: rev: 20.8b1 hooks: - id: black + args: + - --skip-string-normalization From 7400824cadef46474f59c9aea8e9b8cbab3edf0d Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Wed, 21 Oct 2020 16:00:04 +0100 Subject: [PATCH 5/5] server.zip is ok --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cf499cf..c1783eb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -49,8 +49,8 @@ repos: rev: v0.0.16 hooks: - id: forbid-binary - # Exclude png and snapshots forbid, we can check these in. - exclude: ^.+\.(png|snapshot)$ + # Exclude png and server.zip forbid, we can check these in. + exclude: ^.+\.(png|server\.zip)$ # See checks in shellcheck wiki: https://github.com/koalaman/shellcheck/wiki/ - id: shellcheck - id: shfmt