diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml index 411807a3b..2139bb860 100644 --- a/.github/workflows/Build.yml +++ b/.github/workflows/Build.yml @@ -33,6 +33,11 @@ jobs: pip install flake8 pytest pytest-cov if [ -f requirements.txt ]; then pip install -r requirements.txt; fi if [ -f tests_requirements.txt ]; then pip install -r tests_requirements.txt; fi + - name: Run pre-commit hooks + env: + LEAKTK_PATTERN_SERVER_AUTH_TOKEN: ${{ secrets.LEAKTK_PATTERN_SERVER_AUTH_TOKEN }} + run: | + pre-commit run --all-files - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names diff --git a/.github/workflows/PR.yml b/.github/workflows/PR.yml index 4486cf308..c3d5cad4f 100644 --- a/.github/workflows/PR.yml +++ b/.github/workflows/PR.yml @@ -40,6 +40,11 @@ jobs: pip install flake8 pytest pytest-cov if [ -f requirements.txt ]; then pip install -r requirements.txt; fi if [ -f tests_requirements.txt ]; then pip install -r tests_requirements.txt; fi + - name: Run pre-commit hooks + env: + LEAKTK_PATTERN_SERVER_AUTH_TOKEN: ${{ secrets.LEAKTK_PATTERN_SERVER_AUTH_TOKEN }} + run: | + pre-commit run --all-files - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..77eef0304 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,17 @@ +--- +repos: + - repo: https://gitlab.corp.redhat.com/infosec-public/developer-workbench/tools.git + rev: rh-pre-commit-2.2.0 + hooks: + # If you have not run this hook on your system before, it may prompt you to + # log in for patterns, and you will need to try again. + # + # Docs: https://source.redhat.com/departments/it/it-information-security/leaktk/leaktk_components/rh_pre_commit + - id: rh-pre-commit + # - id: rh-pre-commit.commit-msg # Optional for commit-msg attestation + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-json + - id: check-yaml diff --git a/tests_requirements.txt b/tests_requirements.txt index acc5b04f2..92b1db035 100644 --- a/tests_requirements.txt +++ b/tests_requirements.txt @@ -10,6 +10,7 @@ elasticsearch-dsl==7.4.0 moto==2.3.2 oauthlib~=3.1.1 pandas +pre-commit==3.7.1 pytest python-ldap==3.4.2 requests==2.32.2