Skip to content

Add cache for tblib compilation in release workflow#86

Open
Copilot wants to merge 3 commits intomasterfrom
copilot/add-release-action-cache
Open

Add cache for tblib compilation in release workflow#86
Copilot wants to merge 3 commits intomasterfrom
copilot/add-release-action-cache

Conversation

Copy link
Copy Markdown

Copilot AI commented Dec 31, 2025

  • Add cache ID parameters to Dockerfile mount caches for proper identification
  • Add reproducible-containers/buildkit-cache-dance action to release.yml for BuildKit cache persistence
  • Configure scope-based GitHub Actions cache to persist caches across CI runs
  • Update pull-request.yml to use the same caching approach
  • Add explicit actions/cache@v4 step with platform-specific cache keys in release.yml
  • Add cache-dir parameter to buildkit-cache-dance action
  • Add skip-extraction based on cache hit status in release.yml
  • Add explanatory comments in pull-request.yml about hardcoded linux/amd64 platform scope
Original prompt

增加一个release action编译tblib阶段的缓存加快编译速度


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: hugefiver <18693500+hugefiver@users.noreply.github.com>
Copilot AI changed the title [WIP] Add release action to compile tblib cache for faster builds Add cache for tblib compilation in release workflow Dec 31, 2025
Copilot AI requested a review from hugefiver December 31, 2025 06:18
@hugefiver hugefiver marked this pull request as ready for review January 4, 2026 11:59
Copilot AI review requested due to automatic review settings January 4, 2026 11:59
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.0 in 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"
}
Copy link

Copilot AI Jan 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. Builds for different platforms will share the same cache key
  2. The cache for one platform could overwrite the cache for another
  3. 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.

Suggested change
}
}
cache-key: ${{ steps.meta.outputs.platform }}

Copilot uses AI. Check for mistakes.
Comment on lines +54 to +55
cache-from: type=gha,scope=tblib-linux/amd64
cache-to: type=gha,mode=max,scope=tblib-linux/amd64
Copy link

Copilot AI Jan 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cache scope is hardcoded to tblib-linux/amd64 but the pull-request workflow doesn't specify a platform for the build. This means:

  1. If no platform is specified in the build action, it will default to the runner's platform (linux/amd64 on ubuntu-latest)
  2. 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 uses AI. Check for mistakes.
@hugefiver
Copy link
Copy Markdown
Collaborator

@copilot apply changes based on the comments in this thread

Co-authored-by: hugefiver <18693500+hugefiver@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Jan 6, 2026

@copilot apply changes based on the comments in this thread

Applied the review feedback in commit 6e858e7:

  1. Added explicit actions/cache@v4 step with platform-specific cache keys (buildkit-cache-${{ steps.meta.outputs.platform }}-...) in release.yml
  2. Added cache-dir: cache-mount parameter to buildkit-cache-dance action in both workflows
  3. Added skip-extraction: ${{ steps.cache.outputs.cache-hit }} in release.yml to skip extraction when cache is already hit
  4. Added explanatory comment in pull-request.yml about why the platform scope is hardcoded to linux/amd64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants