Skip to content
Open
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
62 changes: 62 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: read

concurrency:
group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip
cache-dependency-path: requirements-dev.txt

- name: Install Ruff
run: pip install --disable-pip-version-check -r requirements-dev.txt

- name: Ruff
run: ruff check api-service ingestion-service notification-service

test:
name: Test (${{ matrix.service }})
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
service: [api-service, ingestion-service, notification-service]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip
cache-dependency-path: ${{ matrix.service }}/requirements.txt

- name: Install dependencies
run: pip install --disable-pip-version-check -r ${{ matrix.service }}/requirements.txt

- name: Pytest
working-directory: ${{ matrix.service }}
run: python -m pytest tests/ -q
44 changes: 44 additions & 0 deletions scripts/run-ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash
# Run the same lint and test steps as .github/workflows/ci.yml locally.
set -euo pipefail

ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT"

PYTHON="${PYTHON:-python3}"
LINT_VENV="$ROOT/.venv"

ensure_lint_venv() {
if [[ ! -d "$LINT_VENV" ]]; then
"$PYTHON" -m venv "$LINT_VENV"
"$LINT_VENV/bin/pip" install --disable-pip-version-check -q --upgrade pip
"$LINT_VENV/bin/pip" install --disable-pip-version-check -q -r requirements-dev.txt
elif ! "$LINT_VENV/bin/python" -m ruff --version &>/dev/null; then
"$LINT_VENV/bin/pip" install --disable-pip-version-check -q -r requirements-dev.txt
fi
}

run_service_tests() {
local service=$1
local service_dir="$ROOT/$service"
local venv="$service_dir/.venv"

echo "==> Test ($service)"
if [[ ! -d "$venv" ]]; then
"$PYTHON" -m venv "$venv"
"$venv/bin/pip" install --disable-pip-version-check -q --upgrade pip
"$venv/bin/pip" install --disable-pip-version-check -q -r "$service_dir/requirements.txt"
fi

(cd "$service_dir" && "$venv/bin/python" -m pytest tests/ -q)
}

echo "==> Lint (Ruff)"
ensure_lint_venv
"$LINT_VENV/bin/ruff" check api-service ingestion-service notification-service

run_service_tests api-service
run_service_tests ingestion-service
run_service_tests notification-service

echo "==> All CI checks passed"