Skip to content

Feature: Add CI workflow for linting, testing, and security scanning #2

Feature: Add CI workflow for linting, testing, and security scanning

Feature: Add CI workflow for linting, testing, and security scanning #2

Workflow file for this run

name: CI
on:
push: {}
pull_request: {}
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
build-test:
name: Lint & Test (Python)
runs-on: ubuntu-latest
timeout-minutes: 25
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Install system deps
run: |
sudo apt-get update
sudo apt-get install -y libgl1 libglib2.0-0
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install ruff pytest pytest-cov
- name: Ruff Lint
run: ruff check .
- name: Ruff Format Check
run: ruff format --check .
- name: Run Tests
env:
PYTHONWARNINGS: default
run: |
pytest -q --cov=src --cov-report=xml --cov-report=term
- name: Upload coverage XML
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: coverage-xml
path: coverage.xml
- name: Upload pytest cache & reports
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: pytest-artifacts
path: |
.pytest_cache
./**/pytest-*.log
security:
name: Basic Security Scan
runs-on: ubuntu-latest
needs: build-test
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Install deps (no extras)
run: |
python -m pip install --upgrade pip
pip install pip-audit -r requirements.txt || true
- name: pip-audit (non-failing)
continue-on-error: true
run: |
pip install pip-audit
pip-audit -r requirements.txt -f json > pip-audit.json || true
- name: Upload pip-audit report
uses: actions/upload-artifact@v4
with:
name: pip-audit-report
path: pip-audit.json
summary:
name: PR Summary
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
needs: [build-test, security]
permissions:
contents: read
pull-requests: write
steps:
- name: Generate Summary
run: |
echo '### CI Results' >> $GITHUB_STEP_SUMMARY
echo '* Build/Test: ${{ needs.build-test.result }}' >> $GITHUB_STEP_SUMMARY
echo '* Security: ${{ needs.security.result }}' >> $GITHUB_STEP_SUMMARY