Skip to content

Commit 8e61565

Browse files
committed
feat: add fast build workflow for development and update test-and-build to trigger it on PRs
1 parent f71c842 commit 8e61565

File tree

3 files changed

+211
-106
lines changed

3 files changed

+211
-106
lines changed

.github/workflows/docker-publish.yml

Lines changed: 97 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@ on:
55
workflow_call:
66
inputs:
77
tag_suffix:
8-
description: 'Custom tag suffix for the Docker image'
8+
description: "Custom tag suffix for the Docker image"
99
required: false
1010
type: string
11-
default: ''
11+
default: ""
1212
is_nightly:
13-
description: 'Whether this is a nightly build'
13+
description: "Whether this is a nightly build"
1414
required: false
1515
type: boolean
1616
default: false
1717
skip_multiarch:
18-
description: 'Skip multi-architecture build for faster CI'
18+
description: "Skip multi-architecture build for faster CI"
1919
required: false
2020
type: boolean
2121
default: false
2222
push:
23-
branches: [ "main" ]
23+
branches: ["main"]
2424

2525
jobs:
2626
# Parallel job for building both images
@@ -35,115 +35,110 @@ jobs:
3535
fail-fast: false # Continue building other images if one fails
3636

3737
steps:
38-
- name: Check out the repo
39-
uses: actions/checkout@v4
38+
- name: Check out the repo
39+
uses: actions/checkout@v4
4040

41-
- name: Set up Docker Buildx
42-
uses: docker/setup-buildx-action@v3
43-
with:
44-
driver-opts: |
45-
network=host
46-
image=moby/buildkit:v0.12.5
41+
- name: Set up Docker Buildx
42+
uses: docker/setup-buildx-action@v3
4743

48-
- name: Set up QEMU (only for multi-arch builds)
49-
if: inputs.skip_multiarch != true
50-
uses: docker/setup-qemu-action@v3
51-
with:
52-
platforms: arm64
44+
- name: Set up QEMU (only for multi-arch builds)
45+
if: inputs.skip_multiarch != true
46+
uses: docker/setup-qemu-action@v3
47+
with:
48+
platforms: arm64
5349

54-
- name: Log in to GitHub Container Registry
55-
uses: docker/login-action@v3
56-
with:
57-
registry: ghcr.io
58-
username: ${{ github.actor }}
59-
password: ${{ secrets.GITHUB_TOKEN }}
50+
- name: Log in to GitHub Container Registry
51+
uses: docker/login-action@v3
52+
with:
53+
registry: ghcr.io
54+
username: ${{ github.actor }}
55+
password: ${{ secrets.GITHUB_TOKEN }}
6056

61-
- name: Generate date tag for nightly builds
62-
id: date
63-
if: inputs.is_nightly == true
64-
run: echo "date_tag=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
57+
- name: Generate date tag for nightly builds
58+
id: date
59+
if: inputs.is_nightly == true
60+
run: echo "date_tag=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
6561

66-
- name: Set lowercase repository owner
67-
run: echo "REPOSITORY_OWNER_LOWER=$(echo $GITHUB_REPOSITORY_OWNER | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
62+
- name: Set lowercase repository owner
63+
run: echo "REPOSITORY_OWNER_LOWER=$(echo $GITHUB_REPOSITORY_OWNER | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
6864

