diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6d7590cda..3d0f8d456 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,23 +1,64 @@ +--- repos: -- repo: git@github.com:Yelp/detect-secrets + - repo: git@github.com:Yelp/detect-secrets rev: v0.13.0 hooks: - - id: detect-secrets - args: ['--baseline', '.secrets.baseline'] + - id: detect-secrets + args: [--baseline, .secrets.baseline] -- repo: https://github.com/pre-commit/pre-commit-hooks + - repo: https://github.com/pre-commit/pre-commit-hooks rev: v2.3.0 hooks: - - id: check-json - - id: check-toml - - id: check-yaml + - id: check-json + - id: check-toml + - id: check-yaml exclude: .gitlab-ci.yml - - id: end-of-file-fixer - - id: fix-encoding-pragma + - id: end-of-file-fixer + - id: fix-encoding-pragma args: [--remove] - - id: no-commit-to-branch + - id: no-commit-to-branch args: [--branch, develop, --branch, master, --pattern, release/.*] - - id: pretty-format-json + - id: pretty-format-json args: [--autofix, --no-sort-keys] - - id: trailing-whitespace + - id: trailing-whitespace args: [--markdown-linebreak-ext=md] + + - repo: local + hooks: + - id: replacer + # More chars can be added + name: Replace unicode dashes with ascii dashes. + language: system + pass_filenames: false + entry: | + sh -c " + # echo -n '–' | hexdump -C # > e2 80 93 + LC_ALL=C + for f in $(ls src/gdcdictionary/schemas/*.yaml); do + # echo 'Converting ' $f + sed -i '' 's/\xe2\x80\x93/-/g' $f + done + " + + - repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt + rev: 0.2.1 + hooks: + - id: yamlfmt + args: [--mapping, '2', --sequence, '4', --offset, '2', --width, '130'] + # TODO: Remove stages so it always run. Do it once all yamls are properly formatted. + stages: [manual] + + - repo: https://github.com/adrienverge/yamllint.git + rev: v1.31.0 + hooks: + - id: yamllint + name: Lint YAML files + args: [--strict] + files: ^src/.*\.(yaml|yml)$ + exclude: | + (?x)^( + sandbox/.*\.(yaml|yml)| + \.yamllint| + \.pre-commit-config\.yaml| + docker-compose-ci\.yaml + )$ diff --git a/.yamllint b/.yamllint new file mode 100644 index 000000000..8b8a0d2be --- /dev/null +++ b/.yamllint @@ -0,0 +1,11 @@ +--- +# SEE https://yamllint.readthedocs.io/en/stable/configuration.html#default-configuration + +extends: default + +rules: + document-start: disable + line-length: + max: 130 + indentation: + indent-sequences: consistent diff --git a/docker-compose-ci.yaml b/docker-compose-ci.yaml index 4d0749683..628e234b7 100644 --- a/docker-compose-ci.yaml +++ b/docker-compose-ci.yaml @@ -1,4 +1,5 @@ -version: "3.3" +--- +version: '3.3' services: app: image: quay.io/ncigdc/jenkins-agent:multipython @@ -7,6 +8,6 @@ services: HTTPS_PROXY: http://cloud-proxy:3128 HTTP_PROXY: http://cloud-proxy:3128 volumes: - - .:/home/jenkins - - $SSH_AUTH_SOCK:$SSH_AUTH_SOCK + - .:/home/jenkins + - $SSH_AUTH_SOCK:$SSH_AUTH_SOCK command: bash -c "tox --recreate" diff --git a/tests/conftest.py b/tests/conftest.py index a9685ab93..ff0b8126d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4,7 +4,7 @@ import os import pytest -from src.gdcdictionary import ROOT_DIR, GDCDictionary +from gdcdictionary import ROOT_DIR, GDCDictionary from tests.utils import load_yaml