Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,28 @@ jobs:
with:
driver: docker-container

# PR builds use linux/amd64 (ubuntu-latest default), so cache scope is hardcoded
- name: Cache tblib and cargo builds
uses: actions/cache@v4
id: cache
with:
path: cache-mount
key: buildkit-cache-linux/amd64-${{ hashFiles('Dockerfile') }}
restore-keys: |
buildkit-cache-linux/amd64-

- name: Inject tblib cache into Docker
uses: reproducible-containers/buildkit-cache-dance@v3.2.0
with:
cache-dir: cache-mount
cache-map: |
{
"tblib-build": "/src/build",
"cargo-cache": "/src/target"
}
# Always skip extraction to prevent PRs from overwriting the main cache
skip-extraction: true

- name: Build and Upload
id: docker_build
uses: docker/build-push-action@v6
Expand All @@ -41,5 +63,5 @@ jobs:
tags: ${{ steps.meta.outputs.image }}:${{ steps.meta.outputs.version }}
labels: runnumber=${{ github.run_id }}
provenance: false
cache-from: type=gha
cache-to: type=gha,mode=max
cache-from: type=gha,scope=tblib-linux/amd64
cache-to: type=gha,mode=max,scope=tblib-linux/amd64
Comment on lines +66 to +67
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.
24 changes: 22 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,26 @@ jobs:
with:
driver: docker-container

- name: Cache tblib and cargo builds
uses: actions/cache@v4
id: cache
with:
path: cache-mount
key: buildkit-cache-${{ steps.meta.outputs.platform }}-${{ hashFiles('Dockerfile') }}
restore-keys: |
buildkit-cache-${{ steps.meta.outputs.platform }}-

- name: Inject tblib cache into Docker
uses: reproducible-containers/buildkit-cache-dance@v3.2.0
with:
cache-dir: cache-mount
cache-map: |
{
"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.
skip-extraction: ${{ steps.cache.outputs.cache-hit }}

- name: Build and Upload
id: docker_build
uses: docker/build-push-action@v6
Expand All @@ -75,5 +95,5 @@ jobs:
labels: runnumber=${{ github.run_id }}
provenance: false
platforms: ${{ steps.meta.outputs.platform }}
cache-from: type=gha
cache-to: type=gha,mode=max
cache-from: type=gha,scope=tblib-${{ steps.meta.outputs.platform }}
cache-to: type=gha,mode=max,scope=tblib-${{ steps.meta.outputs.platform }}
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ RUN apk add --no-cache libressl-dev zlib-static zlib-dev

RUN git clone --depth 1 --shallow-submodules --single-branch --recursive https://github.com/tdlib/telegram-bot-api.git src
RUN cd src && git submodule update --init --recursive
RUN --mount=type=cache,target=/src/build cd src/build && \
RUN --mount=type=cache,id=tblib-build,target=/src/build cd src/build && \
cmake -DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
-DOPENSSL_USE_STATIC_LIBS=ON \
Expand All @@ -23,7 +23,7 @@ RUN apk add --no-cache musl-dev libressl-dev

WORKDIR /src
COPY . .
RUN --mount=type=cache,target=/src/target \
RUN --mount=type=cache,id=cargo-cache,target=/src/target \
cargo build --release && \
cp target/release/tg-bot-full-api /tg-bot-full-api

Expand Down