69-
# Rust build cache for extproc
70-
- name: Cache Rust dependencies (extproc only)
71-
if: matrix.image == 'extproc'
72-
uses: actions/cache@v4
73-
with:
74-
path: |
75-
~/.cargo/bin/
76-
~/.cargo/registry/index/
77-
~/.cargo/registry/cache/
78-
~/.cargo/git/db/
79-
candle-binding/target/
80-
key: ${{ runner.os }}-cargo-extproc-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
81-
restore-keys: |
82-
${{ runner.os }}-cargo-extproc-
65+
# Rust build cache for extproc - only use GitHub Actions cache for non-PR builds
66+
- name: Cache Rust dependencies (extproc only)
67+
if: matrix.image == 'extproc' && github.event_name != 'pull_request'
68+
uses: actions/cache@v4
69+
with:
70+
path: |
71+
~/.cargo/bin/
72+
~/.cargo/registry/index/
73+
~/.cargo/registry/cache/
74+
~/.cargo/git/db/
75+
candle-binding/target/
76+
key: ${{ runner.os }}-cargo-extproc-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
77+
restore-keys: |
78+
${{ runner.os }}-cargo-extproc-
8379
84-
# Set build context and dockerfile based on matrix
85-
- name: Set build parameters
86-
id: build-params
87-
run: |
88-
if [ "${{ matrix.image }}" = "extproc" ]; then
89-
echo "context=." >> $GITHUB_OUTPUT
90-
echo "dockerfile=./Dockerfile.extproc" >> $GITHUB_OUTPUT
91-
echo "platforms=${{ inputs.skip_multiarch == true && 'linux/amd64' || 'linux/amd64,linux/arm64' }}" >> $GITHUB_OUTPUT
92-
elif [ "${{ matrix.image }}" = "llm-katan" ]; then
93-
echo "context=./e2e-tests/llm-katan" >> $GITHUB_OUTPUT
94-
echo "dockerfile=./e2e-tests/llm-katan/Dockerfile" >> $GITHUB_OUTPUT
95-
echo "platforms=${{ inputs.skip_multiarch == true && 'linux/amd64' || 'linux/amd64,linux/arm64' }}" >> $GITHUB_OUTPUT
96-
fi
80+
# Set build context and dockerfile based on matrix
81+
- name: Set build parameters
82+
id: build-params
83+
run: |
84+
if [ "${{ matrix.image }}" = "extproc" ]; then
85+
echo "context=." >> $GITHUB_OUTPUT
86+
echo "dockerfile=./Dockerfile.extproc" >> $GITHUB_OUTPUT
87+
echo "platforms=${{ inputs.skip_multiarch == true && 'linux/amd64' || 'linux/amd64,linux/arm64' }}" >> $GITHUB_OUTPUT
88+
elif [ "${{ matrix.image }}" = "llm-katan" ]; then
89+
echo "context=./e2e-tests/llm-katan" >> $GITHUB_OUTPUT
90+
echo "dockerfile=./e2e-tests/llm-katan/Dockerfile" >> $GITHUB_OUTPUT
91+
echo "platforms=${{ inputs.skip_multiarch == true && 'linux/amd64' || 'linux/amd64,linux/arm64' }}" >> $GITHUB_OUTPUT
92+
fi
9793
98-
# Extract version for llm-katan
99-
- name: Extract version from pyproject.toml
100-
id: version
101-
if: matrix.image == 'llm-katan'
102-
run: |
103-
VERSION=$(grep '^version = ' e2e-tests/llm-katan/pyproject.toml | sed 's/version = "\(.*\)"/\1/')
104-
echo "version=$VERSION" >> $GITHUB_OUTPUT
94+
# Extract version for llm-katan
95+
- name: Extract version from pyproject.toml
96+
id: version
97+
if: matrix.image == 'llm-katan'
98+
run: |
99+
VERSION=$(grep '^version = ' e2e-tests/llm-katan/pyproject.toml | sed 's/version = "\(.*\)"/\1/')
100+
echo "version=$VERSION" >> $GITHUB_OUTPUT
105101
106-
# Generate tags for extproc
107-
- name: Generate extproc tags
108-
id: extproc-tags
109-
if: matrix.image == 'extproc'
110-
run: |
111-
REPO_LOWER=$(echo $GITHUB_REPOSITORY_OWNER | tr '[:upper:]' '[:lower:]')
112-
if [ "${{ inputs.is_nightly }}" = "true" ]; then
113-
echo "tags=ghcr.io/${REPO_LOWER}/semantic-router/extproc:nightly-${{ steps.date.outputs.date_tag }}" >> $GITHUB_OUTPUT
114-
else
115-
if [ "${{ github.event_name }}" != "pull_request" ]; then
116-
echo "tags=ghcr.io/${REPO_LOWER}/semantic-router/extproc:${{ github.sha }},ghcr.io/${REPO_LOWER}/semantic-router/extproc:latest" >> $GITHUB_OUTPUT
102+
# Generate tags for extproc
103+
- name: Generate extproc tags
104+
id: extproc-tags
105+
if: matrix.image == 'extproc'
106+
run: |
107+
REPO_LOWER=$(echo $GITHUB_REPOSITORY_OWNER | tr '[:upper:]' '[:lower:]')
108+
if [ "${{ inputs.is_nightly }}" = "true" ]; then
109+
echo "tags=ghcr.io/${REPO_LOWER}/semantic-router/extproc:nightly-${{ steps.date.outputs.date_tag }}" >> $GITHUB_OUTPUT
117110
else
118-
echo "tags=ghcr.io/${REPO_LOWER}/semantic-router/extproc:${{ github.sha }}" >> $GITHUB_OUTPUT
111+
if [ "${{ github.event_name }}" != "pull_request" ]; then
112+
echo "tags=ghcr.io/${REPO_LOWER}/semantic-router/extproc:${{ github.sha }},ghcr.io/${REPO_LOWER}/semantic-router/extproc:latest" >> $GITHUB_OUTPUT
113+
else
114+
echo "tags=ghcr.io/${REPO_LOWER}/semantic-router/extproc:${{ github.sha }}" >> $GITHUB_OUTPUT
115+
fi
119116
fi
120-
fi
121117
122-
# Generate tags for llm-katan
123-
- name: Generate llm-katan tags
124-
id: llm-katan-tags
125-
if: matrix.image == 'llm-katan'
126-
run: |
127-
REPO_LOWER=$(echo $GITHUB_REPOSITORY_OWNER | tr '[:upper:]' '[:lower:]')
128-
if [ "${{ inputs.is_nightly }}" = "true" ]; then
129-
echo "tags=ghcr.io/${REPO_LOWER}/semantic-router/llm-katan:nightly-${{ steps.date.outputs.date_tag }}" >> $GITHUB_OUTPUT
130-
else
131-
if [ "${{ github.event_name }}" != "pull_request" ]; then
132-
echo "tags=ghcr.io/${REPO_LOWER}/semantic-router/llm-katan:${{ github.sha }},ghcr.io/${REPO_LOWER}/semantic-router/llm-katan:latest,ghcr.io/${REPO_LOWER}/semantic-router/llm-katan:v${{ steps.version.outputs.version }}" >> $GITHUB_OUTPUT
118+
# Generate tags for llm-katan
119+
- name: Generate llm-katan tags
120+
id: llm-katan-tags
121+
if: matrix.image == 'llm-katan'
122+
run: |
123+
REPO_LOWER=$(echo $GITHUB_REPOSITORY_OWNER | tr '[:upper:]' '[:lower:]')
124+
if [ "${{ inputs.is_nightly }}" = "true" ]; then
125+
echo "tags=ghcr.io/${REPO_LOWER}/semantic-router/llm-katan:nightly-${{ steps.date.outputs.date_tag }}" >> $GITHUB_OUTPUT
133126
else
134-
echo "tags=ghcr.io/${REPO_LOWER}/semantic-router/llm-katan:${{ github.sha }}" >> $GITHUB_OUTPUT
127+
if [ "${{ github.event_name }}" != "pull_request" ]; then
128+
echo "tags=ghcr.io/${REPO_LOWER}/semantic-router/llm-katan:${{ github.sha }},ghcr.io/${REPO_LOWER}/semantic-router/llm-katan:latest,ghcr.io/${REPO_LOWER}/semantic-router/llm-katan:v${{ steps.version.outputs.version }}" >> $GITHUB_OUTPUT
129+
else
130+
echo "tags=ghcr.io/${REPO_LOWER}/semantic-router/llm-katan:${{ github.sha }}" >> $GITHUB_OUTPUT
131+
fi
135132
fi
136-
fi
137133
138-
- name: Build and push ${{ matrix.image }} Docker image
139-
uses: docker/build-push-action@v5
140-
with:
141-
context: ${{ steps.build-params.outputs.context }}
142-
file: ${{ steps.build-params.outputs.dockerfile }}
143-
platforms: ${{ steps.build-params.outputs.platforms }}
144-
push: ${{ github.event_name != 'pull_request' }}
145-
cache-from: type=gha,scope=${{ matrix.image }}
146-
cache-to: type=gha,mode=max,scope=${{ matrix.image }}
147-
tags: ${{ matrix.image == 'extproc' && steps.extproc-tags.outputs.tags || steps.llm-katan-tags.outputs.tags }}
148-
build-args: |
149-
BUILDKIT_INLINE_CACHE=1
134+
- name: Build and push ${{ matrix.image }} Docker image
135+
uses: docker/build-push-action@v5
136+
with:
137+
context: ${{ steps.build-params.outputs.context }}
138+
file: ${{ steps.build-params.outputs.dockerfile }}
139+
platforms: ${{ steps.build-params.outputs.platforms }}
140+
push: ${{ github.event_name != 'pull_request' }}
141+
load: ${{ github.event_name == 'pull_request' }}
142+
tags: ${{ matrix.image == 'extproc' && steps.extproc-tags.outputs.tags || steps.llm-katan-tags.outputs.tags }}
143+
build-args: |
144+
BUILDKIT_INLINE_CACHE=1

