home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
68.78k stars 28.11k forks source link

Add HA version to cache key #116159

Closed cdce8p closed 1 week ago

cdce8p commented 1 week ago

Proposed change

Force creation of new venv after a HA version bump. Although the venv could technically be reused, we want to create a new one to populate the wheels cache and speedup subsequent PRs.

The wheels cache is only created if a new venv is needed.

Type of change

Additional information

Checklist

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

To help with the load of incoming pull requests:

emontnemery commented 1 week ago

@cdce8p please motivate why the home assistant version should be part of the cache key, it's not clear from the PR description

cdce8p commented 1 week ago

Some background. To speed up the venv creation, we also cache the wheels. That cache is reset after each HA version bump (through the cache key) to keep it from growing indefinitely. No need to cache no longer used wheels.

What happens after the version bump PR is merged? At the moment, the venv cache is still up-to-date and will be used for any runs. However, the wheels cache is reset. That means that the first PR which updates a requirement will run from a cold wheels cache, i.e. 3-4min for the venv creation instead of the usual 20-30s. As the wheels cache created for a PR branch cannot be used by other PRs, that happens for every PR until the first one is merged into dev. After that, since the venv needs to be created from scratch, the wheels cache is also created and all subsequent venv creations will be fast again.

Adding the HA version to the venv cache key just means we create the new wheels cache directly after the version bump. Thus removing the initial friction.

Hope that explains it.