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

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

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

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"

- name: Lint with ruff
run: ruff check .

test:
name: Test (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"

- name: Run tests
run: pytest -v

version-check:
name: Version sync
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Check version consistency
run: |
PYPROJECT_VERSION=$(python -c "
import re
with open('pyproject.toml') as f:
match = re.search(r'^version\s*=\s*\"(.+?)\"', f.read(), re.MULTILINE)
print(match.group(1))
")
INIT_VERSION=$(python -c "
import re
with open('plexus/__init__.py') as f:
match = re.search(r'^__version__\s*=\s*\"(.+?)\"', f.read(), re.MULTILINE)
print(match.group(1))
")
echo "pyproject.toml version: $PYPROJECT_VERSION"
echo "__init__.py version: $INIT_VERSION"
if [ "$PYPROJECT_VERSION" != "$INIT_VERSION" ]; then
echo "::error::Version mismatch! pyproject.toml=$PYPROJECT_VERSION, __init__.py=$INIT_VERSION"
exit 1
fi
echo "Versions match: $PYPROJECT_VERSION"
50 changes: 42 additions & 8 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,60 @@ name: Publish to PyPI
on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: 'Version to publish (leave empty for current)'
required: false

jobs:
validate:
name: Validate release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"

- name: Check tag matches code version
run: |
TAG="${GITHUB_REF#refs/tags/v}"
CODE_VERSION=$(python -c "
import re
with open('pyproject.toml') as f:
match = re.search(r'^version\s*=\s*\"(.+?)\"', f.read(), re.MULTILINE)
print(match.group(1))
")
echo "Git tag version: $TAG"
echo "Code version: $CODE_VERSION"
if [ "$TAG" != "$CODE_VERSION" ]; then
echo "::error::Tag v$TAG does not match code version $CODE_VERSION"
exit 1
fi

- name: Lint
run: ruff check .

- name: Run tests
run: pytest -v

publish:
name: Publish to PyPI
needs: validate
runs-on: ubuntu-latest
permissions:
id-token: write # Required for trusted publishing
id-token: write

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: '3.12'

- name: Install build tools
run: |
Expand All @@ -36,4 +71,3 @@ jobs:

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
# Uses trusted publishing - configure at pypi.org/manage/project/plexus-agent/settings/publishing/
33 changes: 0 additions & 33 deletions .github/workflows/test.yml

This file was deleted.

Loading