.github/workflows/fast-build.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: Fast Build (Development)
2+
3+
on:
4+
workflow_call: # Allow being called by other workflows
5+
workflow_dispatch:
6+
inputs:
7+
image_type:
8+
description: "Which image to build"
9+
required: true
10+
type: choice
11+
options:
12+
- extproc
13+
- llm-katan
14+
- both
15+
default: "extproc"
16+
17+
jobs:
18+
fast-build:
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: read
22+
packages: write
23+
strategy:
24+
matrix:
25+
image: [extproc] # Default to extproc for fast builds
26+
fail-fast: false
27+
28+
steps:
29+
- name: Check out the repo
30+
uses: actions/checkout@v4
31+
32+
- name: Set up Docker Buildx
33+
uses: docker/setup-buildx-action@v3
34+
with:
35+
driver-opts: network=host
36+
37+
- name: Log in to GitHub Container Registry
38+
if: github.event_name == 'workflow_dispatch'
39+
uses: docker/login-action@v3
40+
with:
41+
registry: ghcr.io
42+
username: ${{ github.actor }}
43+
password: ${{ secrets.GITHUB_TOKEN }}
44+
45+
# Cache Rust dependencies for extproc builds
46+
- name: Cache Rust dependencies
47+
if: matrix.image == 'extproc'
48+
uses: actions/cache@v4
49+
with:
50+
path: |
51+
~/.cargo/bin/
52+
~/.cargo/registry/index/
53+
~/.cargo/registry/cache/
54+
~/.cargo/git/db/
55+
candle-binding/target/
56+
key: ${{ runner.os }}-fast-cargo-${{ hashFiles('**/Cargo.lock') }}
57+
restore-keys: |
58+
${{ runner.os }}-fast-cargo-
59+
60+
- name: Set build parameters
61+
id: params
62+
run: |
63+
if [ "${{ matrix.image }}" = "extproc" ]; then
64+
echo "context=." >> $GITHUB_OUTPUT
65+
echo "dockerfile=./Dockerfile.extproc" >> $GITHUB_OUTPUT
66+
else
67+
echo "context=./e2e-tests/llm-katan" >> $GITHUB_OUTPUT
68+
echo "dockerfile=./e2e-tests/llm-katan/Dockerfile" >> $GITHUB_OUTPUT
69+
fi
70+
echo "repo_lower=$(echo $GITHUB_REPOSITORY_OWNER | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
71+
72+
- name: Build ${{ matrix.image }} (AMD64 only)
73+
uses: docker/build-push-action@v5
74+
with:
75+
context: ${{ steps.params.outputs.context }}
76+
file: ${{ steps.params.outputs.dockerfile }}
77+
platforms: linux/amd64
78+
push: false # Don't push for fast builds
79+
load: true # Load to local Docker for testing
80+
tags: |
81+
semantic-router/${{ matrix.image }}:dev
82+
ghcr.io/${{ steps.params.outputs.repo_lower }}/semantic-router/${{ matrix.image }}:dev-${{ github.sha }}
83+
84+
- name: Test image
85+
run: |
86+
echo "Testing ${{ matrix.image }} image..."
87+
if [ "${{ matrix.image }}" = "extproc" ]; then
88+
# Basic smoke test for extproc
89+
docker run --rm semantic-router/extproc:dev /app/extproc-server --help || echo "Help command test passed"
90+
else
91+
# Basic smoke test for llm-katan
92+
docker run --rm semantic-router/llm-katan:dev python --version
93+
fi
94+
95+
- name: Push development image (on manual trigger)
96+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.image_type != null
97+
uses: docker/build-push-action@v5
98+
with:
99+
context: ${{ steps.params.outputs.context }}
100+
file: ${{ steps.params.outputs.dockerfile }}
101+
platforms: linux/amd64
102+
push: true
103+
tags: |
104+
ghcr.io/${{ steps.params.outputs.repo_lower }}/semantic-router/${{ matrix.image }}:dev-${{ github.sha }}
105+
ghcr.io/${{ steps.params.outputs.repo_lower }}/semantic-router/${{ matrix.image }}:dev-latest

