Skip to content

Commit 6f89e0f

Browse files
committed
ci: speed up and de-duplicate the release & preview pipelines
Performance (PR preview, the iterative-feedback path): - Add a concurrency group with cancel-in-progress so pushing a PR again cancels the superseded (slow) preview run instead of letting it churn. - Build preview images amd64-only. arm64 under QEMU emulation was the slowest part of the job, and preview images are for quick testing; release/stable keep multi-arch. - Enable GitHub Actions Docker layer cache (type=gha) on all image builds so unchanged layers are reused across runs. De-duplication (GitHub Actions has no YAML anchors, so use composite actions): - New .github/actions/setup-docker-publish: the QEMU + Buildx + Docker Hub login trio, shared by release.yml, pr-preview.yml, and docker-stable.yml. These had drifted to three different pinned SHA sets; now there is one. (Docker Hub creds are passed as inputs since composite actions can't read secrets directly.) - New .github/actions/setup-hatch: the pinned virtualenv/hatchling/hatch install shared by release.yml and pr-preview.yml. No behavior change to what gets published; only how the pipelines are assembled and how fast/parallel they run. Stacked on #217 (lelia/fix-dependabot-checks) to avoid a pr-preview.yml conflict with that PR's Dependabot skip; rebase onto main once #217 lands. Signed-off-by: lelia <2418071+lelia@users.noreply.github.com>
1 parent 728bb15 commit 6f89e0f

5 files changed

Lines changed: 70 additions & 44 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: "Set up Docker publish"
2+
description: >-
3+
Set up QEMU + Docker Buildx and authenticate to Docker Hub for multi-arch
4+
image builds. Centralizes the QEMU/Buildx/login trio that the release,
5+
preview, and stable workflows previously each copied (and which had drifted
6+
to different pinned SHAs).
7+
8+
inputs:
9+
dockerhub-username:
10+
description: "Docker Hub username (pass from secrets)"
11+
required: true
12+
dockerhub-token:
13+
description: "Docker Hub token/password (pass from secrets)"
14+
required: true
15+
16+
runs:
17+
using: "composite"
18+
steps:
19+
- uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3
20+
- uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
21+
- uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
22+
with:
23+
username: ${{ inputs.dockerhub-username }}
24+
password: ${{ inputs.dockerhub-token }}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: "Set up Hatch build tooling"
2+
description: >-
3+
Install the pinned hatch / hatchling / virtualenv toolchain used to build
4+
and publish the package. Assumes Python is already set up by the caller.
5+
6+
runs:
7+
using: "composite"
8+
steps:
9+
- shell: bash
10+
run: |
11+
python -m pip install --upgrade pip
12+
pip install "virtualenv<20.36"
13+
pip install hatchling==1.27.0 hatch==1.14.0

.github/workflows/docker-stable.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,19 @@ jobs:
2828
fi
2929
echo "Version ${INPUT_VERSION} found on PyPI - proceeding with release"
3030
31-
- name: Set up QEMU
32-
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3
33-
34-
- name: Set up Docker Buildx
35-
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
36-
37-
- name: Login to Docker Hub with Organization Token
38-
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
31+
- name: Set up Docker publishing
32+
uses: ./.github/actions/setup-docker-publish
3933
with:
40-
username: ${{ secrets.DOCKERHUB_USERNAME }}
41-
password: ${{ secrets.DOCKERHUB_TOKEN }}
34+
dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }}
35+
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }}
4236

4337
- name: Build & Push Stable Docker
4438
uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5
4539
with:
4640
push: true
4741
platforms: linux/amd64,linux/arm64
42+
cache-from: type=gha
43+
cache-to: type=gha,mode=max
4844
tags: socketdev/cli:stable
4945
build-args: |
5046
CLI_VERSION=${{ inputs.version }}

.github/workflows/pr-preview.yml

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ on:
33
pull_request:
44
types: [opened, synchronize, ready_for_review]
55

