Skip to content
Closed
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
38 changes: 13 additions & 25 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,29 @@
name: Coverage (Codecov)

on:
push:
branches: [ "main", "develop" ]
pull_request:
branches: [ "main", "develop" ]
branches: ["main", "develop"]

jobs:
test:
name: Run tests and upload coverage
coverage:
name: Compute coverage
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Set up Python 3.10
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: "3.10"
enable-cache: true

- name: Install pandoc
uses: pandoc/actions/setup@v1

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install coverage
python -m pip install sphinx myst_parser sphinx-rtd-theme nbsphinx pandoc jupyter jupyterlab
pip install -e .
- name: Install the project
run: uv sync --locked --all-extras --dev

- name: Tests with coverage
run: |
coverage run --omit='./results/*','./docs/*','./examples/*' -m unittest discover tests
coverage xml -o coverage.xml
run: uv run pytest --cov=nnodely --cov-branch --cov-report=xml tests

- name: Upload results to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
uses: codecov/codecov-action@v6
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
189 changes: 80 additions & 109 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -1,130 +1,101 @@
name: Publish New nnodely Release
name: Publish

on:
push:
tags:
- "v*" # Push events to matching v*, i.e., v1.0, v20.15.10
- "v*"

jobs:
check-tag-version:
name: Check tag version equal to file version
publish:
name: Build and publish to both TestPyPi and PyPi
runs-on: ubuntu-latest
environment:
name: pypi
permissions:
id-token: write
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Extract tag version
- uses: actions/checkout@v6

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true

- name: Validate tag matches project version
run: |
TAG_NAME="${{ github.ref_name }}"
TAG_VERSION=$(echo $TAG_NAME | sed 's/v//')
TAG_VERSION="${GITHUB_REF_NAME#v}"
PROJ_VERSION=$(uv version --short)

echo "Tag version: $TAG_VERSION"
echo "TAG_VERSION=$TAG_VERSION" >> $GITHUB_ENV
- name: Extract file version
run: |
FILE_VERSION=$(awk -F"'" '/^__version__/ {print $2}' nnodely/__init__.py)
echo "File version: $FILE_VERSION"
echo "FILE_VERSION=$FILE_VERSION" >> $GITHUB_ENV
- name: Show tag and file versions
run: |
echo "The tag version: ${{ env.TAG_VERSION }}"
echo "The file version: ${{ env.FILE_VERSION }}"
- name: Check if tag and file versions match
if: ${{ env.TAG_VERSION != env.FILE_VERSION }}
run: |
echo "The tag version ${{ env.TAG_VERSION }} does not match file version ${{ env.FILE_VERSION }}"
exit 1
echo "Project version: $PROJ_VERSION"

build:
name: Build distribution of tagged version
needs:
- check-tag-version
runs-on: ubuntu-latest
if [ "$TAG_VERSION" != "$PROJ_VERSION" ]; then
echo "Mismatch: tag=$TAG_VERSION project=$PROJ_VERSION"
exit 1
fi

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"

- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
name: Publish to PyPI
needs:
- build
- name: Build
run: uv build

runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/nnodely # Replace <package-name> with your PyPI project name
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
# Check that basic features work and we didn't miss to include crucial files
- name: Basic test (wheel)
run: uv run --isolated --no-project --with dist/*.whl python -c "import nnodely"

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish nnodely to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- name: Basic test (source distribution)
run: uv run --isolated --no-project --with dist/*.tar.gz python -c "import nnodely"

- name: TestPyPi publish
run: uv publish --index testpypi

- name: PyPI publish
run: uv publish

- name: Upload artifacts
uses: actions/upload-artifact@v7
with:
name: python-package-distributions
path: dist/

github-release:
name: >-
Sign the Python with Sigstore and upload them to GitHub Release
needs:
- publish-to-pypi
name: Sign the Python with Sigstore and upload them to GitHub Release
runs-on: ubuntu-latest
needs:
- publish

permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write # IMPORTANT: mandatory for sigstore
contents: write
id-token: write

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Sign the dists with Sigstore
uses: sigstore/gh-action-sigstore-python@v3.0.0
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Get the branch version
run: |
TAG_NAME="${{ github.ref_name }}"
TAG_MESSAGE=${{ github.event.workflow_run.head_commit.message }}
echo "Tag message: $TAG_MESSAGE"
echo "TAG_MESSAGE=$TAG_MESSAGE" >> $GITHUB_ENV
- name: Create GitHub release
env:
GITHUB_TOKEN: ${{ github.token }}
tag: ${{ github.ref_name }}
run: |
echo "The branch version: $tag"
gh release create $tag --title "$tag" --repo ${{ github.repository }} --notes "${{ env.TAG_MESSAGE }}"
- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
tag: ${{ github.ref_name }}
# Upload to GitHub Release using the `gh` CLI.
# `dist/` contains the built packages, and the
# sigstore-produced signatures and certificates.
run: >-
gh release upload $tag dist/** --repo ${{ github.repository }}
- uses: actions/download-artifact@v8
with:
name: python-package-distributions
path: dist/

- name: Sign artifacts
uses: sigstore/gh-action-sigstore-python@v3.0.0
with:
inputs: |
./dist/*.tar.gz
./dist/*.whl
- name: Detect prerelease
id: version
run: |
VERSION="${GITHUB_REF_NAME#v}"

if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "PRERELEASE=false" >> "$GITHUB_OUTPUT"
else
echo "PRERELEASE=true" >> "$GITHUB_OUTPUT"
fi

- name: Release
uses: softprops/action-gh-release@v3
if: github.ref_type == 'tag'
with:
files: |
dist/*.tar.gz
dist/*.whl
generate_release_notes: true
prerelease: ${{ steps.version.outputs.PRERELEASE }}
23 changes: 23 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Lint

on:
pull_request:
branches: ["main", "develop"]

jobs:
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v6

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true

- name: Install the project
run: uv sync --locked --all-extras --dev

- name: Lint
run: uv run ruff check
50 changes: 14 additions & 36 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,29 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Run Tests

on:
push:
branches: [ "main", "develop" ]
pull_request:
branches: [ "main", "develop"]
branches: ["main", "develop"]

jobs:
build:

test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: [ "3.10", "3.11", "3.12"]
architecture: ['x64', 'x86']
python-version: ["3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install pandoc
uses: pandoc/actions/setup@v1
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
python -m pip install sphinx myst_parser sphinx-rtd-theme nbsphinx pandoc jupyter jupyterlab
pip install -e .
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest



- uses: actions/checkout@v6

- name: Install uv and set the Python version
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: ${{ matrix.python-version }}

- name: Install the project
run: uv sync --locked --all-extras --dev

- name: Run tests
run: uv run pytest tests
Loading
Loading