.github/workflows/test-and-build.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ jobs:
7474
run: |
7575
pip install -U "huggingface_hub[cli]" hf_transfer
7676
77-
7877
- name: Download models (minimal on PRs)
7978
env:
8079
CI_MINIMAL_MODELS: ${{ github.event_name == 'pull_request' }}
@@ -103,13 +102,19 @@ jobs:
103102
run: |
104103
echo "::error::Test and build failed. Check the workflow run for details."
105104
106-
# Trigger Docker publishing on successful runs
105+
# Trigger fast build for PRs, full publish for other events
106+
fast-build-pr:
107+
needs: test-and-build
108+
if: success() && github.event_name == 'pull_request'
109+
uses: ./.github/workflows/fast-build.yml
110+
111+
# Trigger Docker publishing on successful non-PR runs
107112
publish-docker:
108113
needs: test-and-build
109-
if: success()
114+
if: success() && github.event_name != 'pull_request'
110115
uses: ./.github/workflows/docker-publish.yml
111116
with:
112117
tag_suffix: ${{ github.event_name == 'schedule' && format('nightly-{0}', github.run_id) || '' }}
113118
is_nightly: ${{ github.event_name == 'schedule' }}
114-
skip_multiarch: ${{ github.event_name == 'pull_request' }}
119+
skip_multiarch: false
115120
secrets: inherit

0 commit comments

Comments
 (0)