Skip to content

feat: add hard-purge daemons for soft-deleted files and vector stores #128

feat: add hard-purge daemons for soft-deleted files and vector stores

feat: add hard-purge daemons for soft-deleted files and vector stores #128

Workflow file for this run

name: Lint, Test, Build, and Publish Docker Images
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
permissions:
contents: write # semantic-release & auto-formatter commits
packages: write # push to Docker Hub / GHCR
jobs:
# ──────────────────────────────────────────────────────────────────────────
# 🧹 Lint
# ──────────────────────────────────────────────────────────────────────────
lint:
name: "🧹 Lint Code & Dockerfiles"
runs-on: ubuntu-latest
steps:
- name: "🕺 Checkout repository"
uses: actions/checkout@v4
- name: "🐍 Set up Python"
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: "📦 Cache pip dependencies"
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-lint-${{ hashFiles('**/*_reqs_*.txt', '**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-lint-
- name: "⚙️ Install Linting Tools"
run: |
python -m pip install --upgrade pip
pip install "ruff==0.4.0" black
sudo wget -qO /usr/local/bin/hadolint \
https://github.com/hadolint/hadolint/releases/latest/download/hadolint-Linux-x86_64
sudo chmod +x /usr/local/bin/hadolint
- name: "✨ Run Ruff Linter"
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
ruff check . --output-format=github
else
ruff check . --fix --output-format=github || true
fi
- name: "⚫️ Run Black Formatter"
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
black --check .
else
black .
git diff --exit-code || true
fi
- name: "🐳 Lint Dockerfiles"
run: |
hadolint docker/api/Dockerfile || true
hadolint docker/sandbox/Dockerfile || true
# ──────────────────────────────────────────────────────────────────────────
# ✅ Tests
# ──────────────────────────────────────────────────────────────────────────
test:
name: "✅ Run Unit Tests"
runs-on: ubuntu-latest
needs: lint
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12"]
steps:
- name: "🕺 Checkout repository"
uses: actions/checkout@v4
- name: "🐍 Set up Python ${{ matrix.python-version }}"
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: "📦 Cache pip dependencies"
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-test-${{ matrix.python-version }}-${{ hashFiles('**/*_reqs_*.txt', '**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-test-${{ matrix.python-version }}-
- name: "⚙️ Install Project & Test Deps"
run: |
python -m pip install --upgrade pip
pip install -r api_unhashed_reqs.txt
pip install --require-hashes -r api_reqs_hashed.txt
pip install -r sandbox_reqs_unhashed.txt
pip install --require-hashes -r sandbox_reqs_hashed.txt
pip install pytest pytest-cov
- name: "✅ Run Pytest with Coverage"
run: pytest tests/ --cov=src --cov-report=xml --cov-report=term-missing
- name: "⬆️ Upload coverage to Codecov"
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
# ──────────────────────────────────────────────────────────────────────────
# 🚀 Build & Publish Docker images
# ──────────────────────────────────────────────────────────────────────────
build_and_publish:
name: "🚀 Build, Tag, and Publish Images to Docker Hub"
runs-on: ubuntu-latest
needs: test
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
steps:
- name: "🕺 Checkout repository"
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: true
- name: "⚙️ Setup QEMU"
uses: docker/setup-qemu-action@v3
- name: "⚙️ Setup Docker Buildx"
uses: docker/setup-buildx-action@v3
- name: "🔑 Login to Docker Hub"
uses: docker/login-action@v3
with:
username: thanosprime
password: ${{ secrets.DOCKERHUB_THANOSPRIME }}
# quick cleanup of any dangling layers on the runner
- name: "🧼 Prune Docker System Cache"
run: docker system prune -af || true
# ----- semantic-release -------------------------------------------------
- name: "🚀 Setup Node.js"
uses: actions/setup-node@v4
with:
node-version: "20"
- name: "⚙️ Install semantic-release"
run: |
npm install -g semantic-release \
@semantic-release/commit-analyzer \
@semantic-release/release-notes-generator \
@semantic-release/changelog \
@semantic-release/exec \
@semantic-release/git \
@semantic-release/github
- name: "🚀 Run semantic-release"
id: semantic
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release
- name: "🏷️ Extract Git Tag Version"
id: get_version
run: |
git fetch --tags origin
VERSION=$(git describe --tags --exact-match HEAD 2>/dev/null || git describe --tags --abbrev=0 HEAD 2>/dev/null)
if [ -z "$VERSION" ]; then
echo "::error::Could not determine version tag after semantic-release."
exit 1
fi
VERSION=${VERSION#v}
echo "Detected version: $VERSION"
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
# ---------------- API image metadata ----------------
- name: "🔧 Define API Image Metadata"
id: meta_api
uses: docker/metadata-action@v5
with:
images: thanosprime/entities-api-api
tags: |
type=semver,pattern={{version}},value=${{ steps.get_version.outputs.VERSION }}
type=raw,value=latest,enable={{is_default_branch}}
type=sha,prefix=sha-
# ---------------- Sandbox image metadata ------------
- name: "🔧 Define Sandbox Image Metadata"
id: meta_sandbox
uses: docker/metadata-action@v5
with:
images: thanosprime/entities-api-sandbox
tags: |
type=semver,pattern={{version}},value=${{ steps.get_version.outputs.VERSION }}
type=raw,value=latest,enable={{is_default_branch}}
type=sha,prefix=sha-
# ---------------- Build / Push API ------------------
- name: "🏗️ Build & Push API Image"
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/api/Dockerfile
push: true
tags: ${{ steps.meta_api.outputs.tags }}
labels: ${{ steps.meta_api.outputs.labels }}
platforms: linux/amd64
cache-from: type=gha # ← still *reads* from cache
# no cache-to: export disabled
# ---------------- Build / Push Sandbox --------------
- name: "🏗️ Build & Push Sandbox Image"
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/sandbox/Dockerfile
push: true
tags: ${{ steps.meta_sandbox.outputs.tags }}
labels: ${{ steps.meta_sandbox.outputs.labels }}
platforms: linux/amd64
cache-from: type=gha # ← still *reads* from cache
# no cache-to: export disabled