Add cache for tblib compilation in release workflow#86
Add cache for tblib compilation in release workflow#86
Conversation
Co-authored-by: hugefiver <18693500+hugefiver@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds persistent caching for Docker BuildKit cache mounts to speed up compilation of the telegram-bot-api library (tblib) and Rust cargo builds in GitHub Actions. Previously, BuildKit cache mounts were not persisted across workflow runs. The change introduces the buildkit-cache-dance action to save and restore mount cache contents to GitHub Actions cache.
Key changes:
- Added cache mount IDs (
tblib-build,cargo-cache) in Dockerfile for BuildKit cache identification - Integrated
reproducible-containers/buildkit-cache-dance@v3.2.0in both release and pull-request workflows to persist cache mounts - Updated BuildKit cache scopes to be platform-specific in release workflow (
tblib-linux/amd64,tblib-linux/arm64)
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| Dockerfile | Added cache mount IDs to enable cache persistence for tblib build and cargo compilation stages |
| .github/workflows/release.yml | Integrated buildkit-cache-dance action to persist cache mounts with platform-specific BuildKit cache scopes |
| .github/workflows/pull-request.yml | Added buildkit-cache-dance with skip-extraction: true to read cache without writing, using hardcoded linux/amd64 scope |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| { | ||
| "tblib-build": "/src/build", | ||
| "cargo-cache": "/src/target" | ||
| } |
There was a problem hiding this comment.
The buildkit-cache-dance action may not automatically scope its GitHub Actions cache by platform. Since the release workflow can build for multiple platforms (linux/amd64 and linux/arm64 via workflow_dispatch), but the action configuration doesn't include platform information, there's a risk that:
- Builds for different platforms will share the same cache key
- The cache for one platform could overwrite the cache for another
- This could lead to build failures or incorrect binaries when switching platforms
Verify whether the action supports a platform-specific cache key parameter (such as cache-key, cache-source, or similar). If supported, consider adding platform scoping:
with:
cache-map: |
{
"tblib-build": "/src/build",
"cargo-cache": "/src/target"
}
cache-key: ${{ steps.meta.outputs.platform }}Alternatively, if the action doesn't support this, you may need to include the platform in the cache mount IDs themselves or verify that the action's default behavior already handles this correctly.
| } | |
| } | |
| cache-key: ${{ steps.meta.outputs.platform }} |
| cache-from: type=gha,scope=tblib-linux/amd64 | ||
| cache-to: type=gha,mode=max,scope=tblib-linux/amd64 |
There was a problem hiding this comment.
The cache scope is hardcoded to tblib-linux/amd64 but the pull-request workflow doesn't specify a platform for the build. This means:
- If no platform is specified in the build action, it will default to the runner's platform (linux/amd64 on ubuntu-latest)
- However, this is inconsistent with the release workflow which uses dynamic platform scopes based on
steps.meta.outputs.platform
While this works for the current setup, it creates a maintenance burden. If someone later decides to test multi-platform builds in PRs or if the default runner platform changes, the hardcoded scope will cause cache misses or incorrect cache usage. Consider using a dynamic approach similar to the release workflow, or add a comment explaining why this is intentionally hardcoded to linux/amd64.
|
@copilot apply changes based on the comments in this thread |
Co-authored-by: hugefiver <18693500+hugefiver@users.noreply.github.com>
Applied the review feedback in commit 6e858e7:
|
reproducible-containers/buildkit-cache-danceaction to release.yml for BuildKit cache persistenceactions/cache@v4step with platform-specific cache keys in release.ymlcache-dirparameter tobuildkit-cache-danceactionskip-extractionbased on cache hit status in release.ymlOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.