`bicep restore` is caching a lot of redundant data during a local deploy extension development cycle
- Dominant language
- Bicep
- Stars
- 3.6k
- Forks
- 830
- Avg merge
- 1d 21m
- Merged PRs (30d)
- 79
Description
**Bicep version**
Bicep CLI version 0.36.90 (a8510cf601)
**Describe the bug**
When developing extensions, the easiest way test them is to publish the extension at a local path and have the bicepconfig.json point to the resulting file. Then, whenever a change is made to the extension code, the extension is published again and the main.bicep execute a restore to get the updated files.
However because the extension is cached to the path `~/.bicep/local/sha256_hashOfTheExtension`, whenever the extension is republished, a new entry will be created containing the entire extension. This is problematic because if you publish the extension a lot, the cache can easily reach in the tens of GBs where 99% of it is older versions of the extension that will never be used again.
**To Reproduce**
1. Clone this repository https://github.com/anthony-c-martin/bicep-ext-local
2. Follow the instructions inside the README.md to make the extension ready for local testing
3. Restore a main.bicep inside the samples directory
4. You'll notice that the extension was added to the cache directory
5. Publish the extension once more without any change to the C# code
6. Restore the same main.bicep after the publish
7. A second cache entry was created for the same extension
**Additional context**
It would be preferable if the caching was done in a way that reduce the amount of redundant data created.
For example, the sha256 hash for the folder name could be calculated based on the full path of the extension file.
This would reduce the amount of space used by the cache by reusing the same folder when an extension is published to the same place repeatedly.
Overall, there is no reason to keep hundreds of local path extensions on the cache when these are mainly used for development where only the latest published extension is relevant.
Contributor guide
Research direction
Start with the README.md instructions in the bicep-ext-local reproduction, then inspect how `bicep restore` populates `~/.bicep/local` when restoring `samples/main.bicep`. Done means repeatedly publishing the same local extension path and restoring it reuses cache data instead of creating redundant entries.
Written by the indexing model from the issue text.
Assessment
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100