agritheory / test_utils

Common Test Utilities and Fixtures for AgriTheory Projects
4 stars 4 forks source link

`validate_customizations` fails in pre-commit GHA while trying to look for apps #54

Open Alchez opened 5 months ago

Alchez commented 5 months ago

Ref: https://github.com/agritheory/shipstation_integration/actions/runs/9460732509/job/26060075732?pr=23

Traceback (most recent call last):
  File "/home/runner/.cache/pre-commit/repoyjuwxzj5/py_env-python3.10/bin/validate_customizations", line 8, in <module>
    sys.exit(main())
  File "/home/runner/.cache/pre-commit/repoyjuwxzj5/py_env-python3.10/lib/python3.10/site-packages/test_utils/pre_commit/validate_customizations.py", line 272, in main
    exceptions = validate_customizations(set_module)
  File "/home/runner/.cache/pre-commit/repoyjuwxzj5/py_env-python3.10/lib/python3.10/site-packages/test_utils/pre_commit/validate_customizations.py", line 253, in validate_customizations
    customized_doctypes = get_customized_doctypes()
  File "/home/runner/.cache/pre-commit/repoyjuwxzj5/py_env-python3.10/lib/python3.10/site-packages/test_utils/pre_commit/validate_customizations.py", line 23, in get_customized_doctypes
    apps_order = apps_order.read_text().split("\n")
  File "/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/pathlib.py", line 1134, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
  File "/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/pathlib.py", line 1119, in open
    return self._accessor.open(self, mode, buffering, encoding, errors,
FileNotFoundError: [Errno 2] No such file or directory: '/home/runner/work/sites/apps.txt'

Solutions?:

This will happen anytime the hook is added to a pre-commit file and then run via GHA. I'm guessing we need to recommend a full bench setup to be able run this particular hook inside the GHA context.

agritheory commented 4 months ago

I propose that we check for the existence of the frappe-bench application via shutil, then see if "sites", "env" and "apps" exist directories. If both of those things are true, we can probably run it.