Skip to content

Commit

Permalink
Merge pull request #2 from NREL/sksundae
Browse files Browse the repository at this point in the history
sksundae
  • Loading branch information
c-randall authored Nov 11, 2024
2 parents e23c457 + 47c3457 commit 5204d3f
Show file tree
Hide file tree
Showing 105 changed files with 5,471 additions and 704 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
blank_issues_enabled: true
contact_links:
- name: I just have a question...
url: https://github.com/ROVI-org/thevenin/discussions
url: https://github.com/NREL/thevenin/discussions
about: Join our discussion instead. Search for existing questions, or ask a new one!
2 changes: 1 addition & 1 deletion .github/linters/.codespellrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[codespell]
skip = build,docs,images,reports,sphinx,references
skip = build,docs,images,reports,references
ignore-words-list = thev
2 changes: 1 addition & 1 deletion .github/linters/.flake8
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@

max-line-length = 80
extend-ignore = E121,E122,E126,E127,E128,E131,E201,E202,E226,E241,E731
exclude = build,docs,sphinx,images,reports
exclude = build,docs,images,reports,references
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Please include a summary of the change and which issue is fixed. Please also inc
Fixes # (issue)

## Type of change
Please add a line in the relevant section of [CHANGELOG.md](https://github.com/ROVI-org/thevenin/blob/main/CHANGELOG.md) to document the change (include PR #) - note reverse order of PR #s. If necessary, also add to the list of breaking changes.
Please add a line in the relevant section of [CHANGELOG.md](https://github.com/NREL/thevenin/blob/main/CHANGELOG.md) to document the change (include PR #) - note reverse order of PR #s. If necessary, also add to the list of breaking changes.

- [ ] New feature (non-breaking change which adds functionality)
- [ ] Optimization (back-end change that improves speed/readability/etc.)
Expand Down
52 changes: 34 additions & 18 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- 'CHANGELOG*'
- 'docs/*'
- 'images/*'
- 'LICENSE'
- '.github/ISSUE_TEMPLATE/*'

pull_request:
Expand All @@ -20,33 +21,38 @@ on:
- 'CHANGELOG*'
- 'docs/*'
- 'images/*'
- 'LICENSE'
- '.github/ISSUE_TEMPLATE/*'

jobs:
lint:
name: (Lint ${{ matrix.python-version }}, ${{ matrix.os }})

runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest']
python-version: ['3.12']
os: [ubuntu-latest]
python-version: ['3.13']

defaults:
run:
shell: bash -l {0}

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Checkout repository
uses: actions/checkout@v4

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

- name: Spell check
run: |
pip install codespell
codespell --config .github/linters/.codespellrc
- name: Code format
run: |
pip install flake8
Expand All @@ -55,34 +61,44 @@ jobs:
tests:
name: (Test ${{ matrix.python-version }}, ${{ matrix.os }})

runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'windows-latest', 'macos-13', 'macos-latest']
python-version: ['3.9', '3.12']
os: [macos-13, macos-latest, windows-latest, ubuntu-latest]
python-version: ['3.9', '3.13']

defaults:
run:
shell: bash -l {0}

steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup conda/python
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: 'rovi'
python-version: ${{ matrix.python-version }}
miniconda-version: 'latest'
auto-update-conda: true
- name: Conda dependencies
run: conda install scikits_odes_sundials -c conda-forge
miniconda-version: latest
python-version: ${{ matrix.python-version }}
activate-environment: rovi

- name: Verify environment
run: |
conda info
conda list
- name: Pip dependencies
run: pip install .
- name: List packages
run: conda list

- name: List info
run: |
conda info
conda list
- name: Pytest
run: |
pip install pytest
pytest
pytest .
210 changes: 210 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
name: release

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+a[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+b[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+rc[0-9]+'

env:
PACKAGE_NAME: '<PACKAGE_NAME>'

jobs:
details:
runs-on: ubuntu-latest
outputs:
tag_version: ${{ steps.release.outputs.tag_version }}

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Extract tag details
id: release
run: |
if [[ "${{ github.ref_type }}" = "tag" ]]; then
TAG_VERSION=${GITHUB_REF#refs/tags/v}
echo "tag_version=$TAG_VERSION" >> "$GITHUB_OUTPUT"
echo "Tag version is $TAG_VERSION"
else
echo "No tag found"
exit 1
fi
check-version:
needs: details
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

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

- name: Fetch info from PyPI
run: |
response=$(curl -s https://pypi.org/pypi/${{ env.PACKAGE_NAME }}/json || echo "{}")
latest_pypi_version=$(echo $response | grep -oP '"releases":\{"\K[^"]+' | sort -rV | head -n 1)
if [[ -z "$latest_pypi_version" ]]; then
echo "Package not found on PyPI."
latest_pypi_version="0.0.0"
fi
echo "Latest version on PyPI: $latest_pypi_version"
echo "latest_pypi_version=$latest_pypi_version" >> $GITHUB_ENV
- name: Compare version against PyPI and exit if not newer
run: |
TAG_VERSION=${{ needs.details.outputs.tag_version }}
PYPI_VERSION=$latest_pypi_version
TAG_BASE=${TAG_VERSION%%[a-z]}
PYPI_BASE=${PYPI_VERSION%%[a-z]}
TAG_SUFFIX=${TAG_VERSION#$TAG_BASE}
PYPI_SUFFIX=${PYPI_VERSION#$PYPI_BASE}
suffix_count=0
[[ -n "$TAG_SUFFIX" ]] && ((suffix_count++))
[[ -n "$PYPI_SUFFIX" ]] && ((suffix_count++))
if [[ "$TAG_VERSION" == "$PYPI_VERSION" ]]; then
echo "The tag $TAG_VERSION matches the PyPI version $PYPI_VERSION."
exit 1
elif [[ "$suffix_count" == 1 && "$TAG_BASE" == "$PYPI_BASE" ]]; then
if [[ -n "$PYPI_SUFFIX" ]]; then
echo "The tag $TAG_VERSION is newer than PyPI $PYPI_VERSION."
else
echo "The tag $TAG_VERSION is older than PyPI $PYPI_VERSION."
exit 1
fi
else
newest=$(printf "%s\n%s" "$TAG_VERSION" "$PYPI_VERSION" | sort -V | tail -n 1)
if [[ "$TAG_VERSION" == "$newest" ]]; then
echo "The tag $TAG_VERSION is newer than PyPI $PYPI_VERSION."
else
echo "The tag $TAG_VERSION is older than PyPI $PYPI_VERSION."
exit 1
fi
fi
- name: Verify tag and pyproject.toml versions match
run: |
python -m pip install --upgrade pip
pip install setuptools numpy cython
PKG_VERSION=$(python setup.py --version)
TAG_VERSION=${{ needs.details.outputs.tag_version }}
if [[ "$PKG_VERSION" != "$TAG_VERSION" ]]; then
echo "Version mismatch: setup.py has $PKG_VERSION, but tag is $TAG_VERSION."
exit 1
else
echo "Package and tag versions match: $PKG_VERSION == $TAG_VERSION."
fi
build:
name: (build ubuntu-latest, 3.13)
needs: [details, check-version]
runs-on: ubuntu-latest

defaults:
run:
shell: bash -l {0}

steps:
- name: Checkout repository
uses: actions/checkout@v4

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

- name: Install build
run: pip install build

- name: Build distributions
run: python -m build

- name: Upload
uses: actions/upload-artifact@v4
with:
name: builds
path: dist/*

test:
name: (test ${{ matrix.python-version }}, ${{ matrix.os }})
needs: build
runs-on: ${{ matrix.os }}

strategy:
fail-fast: true
matrix:
os: [macos-13, macos-latest, windows-latest, ubuntu-latest]
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']

defaults:
run:
shell: bash -l {0}

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist/
pattern: builds*
merge-multiple: true

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

- name: Install thevenin
run: pip install dist/*.whl -v

- name: Pytest
run: |
pip install pytest
pytest ./tests
pypi-publish:
name: Upload to PyPI
needs: test
runs-on: ubuntu-latest

steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist/
pattern: builds*
merge-multiple: true

- name: Check files
run: ls dist

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

- name: Install twine
run: pip install twine

- name: Check builds and upload to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
twine check dist/*
twine upload dist/*
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ instance/
.scrapy

# Sphinx documentation
docs/
sphinx/
docs/build

# PyBuilder
.pybuilder/
Expand Down
16 changes: 16 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set OS, Python version, and other tools for the build
build:
os: ubuntu-22.04
tools:
python: latest

# Location of sphinx configuration file
sphinx:
configuration: docs/source/conf.py
Loading

0 comments on commit 5204d3f

Please sign in to comment.