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
50 changes: 50 additions & 0 deletions .github/workflows/_build-docker-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: 'Build Docker Image'
on:
workflow_call:
env:
REGISTRY: docker.io
IMAGE_NAME: aberger4/jabs-postprocess
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:

- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: aberger4
password: ${{ secrets.DOCKER_SECRET }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable={{is_default_branch}}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
33 changes: 33 additions & 0 deletions .github/workflows/_format-lint-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: 'Lint Code Definition'
on:
workflow_call:
inputs:
python-version:
description: 'Python version to set up'
required: false
default: '3.10'
type: string
jobs:
format-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python-version }}

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"

- name: Install dependencies with uv
run: uv sync --only-group lint

- name: Run Ruff Linter
run: uv run --only-group lint ruff check src/ tests/

- name: Run Ruff Formatter
run: uv run --only-group lint ruff format --check src/ tests/
35 changes: 35 additions & 0 deletions .github/workflows/_run-tests-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: 'Python Tests Definition'
on:
workflow_call:
inputs:
python-version:
description: Python version to set up'
required: false
default: '3.10'
type: string
runner-os:
description: 'Runner OS'
required: false
default: 'ubuntu-latest'
type: string
jobs:
run-tests:
runs-on: ${{ inputs.runner-os }}
steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python-version }}

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"

- name: Install dependencies with uv
run: uv sync

- name: Test with pytest
run: uv run pytest tests
20 changes: 20 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Pull Request Checks

on:
pull_request:
branches: [ main, master ]

jobs:
format-lint:
name: "Format and Lint"
uses: ./.github/workflows/_format-lint-action.yml

test:
name: "Run Tests"
needs: format-lint
uses: ./.github/workflows/_run-tests-action.yml

build:
name: "Build Docker Image"
needs: [format-lint, test]
uses: ./.github/workflows/_build-docker-action.yml
36 changes: 36 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM ghcr.io/astral-sh/uv:python3.10-bookworm-slim

ENV UV_SYSTEM_PYTHON=1 \
UV_PYTHON=/usr/local/bin/python \
PYTHONUNBUFFERED=1

WORKDIR /workspace

RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg \
python3-tk \
coreutils \
libsm6 \
qtbase5-dev \
libglu1-mesa-dev \
libgl1-mesa-glx \
libxcb-util1 \
libvtk9-dev \
procps && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Copy metadata first for layer caching
COPY pyproject.toml uv.lock* README.md ./

# Only install runtime dependencies
RUN uv sync --frozen --no-group dev --no-group test --no-group lint --no-install-project

# Now add source and install the project itself
COPY src ./src

RUN uv sync --locked

ENV PATH="/workspace/.venv/bin:$PATH"

CMD ["jabs-postprocess", "--help"]
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ build-backend = "setuptools.build_meta"

[dependency-groups]
dev = [
{include-group = "lint"},
{include-group = "test"}
]
test = [
"pytest>=8.3.5",
"pytest-cov>=6.1.1",
]
lint = [
"ruff>=0.11.10",
]
Loading