From 56dc9277d7244c7eecb90271333ee05e3629594c Mon Sep 17 00:00:00 2001 From: teknium1 Date: Thu, 5 Mar 2026 07:29:16 -0800 Subject: [PATCH] ci: add test workflow for PRs and main branch Run pytest on Python 3.11 + 3.12 for every PR and push to main. - Uses uv for fast dependency installation - Excludes integration tests (need real API keys/services) - Blanks API keys as safety net against accidental real API calls - Concurrency: cancels in-progress runs when new commits are pushed - 10 minute timeout (tests take ~77s) - fail-fast disabled so both Python versions run independently GitHub's default 'require approval for first-time contributors' means maintainers approve CI before it runs on new contributors' PRs, preventing abuse of CI resources. --- .github/workflows/tests.yml | 47 +++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..659d8dc2 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,47 @@ +name: Tests + +on: + push: + branches: [main] + pull_request: + branches: [main] + +# Cancel in-progress runs for the same PR/branch +concurrency: + group: tests-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + runs-on: ubuntu-latest + timeout-minutes: 10 + strategy: + matrix: + python-version: ['3.11', '3.12'] + fail-fast: false + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v5 + + - name: Set up Python ${{ matrix.python-version }} + run: uv python install ${{ matrix.python-version }} + + - name: Install dependencies + run: | + uv venv .venv --python ${{ matrix.python-version }} + source .venv/bin/activate + uv pip install -e ".[all,dev]" + + - name: Run tests + run: | + source .venv/bin/activate + python -m pytest tests/ -q --ignore=tests/integration --tb=short + env: + # Ensure tests don't accidentally call real APIs + OPENROUTER_API_KEY: "" + OPENAI_API_KEY: "" + NOUS_API_KEY: ""