6+
# Cancel an in-flight preview when the PR is pushed again -- previews are slow
7+
# (publish + multi-step Docker build), so superseded runs shouldn't keep going.
8+
concurrency:
9+
group: pr-preview-${{ github.event.pull_request.number }}
10+
cancel-in-progress: true
11+
612
jobs:
713
preview:
814
# Skip on:
@@ -26,12 +32,8 @@ jobs:
2632
with:
2733
python-version: '3.13'
2834

29-
# Install all dependencies from pyproject.toml
30-
- name: Install dependencies
31-
run: |
32-
python -m pip install --upgrade pip
33-
pip install "virtualenv<20.36"
34-
pip install hatchling==1.27.0 hatch==1.14.0
35+
- name: Install build tooling
36+
uses: ./.github/actions/setup-hatch
3537

3638
- name: Inject full dynamic version
3739
run: python .hooks/sync_version.py --dev
@@ -139,18 +141,12 @@ jobs:
139141
echo "success=false" >> $GITHUB_OUTPUT
140142
exit 1
141143
142-
- name: Set up QEMU
143-
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf
144-
145-
- name: Set up Docker Buildx
146-
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349
147-
148-
- name: Login to Docker Hub with Organization Token
144+
- name: Set up Docker publishing
149145
if: steps.verify_package.outputs.success == 'true'
150-
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
146+
uses: ./.github/actions/setup-docker-publish
151147
with:
152-
username: ${{ secrets.DOCKERHUB_USERNAME }}
153-
password: ${{ secrets.DOCKERHUB_TOKEN }}
148+
dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }}
149+
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }}
154150

155151
- name: Build & Push Docker Preview
156152
if: steps.verify_package.outputs.success == 'true'
@@ -159,7 +155,12 @@ jobs:
159155
VERSION: ${{ env.VERSION }}
160156
with:
161157
push: true
162-
platforms: linux/amd64,linux/arm64
158+
# Preview images are for quick testing -- build amd64 only. arm64 via
159+
# QEMU emulation is the slowest part of the job; release builds keep
160+
# multi-arch. GHA layer cache speeds up repeated preview builds.
161+
platforms: linux/amd64
162+
cache-from: type=gha
163+
cache-to: type=gha,mode=max
163164
tags: |
164165
socketdev/cli:pr-${{ github.event.pull_request.number }}
165166
build-args: |

.github/workflows/release.yml

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,9 @@ jobs:
1818
with:
1919
python-version: '3.13'
2020

21-
# Install all dependencies from pyproject.toml
22-
- name: Install dependencies
23-
run: |
24-
python -m pip install --upgrade pip
25-
pip install "virtualenv<20.36"
26-
pip install hatchling==1.27.0 hatch==1.14.0
27-
21+
- name: Install build tooling
22+
uses: ./.github/actions/setup-hatch
23+
2824
- name: Get Version
2925
id: version
3026
env:
@@ -72,17 +68,11 @@ jobs:
7268
if: steps.version_check.outputs.pypi_exists != 'true'
7369
uses: pypa/gh-action-pypi-publish@ab69e431e9c9f48a3310be0a56527c679f56e04d
7470

75-
- name: Set up QEMU
76-
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf
77-
78-
- name: Set up Docker Buildx
79-
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349
80-
81-
- name: Login to Docker Hub with Organization Token
82-
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
71+
- name: Set up Docker publishing
72+
uses: ./.github/actions/setup-docker-publish
8373
with:
84-
username: ${{ secrets.DOCKERHUB_USERNAME }}
85-
password: ${{ secrets.DOCKERHUB_TOKEN }}
74+
dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }}
75+
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }}
8676

8777
- name: Verify package is installable
8878
id: verify_package
@@ -112,6 +102,8 @@ jobs:
112102
with:
113103
push: true
114104
platforms: linux/amd64,linux/arm64
105+
cache-from: type=gha
106+
cache-to: type=gha,mode=max
115107
tags: |
116108
socketdev/cli:latest
117109
socketdev/cli:${{ env.VERSION }}

0 commit comments

Comments
 (0)