Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a little check to make sure the pre-commit hooks ran as expected #502

Closed
wants to merge 1 commit into from

Conversation

MatMoore
Copy link
Contributor

I've made this into a comment rather than a failing check, because I've noticed instances where the pre-commit hook doesn't do the right thing.

For example, djhtml refuses to process templates/navigation.html, because it contains a long line. This is because the crown logo SVG from the header contains a very long path attribute.

@MatMoore MatMoore requested a review from a team as a code owner June 26, 2024 14:28
@MatMoore MatMoore force-pushed the run-pre-commit-hooks-in-ci branch from edf43fd to 17a1da3 Compare June 26, 2024 14:30
@MatMoore MatMoore force-pushed the run-pre-commit-hooks-in-ci branch from 17a1da3 to afc4810 Compare June 26, 2024 14:33
@MatMoore MatMoore force-pushed the run-pre-commit-hooks-in-ci branch from afc4810 to 403b4ef Compare June 26, 2024 14:35
@MatMoore MatMoore force-pushed the run-pre-commit-hooks-in-ci branch from 403b4ef to 30abd6e Compare June 26, 2024 14:38
@MatMoore MatMoore force-pushed the run-pre-commit-hooks-in-ci branch from 30abd6e to d9dfb6d Compare June 26, 2024 14:48
@MatMoore MatMoore force-pushed the run-pre-commit-hooks-in-ci branch from d9dfb6d to 85c42d2 Compare June 26, 2024 14:50
@MatMoore MatMoore closed this Jun 26, 2024
@MatMoore MatMoore reopened this Jun 26, 2024
@MatMoore MatMoore force-pushed the run-pre-commit-hooks-in-ci branch from 85c42d2 to b1f0782 Compare June 26, 2024 14:53
@MatMoore MatMoore closed this Jun 26, 2024
@MatMoore MatMoore reopened this Jun 26, 2024
@MatMoore MatMoore force-pushed the run-pre-commit-hooks-in-ci branch from b1f0782 to 1f39450 Compare June 26, 2024 14:54
@MatMoore MatMoore closed this Jun 26, 2024
@MatMoore MatMoore reopened this Jun 26, 2024
@MatMoore MatMoore force-pushed the run-pre-commit-hooks-in-ci branch from 1f39450 to 713fb30 Compare June 26, 2024 14:56
@MatMoore MatMoore closed this Jun 26, 2024
I've made this into a comment rather than a failing check, because
I've noticed instances where the pre-commit hook doesn't do the right
thing.

For example, djhtml refuses to process templates/navigation.html,
because it contains a long line. This is because the crown logo SVG from
the header contains a very long path attribute.
@MatMoore MatMoore force-pushed the run-pre-commit-hooks-in-ci branch from 68d8cab to 0075b08 Compare June 26, 2024 15:08
@MatMoore MatMoore marked this pull request as draft June 26, 2024 15:08
@MatMoore MatMoore closed this Jun 26, 2024
@MatMoore MatMoore reopened this Jun 26, 2024
Copy link
Contributor

⚠️ Make sure you have pre-commit installed.\n\npre-commit output: [INFO] Initializing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Initializing environment for https://github.com/psf/black.
[INFO] Initializing environment for https://github.com/PyCQA/flake8.
[INFO] Initializing environment for https://github.com/PyCQA/flake8:flake8-broken-line,flake8-bugbear,flake8-comprehensions,flake8-debugger,flake8-string-format,Flake8-pyproject.
[INFO] Initializing environment for https://github.com/Yelp/detect-secrets.
[INFO] Initializing environment for https://github.com/pycqa/isort.
[INFO] Initializing environment for https://github.com/pycqa/isort:toml.
[INFO] Initializing environment for https://github.com/floatingpurr/sync_with_poetry.
[INFO] Initializing environment for https://github.com/rtts/djhtml.
[INFO] Installing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/psf/black.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/PyCQA/flake8.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/Yelp/detect-secrets.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/pycqa/isort.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/floatingpurr/sync_with_poetry.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/rtts/djhtml.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
fix requirements.txt.................................(no files to check)Skipped
check yaml...............................................................Passed
fix end of files.........................................................Failed

  • hook id: end-of-file-fixer
  • exit code: 1
  • files were modified by this hook

Fixing scss/_glossary.scss
Fixing templates/partial/contact_team.html
Fixing scss/_details.scss
Fixing templates/partial/sort.html
Fixing templates/partial/no_results.html
Fixing templates/base/navigation.html
Fixing templates/partial/esda_info.html
Fixing .github/workflows/test-datahub-client.yml

trim trailing whitespace.................................................Failed

  • hook id: trailing-whitespace
  • exit code: 1
  • files were modified by this hook

Fixing deployments/templates/deployment.yml
Fixing templates/details_table.html

black formatting.........................................................Failed

  • hook id: black
  • files were modified by this hook

reformatted home/templatetags/snippets.py

All done! ✨ 🍰 ✨
1 file reformatted, 94 files left unchanged.

flake8 lint..............................................................Failed

  • hook id: flake8
  • exit code: 1

