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
84 changes: 71 additions & 13 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,80 @@
name: Publish Python 🐍 distribution to PyPI
name: CI/CD Pipeline

on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master
release:
types: [published]

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

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

- name: Install linting tools
run: |
python -m pip install --upgrade pip
pip install ruff mypy

- name: Check formatting with Ruff
run: ruff format --check .

- name: Lint with Ruff
run: ruff check .

- name: Type check with mypy
run: mypy runapi --ignore-missing-imports
continue-on-error: true # Don't fail on type errors initially

test:
name: Test Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
needs: lint
strategy:
fail-fast: false
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 ".[test]"

- name: Run tests
run: |
python tests/test_runapi.py

check-version:
runs-on: ubuntu-latest
needs: test
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
outputs:
is_new_version: ${{ steps.check.outputs.is_new_version }}
version: ${{ steps.check.outputs.version }}
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
Expand All @@ -38,9 +96,9 @@ jobs:
project = tomllib.load(f)
local_version = project["project"]["version"]
package_name = project["project"]["name"]

print(f"Checking version {local_version} for package {package_name}...")

# Output version for later jobs
with open(os.environ['GITHUB_OUTPUT'], 'a') as fh:
print(f"version={local_version}", file=fh)
Expand All @@ -65,30 +123,30 @@ jobs:
else:
print(f"Error checking PyPI: {e}")
sys.exit(1)

except Exception as e:
print(f"Error: {e}")
sys.exit(1)

build:
needs: check-version
if: needs.check-version.outputs.is_new_version == 'true'
name: Build distribution 📦
name: Build distribution
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

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

- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build

- name: Build a binary wheel and a source tarball
run: python -m build

Expand All @@ -99,7 +157,7 @@ jobs:
path: dist/

publish-to-pypi:
name: Publish Python 🐍 distribution to PyPI
name: Publish to PyPI
needs: build
runs-on: ubuntu-latest
permissions:
Expand All @@ -112,22 +170,22 @@ jobs:
name: python-package-distributions
path: dist/

- name: Publish distribution 📦 to PyPI
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
skip-existing: true
verbose: true

create-release:
name: Create GitHub Release 🏷️
name: Create GitHub Release
needs: [publish-to-pypi, check-version]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- name: Create Release
uses: softprops/action-gh-release@v2
with:
Expand Down
105 changes: 104 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,106 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
venv/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
*.egg
MANIFEST

# PyInstaller
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# IDEs and editors
.idea/
.vscode/
*.swp
*.swo
*~
.project
.pydevproject
.settings/
*.sublime-project
*.sublime-workspace

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre
.pyre/

# Logs
*.log
logs/

# Local development
.DS_Store
Thumbs.db

# Temporary files
tmp/
temp/
*.tmp
*.bak

# Secrets (never commit these)
*.pem
*.key
secrets.json
credentials.json
Loading
Loading