Skip to content
Merged
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
36 changes: 36 additions & 0 deletions .github/actions/run-precommit-for-service/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
name: Run Pre-commit for Service
description: Set up a Dev-Container for a specific service and run pre-commit checks within that environment.

inputs:
devcontainer-cfg-path:
description: Directory containing .devcontainer configuration for the service.
required: true

service-workdir:
description: Working directory inside the Dev-Container where the service code resides.
required: true

runs:
using: composite

steps:
- name: Verify Docker engine
run: docker version
shell: bash

- name: Ensure SSH agent mount path exists
run: |
if [ ! -e "${SSH_AUTH_SOCK}" ]; then
touch "${SSH_AUTH_SOCK}"
fi
shell: bash

- name: Run pre-commit in devcontainer
uses: devcontainers/ci@v0.3
with:
configFile: ${{ inputs.devcontainer-cfg-path }}/devcontainer.json
runCmd: |
cd ${{ inputs.service-workdir }} && \
just setup-environment && \
just run-precommit
141 changes: 88 additions & 53 deletions .github/workflows/service-checks.yml
Original file line number Diff line number Diff line change
@@ -1,78 +1,113 @@
name: Service checks
name: Service Checks
description: Run pre-commit static analysis on services having their own Dev-Container setup.

on:
pull_request:
paths:
- "services/**"
- ".pre-commit-config.yaml"
- "pyproject.toml"
- ".github/workflows/service-checks.yml"
push:
- .github/workflows/service-checks.yml
- .pre-commit-config.yaml
- pyproject.toml
- services/context-retriever/**
- services/web-app/**
- services/llm-proxy/**
- .devcontainer/**
branches: [main, develop]
paths:
- "services/**"
- ".pre-commit-config.yaml"
- "pyproject.toml"
- ".github/workflows/service-checks.yml"

permissions:
contents: read


concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
# Dummy socket to simulate mounting SSH agent into Dev-Container
SSH_AUTH_SOCK: /tmp/ssh-agent

jobs:
changes:
runs-on: ubuntu-latest
name: Detect changed services
runs-on: ubuntu-24.04
outputs:
llm_proxy: ${{ steps.filter.outputs.llm_proxy }}
web_app: ${{ steps.filter.outputs.web_app }}
context-retriever: ${{ steps.filter.outputs.context-retriever }}
web-app: ${{ steps.filter.outputs.web-app }}
llm-proxy: ${{ steps.filter.outputs.llm-proxy }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Determine impacted services
id: filter
uses: dorny/paths-filter@v3
with:
filters: |
llm_proxy:
- 'services/llm-proxy/**'
- '.pre-commit-config.yaml'
- 'pyproject.toml'
web_app:
- 'services/web-app/**'
- '.pre-commit-config.yaml'
- 'pyproject.toml'
context-retriever:
- services/context-retriever/**
- .pre-commit-config.yaml
- pyproject.toml
- .github/workflows/service-checks.yml
- .devcontainer/context-retriever/**
- .devcontainer/scripts/**
web-app:
- services/web-app/**
- .pre-commit-config.yaml
- pyproject.toml
- .github/workflows/service-checks.yml
- .devcontainer/web-app/**
- .devcontainer/scripts/**
llm-proxy:
- services/llm-proxy/**
- .pre-commit-config.yaml
- pyproject.toml
- .github/workflows/service-checks.yml
- .devcontainer/llm-proxy/**
- .devcontainer/scripts/**

precommit-llm-proxy:
runs-on: ubuntu-latest
precommit-context-retriever:
name: Pre-commit (context-retriever)
runs-on: ubuntu-24.04
needs: changes
if: needs.changes.outputs.llm_proxy == 'true'
if: needs.changes.outputs.context-retriever == 'true'
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
- name: Checkout repository
uses: actions/checkout@v4

- name: Run pre-commit for context-retriever
uses: ./.github/actions/run-precommit-for-service
with:
python-version: "3.12"
- name: Install dependencies
working-directory: services/llm-proxy
run: |
uv venv
uv pip install -e ".[dev]"
- name: Run pre-commit
working-directory: services/llm-proxy
run: |
uv run pre-commit run -c ../../.pre-commit-config.yaml --files $(git -C ../.. ls-files services/llm-proxy)
devcontainer-cfg-path: .devcontainer/context-retriever
service-workdir: /home/appuser/workspace/services/context-retriever


precommit-web-app:
runs-on: ubuntu-latest
name: Pre-commit (web-app)
runs-on: ubuntu-24.04
needs: changes
if: needs.changes.outputs.web-app == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Run pre-commit for web-app
uses: ./.github/actions/run-precommit-for-service
with:
devcontainer-cfg-path: .devcontainer/web-app
service-workdir: /home/appuser/workspace/services/web-app

precommit-llm-proxy:
name: Pre-commit (llm-proxy)
runs-on: ubuntu-24.04
needs: changes
if: needs.changes.outputs.web_app == 'true'
if: needs.changes.outputs.llm-proxy == 'true'
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
- name: Checkout repository
uses: actions/checkout@v4

- name: Run pre-commit for llm-proxy
uses: ./.github/actions/run-precommit-for-service
with:
python-version: "3.12"
- name: Install dependencies
working-directory: services/web-app
run: |
uv venv
uv pip install -e ".[dev]"
- name: Run pre-commit
working-directory: services/web-app
run: |
uv run pre-commit run -c ../../.pre-commit-config.yaml --files $(git -C ../.. ls-files services/web-app)
devcontainer-cfg-path: .devcontainer/llm-proxy
service-workdir: /home/appuser/workspace/services/llm-proxy
2 changes: 1 addition & 1 deletion services/llm-proxy/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ run-server *args:

# Runs static checks using global pre-commit configuration.
run-precommit:
uv run pre-commit run -c ../../.pre-commit-config.yaml \
uv run --extra dev pre-commit run -c ../../.pre-commit-config.yaml \
--files `git ls-files --cached --others --exclude-standard`
2 changes: 1 addition & 1 deletion services/web-app/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ run-mock-backend:

# Runs static checks using global pre-commit configuration.
run-precommit:
uv run pre-commit run -c ../../.pre-commit-config.yaml \
uv run --extra dev pre-commit run -c ../../.pre-commit-config.yaml \
--files `git ls-files --cached --others --exclude-standard`