home/templatetags/lookup.py:9:90: E501 line too long (98 > 89 characters)
home/templatetags/snippets.py:17:90: E501 line too long (91 > 89 characters)
lib/datahub-client/tests/test_helpers/graph_helpers.py:1:90: E501 line too long (116 > 89 characters)
lib/datahub-client/tests/test_helpers/graph_helpers.py:63:90: E501 line too long (100 > 89 characters)
lib/datahub-client/tests/test_helpers/mce_helpers.py:1:90: E501 line too long (114 > 89 characters)
lib/datahub-client/tests/test_helpers/mce_helpers.py:106:90: E501 line too long (94 > 89 characters)
lib/datahub-client/tests/test_helpers/mce_helpers.py:157:16: C403 Unnecessary list comprehension - rewrite as a set comprehension.
lib/datahub-client/tests/test_helpers/mce_helpers.py:164:16: C403 Unnecessary list comprehension - rewrite as a set comprehension.
lib/datahub-client/tests/test_helpers/mce_helpers.py:253:16: C403 Unnecessary list comprehension - rewrite as a set comprehension.
lib/datahub-client/tests/test_helpers/mce_helpers.py:260:16: C403 Unnecessary list comprehension - rewrite as a set comprehension.
lib/datahub-client/tests/test_helpers/mce_helpers.py:300:90: E501 line too long (97 > 89 characters)
lib/datahub-client/tests/test_helpers/mce_helpers.py:365:16: C403 Unnecessary list comprehension - rewrite as a set comprehension.
lib/datahub-client/tests/test_helpers/mce_helpers.py:372:16: C403 Unnecessary list comprehension - rewrite as a set comprehension.
lib/datahub-client/tests/test_helpers/mce_helpers.py:395:16: C403 Unnecessary list comprehension - rewrite as a set comprehension.
lib/datahub-client/tests/test_helpers/mce_helpers.py:402:16: C403 Unnecessary list comprehension - rewrite as a set comprehension.
lib/datahub-client/tests/test_helpers/mce_helpers.py:416:90: E501 line too long (92 > 89 characters)
lib/datahub-client/tests/test_helpers/type_helpers.py:1:90: E501 line too long (115 > 89 characters)
lib/datahub-client/tests/test_helpers/type_helpers.py:9:90: E501 line too long (92 > 89 characters)
tests/benchmark/test_exact_matches.py:19:90: E501 line too long (128 > 89 characters)
tests/benchmark/test_exact_matches.py:27:90: E501 line too long (132 > 89 characters)
tests/home/service/test_glossary.py:16:90: E501 line too long (91 > 89 characters)
tests/home/service/test_glossary.py:35:90: E501 line too long (91 > 89 characters)
tests/home/service/test_glossary.py:60:90: E501 line too long (91 > 89 characters)
tests/home/templatetags/test_snippets.py:16:90: E501 line too long (155 > 89 characters)
tests/home/templatetags/test_snippets.py:19:90: E501 line too long (435 > 89 characters)
tests/home/templatetags/test_snippets.py:21:90: E501 line too long (330 > 89 characters)
tests/home/templatetags/test_snippets.py:30:90: E501 line too long (98 > 89 characters)
tests/test_views.py:1:1: F401 'data_platform_catalogue.search_types.SearchResponse' imported but unused
users/admin.py:1:1: F401 'django.contrib.admin' imported but unused
users/migrations/0001_initial.py:39:90: E501 line too long (117 > 89 characters)
users/migrations/0001_initial.py:67:90: E501 line too long (134 > 89 characters)
users/tests.py:1:1: F401 'django.test.TestCase' imported but unused
users/views.py:1:1: F401 'django.shortcuts.render' imported but unused

Detect secrets...........................................................Failed

  • hook id: detect-secrets
  • exit code: 1

ERROR: Potential secrets about to be committed to git repo!

Secret Type: Base64 High Entropy String
Location: jest.config.js:15

Possible mitigations:

  • For information about putting your secrets in a safer place, please ask in
    #security
  • Mark false positives with an inline pragma: allowlist secret comment

If a secret has already been committed, visit
https://help.github.com/articles/removing-sensitive-data-from-a-repository

isort (python)...........................................................Failed

  • hook id: isort
  • files were modified by this hook

Fixing /home/runner/work/find-moj-data/find-moj-data/core/urls.py
Fixing /home/runner/work/find-moj-data/find-moj-data/lib/datahub-client/data_platform_catalogue/client/search.py
Fixing /home/runner/work/find-moj-data/find-moj-data/lib/datahub-client/tests/test_helpers/mce_helpers.py
Fixing /home/runner/work/find-moj-data/find-moj-data/tests/test_views.py

Sync with Poetry.........................................................Passed
DjHTML...................................................................Failed

  • hook id: djhtml
  • exit code: 123
  • files were modified by this hook

Error: Maximum line length exceeded in templates/base/navigation.html
reindented templates/details_table.html
reindented templates/partial/esda_info.html
reindented templates/partial/no_results.html
reindented templates/partial/sort.html
4 templates have been reindented.
22 templates were already perfect!
1 template could not be processed due to an error.

DjCSS....................................................................Passed
DjJS.....................................................................Failed

  • hook id: djjs
  • files were modified by this hook

reindented static/assets/js/enhanced-glossary.js
1 template has been reindented.
6 templates were already perfect!

@MatMoore
Copy link
Contributor Author

I'm closing this for now as I didn't get this working with staged changes only, and we can't run it against the whole repo while we have non-linted code in the codebase.

@MatMoore MatMoore closed this Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant