diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index a5b11c2..40b7a06 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -4,6 +4,9 @@ on: tags: - 'v*' +env: + REGISTRY: ghcr.io + jobs: push: runs-on: ubuntu-latest @@ -20,7 +23,7 @@ jobs: - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: - registry: ghcr.io + registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} @@ -28,6 +31,32 @@ jobs: run: | make docker-buildx + - name: 'Set up Docker Buildx' + uses: docker/setup-buildx-action@v3 + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/testbench/testworkflows + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=raw,value=latest + + - name: 'Build & Push TestWorkflows Image' + uses: docker/build-push-action@v5 + with: + context: ./testworkflows + file: ./testworkflows/Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + - name: 'Setup Flux CLI' uses: fluxcd/flux2/action@main diff --git a/testworkflows/.dockerignore b/testworkflows/.dockerignore new file mode 100644 index 0000000..eb709d6 --- /dev/null +++ b/testworkflows/.dockerignore @@ -0,0 +1,44 @@ +# Python cache and compiled files +__pycache__/ +*.py[cod] +*$py.class +*.so +.Python + +# Testing +.pytest_cache/ +.coverage +htmlcov/ +.tox/ + +# Virtual environments +venv/ +env/ +ENV/ + +# IDE and editor files +.vscode/ +.idea/ +*.swp +*.swo +*~ + +# Git +.git/ +.gitignore + +# Environment variables +.env +.env.* + +# Documentation +*.md + +# Data directories (created at runtime) +data/ +results/ + +# Temporary files +*.log +*.tmp +.DS_Store \ No newline at end of file diff --git a/testworkflows/Dockerfile b/testworkflows/Dockerfile new file mode 100644 index 0000000..a52192a --- /dev/null +++ b/testworkflows/Dockerfile @@ -0,0 +1,33 @@ +FROM python:3.13-slim + +WORKDIR /app + +# Install runtime and build dependencies (git is needed for Gitpython, which is a dependency of Ragas) +RUN apt-get update && apt-get install -y --no-install-recommends \ + git \ + && rm -rf /var/lib/apt/lists/* + +# Install UV package manager +COPY --from=ghcr.io/astral-sh/uv:0.9 /uv /bin/uv + +# Copy dependency files +COPY pyproject.toml uv.lock ./ + +# Install dependencies using UV +RUN uv sync + +# Copy scripts to root dir +COPY scripts/* ./ + +# Create directories for data and results +RUN mkdir -p data/datasets data/experiments results + +# Set environment variables +ENV PYTHONUNBUFFERED=1 \ + PYTHONDONTWRITEBYTECODE=1 + +# Make scripts executable +RUN chmod +x *.py + +# Set 'uv run python3' entrypoint so we can run scripts directly +ENTRYPOINT ["uv", "run", "python3"] \ No newline at end of file diff --git a/testworkflows/Makefile b/testworkflows/Makefile new file mode 100644 index 0000000..3b7c76d --- /dev/null +++ b/testworkflows/Makefile @@ -0,0 +1,26 @@ +# Testworkflows Docker Image Makefile + +# Image configuration +IMAGE_NAME ?= testworkflows +IMAGE_TAG ?= latest + +# Full image reference +IMAGE := $(IMAGE_NAME):$(IMAGE_TAG) + +.PHONY: help +help: ## Display this help message + @echo "Testworkflows Docker Image Management" + @echo "" + @echo "Usage: make [target]" + @echo "" + @awk 'BEGIN {FS = ":.*##"; printf "Targets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " %-15s %s\n", $$1, $$2 } /^##@/ { printf "\n%s\n", substr($$0, 5) } ' $(MAKEFILE_LIST) + +## Build the Docker image +.PHONY: build +build: + docker build -t $(IMAGE) . + +## Run container +.PHONY: run +run: + docker run --rm -it $(IMAGE) \ No newline at end of file