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

Fix pre-commit GitHub Action cache #4746

Merged
merged 1 commit into from
Dec 6, 2023
Merged

Fix pre-commit GitHub Action cache #4746

merged 1 commit into from
Dec 6, 2023

Conversation

agners
Copy link
Member

@agners agners commented Dec 6, 2023

Proposed change

Currently pre-commit caching seems not to work properly: There is no cache stored according to GitHub Action tab, and the Prepare Python dependencies job shows the following warning: Warning: Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.

This seems to be similar to what have been observed and solved in Home Assistant Core with home-assistant/core#46696. Use PRE_COMMIT_CACHE instead of PRE_COMMIT_HOME as well.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (which adds functionality to the supervisor)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:
  • Link to cli pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast supervisor tests)
  • Tests have been added to verify that the new code works.

If API endpoints of add-on configuration are added/changed:

Currently pre-commit caching seems not to work properly: There is
no cache stored according to GitHub Action tab, and the Prepare
Python dependencies job shows the following warning:
Warning: Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.

This seems to be similar to what have been observed and solved in
Home Assistant Core with home-assistant/core#46696.
Use PRE_COMMIT_CACHE instead of PRE_COMMIT_HOME as well.
@agners agners added the github_actions Pull requests that update Github_actions code label Dec 6, 2023
@agners
Copy link
Member Author

agners commented Dec 6, 2023

The difference is just a couple of seconds 🙈

Before:

image

(https://github.com/home-assistant/supervisor/actions/runs/7112818833)

After:

image

(https://github.com/home-assistant/supervisor/actions/runs/7113102530)

But the error is gone 🎉

@agners agners merged commit 8c8122e into main Dec 6, 2023
23 checks passed
@agners agners deleted the fix-pre-commit-cache branch December 6, 2023 10:30
@agners
Copy link
Member Author

agners commented Dec 6, 2023

I also understand the reason now why this did not work: The environment variable really got the string assigned (as in PRE_COMMIT_HOME="~/.cache/pre-commit"). It seems that pre-commit uses PRE_COMMIT_HOME, but doesn't expand this path hence the cache landed in the current directory in a directory named ~ 🙈 . The GitHub Action cache path does expand this path, so tries to cache the right location.

Using a different variable name makes pre-commit use the default path, and GitHub Action storing that default path properly.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla-signed github_actions Pull requests that update Github_actions code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants