Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 4 additions & 2 deletions Dockerfile.precommit
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ RUN apt-get update && apt-get install -y \
build-essential \
pkg-config \
python3 \
libssl-dev \
ca-certificates \
python3-pip

# Install Node.js and npm
RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - && \
apt-get install -y nodejs

# Install Rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \
. $HOME/.cargo/env
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"

# Markdown
RUN npm install -g markdownlint-cli
Expand Down
24 changes: 22 additions & 2 deletions tools/make/pre-commit.mk
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
PRECOMMIT_CONTAINER := ghcr.io/vllm-project/semantic-router/precommit:latest

precommit-install:
pip install pre-commit

Expand All @@ -19,6 +21,24 @@ precommit-check:
echo "No Go, Rust, JavaScript, Markdown, Yaml, or Python files found to check"; \
fi

# Run pre-commit hooks in a Docker container,
# and you can exec container to run bash for debug.
# export PRECOMMIT_CONTAINER=ghcr.io/vllm-project/semantic-router/precommit:latest
# docker run --rm -it \
# -v $(pwd):/app \
# -w /app \
# --name precommit-container ${PRECOMMIT_CONTAINER} \
# bash
# and then, run `pre-commit install && pre-commit run --all-files` command
precommit-local:
docker pull ghcr.io/vllm/semantic-router/precommit:latest
docker run --rm -v $$(pwd):/data ghcr.io/vllm-project/semantic-router/precommit:latest pre-commit run --all-files
@if ! docker image inspect ${PRECOMMIT_CONTAINER} > /dev/null 2>&1; then \
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: can you make a macro for docker command and detect if either docker or podman is installed and choose the one that is present on the system?

Copy link
Collaborator

Choose a reason for hiding this comment

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

you can do it in a followup PR.

echo "Image not found locally. Pulling..."; \
docker pull ${PRECOMMIT_CONTAINER}; \
else \
echo "Image found locally. Skipping pull."; \
fi
docker run --rm \
-v $(shell pwd):/app \
-w /app \
--name precommit-container ${PRECOMMIT_CONTAINER} \
bash -c "source ~/.cargo/env && pre-commit install && pre-commit run --all-files"
Loading