Skip to content

Commit 0a3af6e

Browse files
yuluo-yxrootfs
andauthored
infra: update Dockerfile.extproc (#169)
* infra: update Dockerfile.extproc Signed-off-by: yuluo-yx <[email protected]> * feat: add precommit container, make it easier to run precommit Signed-off-by: yuluo-yx <[email protected]> --------- Signed-off-by: yuluo-yx <[email protected]> Co-authored-by: Huamin Chen <[email protected]>
1 parent a09c988 commit 0a3af6e

File tree

6 files changed

+99
-23
lines changed

6 files changed

+99
-23
lines changed

.github/workflows/docker-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ jobs:
4848
push: ${{ github.event_name != 'pull_request' }} # Only push on merge to main, not on PRs
4949
tags: |
5050
${{ inputs.is_nightly == true && format('ghcr.io/{0}/semantic-router/extproc:nightly-{1}', github.repository_owner, steps.date.outputs.date_tag) || format('ghcr.io/{0}/semantic-router/extproc:{1}', github.repository_owner, github.sha) }}
51-
${{ inputs.is_nightly != true && format('ghcr.io/{0}/semantic-router/extproc:latest', github.repository_owner) || '' }}
51+
${{ inputs.is_nightly != true && format('ghcr.io/{0}/semantic-router/extproc:latest', github.repository_owner) || '' }}

.github/workflows/pre-commit.yml

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
sudo apt-get install -y \
4646
make \
4747
build-essential \
48-
pkg-config
48+
pkg-config
4949
npm install -g markdownlint-cli
5050
pip install --user yamllint codespell
5151
@@ -81,31 +81,13 @@ jobs:
8181
key: ${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
8282

8383
- name: Install pre-commit
84-
run: pip install pre-commit
84+
run: make precommit-install
8585

8686
- name: Run Code Spell Check
8787
run: make codespell
8888

89-
- name: Run pre-commit on Go, Rust, JavaScript, Markdown, Yaml and Python files
90-
run: |
91-
# Find all Go, Rust, JavaScripts, Markdown and Python files (excluding vendored/generated code)
92-
FILES=$(find . -type f \( -name "*.go" -o -name "*.rs" -o -name "*.py" -o -name "*.js" -o -name "*.md" -o -name "*.yaml" -o -name "*.yml" \) \
93-
! -path "./target/*" \
94-
! -path "./candle-binding/target/*" \
95-
! -path "./.git/*" \
96-
! -path "./node_modules/*" \
97-
! -path "./vendor/*" \
98-
! -path "./__pycache__/*" \
99-
! -path "./site/*" \
100-
! -name "*.pb.go" \
101-
| tr '\n' ' ')
102-
103-
if [ -n "$FILES" ]; then
104-
echo "Running pre-commit on files: $FILES"
105-
pre-commit run --files $FILES
106-
else
107-
echo "No Go, Rust, JavaScript, Markdown, Yaml, or Python files found to check"
108-
fi
89+
- name: Run pre-commit check
90+
run: make precommit-check
10991

11092
- name: Show pre-commit results
11193
if: failure()
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Create and publish Precommit Image
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
paths:
8+
- 'Dockerfile.precommit'
9+
10+
jobs:
11+
build_and_push:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
packages: write
16+
17+
steps:
18+
- name: Check out the repo
19+
uses: actions/checkout@v4
20+
21+
- name: Log in to GitHub Container Registry
22+
uses: docker/login-action@v3
23+
with:
24+
registry: ghcr.io
25+
username: ${{ github.actor }}
26+
password: ${{ secrets.GITHUB_TOKEN }}
27+
28+
- name: Generate date tag for nightly builds
29+
id: date
30+
if: inputs.is_nightly == true
31+
run: echo "date_tag=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
32+
33+
- name: Build and push Docker image
34+
uses: docker/build-push-action@v5
35+
with:
36+
context: .
37+
file: ./Dockerfile.precommit
38+
push: ${{ github.event_name != 'pull_request' }} # Only push on merge to main, not on PRs
39+
tags: |
40+
${{ inputs.is_nightly != true && format('ghcr.io/{0}/semantic-router/precommit:latest', github.repository_owner) || '' }}

Dockerfile.precommit

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
FROM golang:1.24
2+
3+
# Install Base env
4+
RUN apt-get update && apt-get install -y \
5+
make \
6+
build-essential \
7+
pkg-config \
8+
python3 \
9+
python3-pip
10+
11+
# Install Node.js and npm
12+
RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - && \
13+
apt-get install -y nodejs
14+
15+
# Install Rust
16+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \
17+
. $HOME/.cargo/env
18+
19+
# Markdown
20+
RUN npm install -g markdownlint-cli
21+
22+
# Install pre-commit and tools
23+
RUN pip install --break-system-packages pre-commit
24+
25+
# Yamllint
26+
RUN pip install --break-system-packages yamllint
27+
28+
# CodeSpell
29+
RUN pip install --break-system-packages codespell

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ _run:
1313
-f tools/make/linter.mk \
1414
-f tools/make/milvus.mk \
1515
-f tools/make/models.mk \
16+
-f tools/make/pre-commit.mk \
1617
$(MAKECMDGOALS)
1718

1819
.PHONY: _run

tools/make/pre-commit.mk

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
precommit-install:
2+
pip install pre-commit
3+
4+
precommit-check:
5+
@FILES=$$(find . -type f \( -name "*.go" -o -name "*.rs" -o -name "*.py" -o -name "*.js" -o -name "*.md" -o -name "*.yaml" -o -name "*.yml" \) \
6+
! -path "./target/*" \
7+
! -path "./candle-binding/target/*" \
8+
! -path "./.git/*" \
9+
! -path "./node_modules/*" \
10+
! -path "./vendor/*" \
11+
! -path "./__pycache__/*" \
12+
! -path "./site/*" \
13+
! -name "*.pb.go" \
14+
| tr '\n' ' '); \
15+
if [ -n "$$FILES" ]; then \
16+
echo "Running pre-commit on files: $$FILES"; \
17+
pre-commit run --files $$FILES; \
18+
else \
19+
echo "No Go, Rust, JavaScript, Markdown, Yaml, or Python files found to check"; \
20+
fi
21+
22+
precommit-local:
23+
docker pull ghcr.io/vllm/semantic-router/precommit:latest
24+
docker run --rm -v $$(pwd):/data ghcr.io/vllm-project/semantic-router/precommit:latest pre-commit run --all-files

0 commit comments

Comments
 (0)