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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
55 changes: 44 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,76 @@ on:
- reopened
paths:
- '**.py'
- 'pyproject.toml'
push:
branches:
- main
paths:
- '**.py'
- 'pyproject.toml'

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [ "3.9", "3.10" ]
python-version: [ "3.9", "3.10", "3.11" ]

steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Install Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f ./engforge/datastores/datastores_requirements.txt ]; then pip install -r ./engforge/datastores/datastores_requirements.txt; fi
pip install flake8 pytest black
pip install -e .[all]

- name: Display Python Version
run: python -c "import sys; print(sys.version)"

- name: Check for existing release
if: github.event_name == 'pull_request'
run: |
VERSION=$(python -c "
try:
import tomllib
except ImportError:
import tomli as tomllib
with open('pyproject.toml', 'rb') as f:
print(tomllib.load(f)['project']['version'])
")
echo "Checking for existing release v$VERSION"
if gh release view "v$VERSION" >/dev/null 2>&1; then
echo "::error::Release v$VERSION already exists. Please bump the version in pyproject.toml"
exit 1
else
echo "Version v$VERSION is available"
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Auto-format with Black
if: github.event_name == 'pull_request'
run: |
black ./engforge
if ! git diff --quiet; then
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add -A
git commit -m "Auto-format code with Black [skip ci]" || exit 0
git push
fi

- name: Run tests
run: python -m unittest discover ./test/
run: python -m unittest discover -s engforge/test -p "test_*.py" -v

- uses: psf/black@stable
with:
version: "24.8.0"
options: "--check --verbose"
src: "./engforge"
- name: Verify Black formatting
run: black --check --verbose ./engforge
35 changes: 9 additions & 26 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
name: "docs"
on:
push:
branches:
- main
pull_request:
paths:
- '**.py'
- '**.md'
- '**.rst'
- '**.yml'
- 'docs/**'

permissions:
pages: write
id-token: write
contents: read

jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- uses: actions/checkout@v4

- name: Install Python
Expand All @@ -31,26 +24,16 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
if [ -f "./engforge/datastores/datastores_requirements.txt" ]; then pip install -r ./engforge/datastores/datastores_requirements.txt; fi
pip install -e .[all]
pip install -r ./docs/requirements.txt

- name: make html
- name: Test documentation build
run: |
cd docs
make html

# - uses: actions/upload-artifact@v4
# with:
# name: DocumentationHTML
# path: docs/_build/html/

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
- name: Upload documentation artifact
uses: actions/upload-artifact@v4
with:
# Upload entire repository
path: 'docs/_build/html/'

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
name: documentation-preview
path: docs/_build/html/
100 changes: 100 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: release

on:
push:
branches:
- main
paths:
- '**.py'
- 'pyproject.toml'
- '**.md'
- '**.rst'
- '**.yml'

permissions:
contents: write
pages: write
id-token: write

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
pip install -e .[all]
pip install -r ./docs/requirements.txt

- name: Get version
id: version
run: |
VERSION=$(python -c "
try:
import tomllib
except ImportError:
import tomli as tomllib
with open('pyproject.toml', 'rb') as f:
print(tomllib.load(f)['project']['version'])
")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"

- name: Check if release exists
id: check_release
run: |
if gh release view "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then
echo "exists=true" >> $GITHUB_OUTPUT
echo "Release v${{ steps.version.outputs.version }} already exists"
else
echo "exists=false" >> $GITHUB_OUTPUT
echo "Release v${{ steps.version.outputs.version }} does not exist"
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build documentation
run: |
cd docs
make html

- name: Upload pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: 'docs/_build/html/'

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

- name: Build package
if: steps.check_release.outputs.exists == 'false'
run: |
python -m build

- name: Create GitHub Release
if: steps.check_release.outputs.exists == 'false'
run: |
gh release create "v${{ steps.version.outputs.version }}" \
--title "Release v${{ steps.version.outputs.version }}" \
--notes "Automated release for version ${{ steps.version.outputs.version }}" \
--generate-notes \
dist/*
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish to PyPI
if: steps.check_release.outputs.exists == 'false'
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://upload.pypi.org/legacy/
16 changes: 15 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,18 @@ dist/*
*.profile
*.log

docs/_autosummary*
# Build artifacts and packaging
*.egg-info/
*.egg
.eggs/
MANIFEST
.installed.cfg

# Claude Code tracking files
*.claude.rar
.claude/
claude_session_*

# Documentation build
docs/_autosummary*
docs/_build/
Loading
Loading