Skip to content

added additional information theoretic framework to distill additiona… #12

added additional information theoretic framework to distill additiona…

added additional information theoretic framework to distill additiona… #12

Workflow file for this run

name: CI/CD
on:
push:
branches: [master, main]
pull_request:
branches: [master, main]
permissions:
contents: write
id-token: write
pages: write
jobs:
# ===========================================================================
# Run Tests
# ===========================================================================
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Run tests
run: pytest tests/ -v --tb=short
# ===========================================================================
# Lint Check
# ===========================================================================
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: 'pip'
- name: Install linting tools
run: |
python -m pip install --upgrade pip
pip install ruff black isort
- name: Check formatting with black
run: black --check src/LZGraphs tests || true
- name: Check imports with isort
run: isort --check-only src/LZGraphs tests || true
- name: Lint with ruff
run: ruff check src/LZGraphs tests || true
# ===========================================================================
# Release (only on push to master, after tests pass)
# ===========================================================================
release:
needs: [test, lint]
runs-on: ubuntu-latest
concurrency: release
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_TOKEN }}
persist-credentials: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Get version from package
id: version
run: |
VERSION=$(grep -Po '(?<=__version__ = ")[^"]+' src/LZGraphs/__init__.py)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Current version: $VERSION"
- name: Check if version exists on PyPI
id: check_pypi
run: |
VERSION=${{ steps.version.outputs.version }}
if pip index versions LZGraphs 2>/dev/null | grep -q "$VERSION"; then
echo "Version $VERSION already exists on PyPI"
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "Version $VERSION not on PyPI - will publish"
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Build package
if: steps.check_pypi.outputs.exists == 'false'
run: python -m build
- name: Publish to PyPI
if: steps.check_pypi.outputs.exists == 'false'
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: twine upload dist/*
- name: Create GitHub Release
if: steps.check_pypi.outputs.exists == 'false'
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
VERSION=${{ steps.version.outputs.version }}
# Check if tag exists, create if not
if ! git tag -l | grep -q "^v$VERSION$"; then
git tag "v$VERSION"
git push origin "v$VERSION"
fi
# Create release if it doesn't exist
if ! gh release view "v$VERSION" &>/dev/null; then
gh release create "v$VERSION" \
--title "v$VERSION" \
--notes "Release v$VERSION" \
dist/*
fi
# ===========================================================================
# Deploy Documentation to GitHub Pages
# ===========================================================================
docs:
needs: [test, lint]
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: 'pip'
- name: Install documentation dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[docs]"
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Build and deploy documentation
run: mkdocs gh-deploy --force