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
4 changes: 2 additions & 2 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ plugins:
config:
minimum_severity: major
tests_patterns:
- pythresh/test/**
- tests/**
exclude_patterns:
- "examples/"
- "**/test/"
- "tests/"
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Force consistent line endings everywhere
* text=auto eol=lf
25 changes: 13 additions & 12 deletions .github/workflows/python-package.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,23 @@ jobs:
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
- name: Install libomp (macOS)
if: runner.os == 'macOS'
run: |
python -m pip install --upgrade pip wheel setuptools setuptools-scm
python -m pip install flake8 pytest-cov mypy cython
python -m pip install -r requirements-test.txt --use-pep517
- name: Lint with flake8
brew install libomp
- name: Install dependencies
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
python -m pip install --upgrade pip wheel setuptools>=77.0.3 uv
uv pip install --system -e '.[dev]' --no-build-isolation
- name: Lint with Ruff
run: ruff check .
- name: Check formatting
run: ruff format --check .
- name: Test with pytest
run: |
pytest -vs --doctest-modules --cov-fail-under=90 --cov-branch --cov=pythresh --cov-report term-missing --pyargs pythresh --continue-on-collection-errors
pytest -q -r f --doctest-modules --cov-fail-under=90 --cov-branch --cov=pythresh --cov-report=term-missing --cov-report=xml --continue-on-collection-errors
- name: Upload coverage to Codecov (partial)
uses: codecov/codecov-action@v5
uses: codecov/codecov-action@v6
with:
files: ./coverage.xml
flags: ${{ matrix.os }}-${{ matrix.python-version }}
Expand All @@ -58,7 +59,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Finalize Codecov uploads
uses: codecov/codecov-action@v5
uses: codecov/codecov-action@v6
with:
finalize: true
env:
Expand Down
99 changes: 44 additions & 55 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,64 +13,67 @@ on:

jobs:
release:
if: contains(github.event.head_commit.message, 'bump') && github.actor == 'KulikDM'
if: contains(github.event.head_commit.message, 'release') && github.actor == 'KulikDM'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
token: ${{ secrets.GIT_TOKEN }}

- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"

- name: Increment version number
- name: Install dependencies
run: |
printf "Reading the current version from the file\n"

current_version=$(grep -oP "__version__ = '\K(\d+\.\d+\.\d+)" pythresh/version.py)

if [[ -z $current_version ]]; then
current_version="0.0.0"
printf "\nIssue fetching current version $current_version\n"
exit 1
fi

printf "\nIncrementing the version number\n"
set -euo pipefail
pip install --upgrade pip setuptools wheel
pip install bump-my-version build twine

IFS='.' read -r -a version_parts <<< "$current_version"
patch=$(( ${version_parts[2]} + 1 ))
- name: Configure Git
run: |
git config --global user.name "${{ secrets.GIT_USER }}"
git config --global user.email "${{ secrets.GIT_EMAIL }}"

printf "\nHandling version part overflow\n"
- name: Bump version
run: |
set -euo pipefail

if (( patch > 9 )); then
patch=0
minor=$(( ${version_parts[1]} + 1 ))
COMMIT_MSG="${{ github.event.head_commit.message }}"
echo "Commit message: $COMMIT_MSG"

if (( minor > 9 )); then
minor=0
major=$(( ${version_parts[0]} + 1 ))
else
major=${version_parts[0]}
fi
if [[ "$COMMIT_MSG" =~ patch ]]; then
BUMP_TYPE="patch"
elif [[ "$COMMIT_MSG" =~ minor ]]; then
BUMP_TYPE="minor"
elif [[ "$COMMIT_MSG" =~ major ]]; then
BUMP_TYPE="major"
else
minor=${version_parts[1]}
major=${version_parts[0]}
echo "No bump type found, defaulting to patch."
BUMP_TYPE="patch"
fi

new_version="${major}.${minor}.$patch"
echo "Bumping version type: $BUMP_TYPE"
bump-my-version bump "$BUMP_TYPE" \
--no-tag \
--commit \
--message "Bump version: {current_version} → {new_version} [skip ci]"

printf "\nUpdating the file with the new version number\n"
- name: Push version bump
run: |
set -euo pipefail
git push --follow-tags

sed -i "s/__version__ = '${current_version}'/__version__ = '${new_version}'/" pythresh/version.py
new_version=$(PYTHONPATH=. python -c "import pythresh; print(pythresh.__version__)")

echo "new_version=$new_version" >> $GITHUB_ENV
echo "WORK_DIR=$(pwd)" >> $GITHUB_ENV

printf "\nNew version updated from $current_version to $new_version\n"

- name: Validate new PyPi version
run: |
set -euo pipefail
printf "Getting lastest pypi information\n"

url="https://pypi.org/pypi/pythresh/json"
Expand All @@ -84,50 +87,37 @@ jobs:
fi

printf "\nNew version validated\n"

- name: Commit and push changes
env:
GIT_USER: ${{ secrets.GIT_USER }}
GIT_EMAIL: ${{ secrets.GIT_EMAIL }}
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
run: |
printf "Preparing to commit\n"

git config --global user.name $GIT_USER
git config --global user.email $GIT_EMAIL
git commit -a -m "Updated to version ${{ env.new_version }}"

printf "\nPushing the changes to the repository\n"

git push origin main

printf "\nNew version commited\n"
sleep 1m

- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
set -euo pipefail
printf "Preparing to install dependancies\n"

python -m pip install --upgrade pip setuptools wheel twine build
python -m build

printf "\nPackage created locally\n"

twine check --strict dist/*

printf "\nChecks passed\n"

twine upload dist/*

printf "\nNew PyPi release created\n"
sleep 10m

- name: Validate new Conda version
run: |
set -euo pipefail
printf "Getting lastest pypi information\n"

url="https://pypi.org/pypi/pythresh/json"
latest_version=$(curl -s "$url" | jq -r '.info.version')
latest_sha256=$(curl -s "$url" | jq -r '.releases."'"$latest_version"'"[1].digests."sha256"')
latest_sha256=$(curl -s "$url" | jq -r '.releases."'"$latest_version"'"[] | select(.packagetype == "sdist") | .digests.sha256')

echo "Validating version update"

Expand All @@ -144,13 +134,11 @@ jobs:
- name: Update Conda feedstock repository
env:
GIT_USER: ${{ secrets.GIT_USER }}
GIT_EMAIL: ${{ secrets.GIT_EMAIL }}
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
run: |
set -euo pipefail
printf "Preparing to clone feedstock repository\n"

git config --global user.name $GIT_USER
git config --global user.email $GIT_EMAIL
git clone https://$GIT_USER:$GIT_TOKEN@github.com/conda-forge/pythresh-feedstock.git

cd pythresh-feedstock
Expand Down Expand Up @@ -181,6 +169,7 @@ jobs:
env:
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
run: |
set -euo pipefail
printf "Preparing to create new GitHub release\n"

cd "${{ env.WORK_DIR }}"
Expand Down
6 changes: 5 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ repos:
- id: name-tests-test
always_run: true
args: [--pytest-test-first]
exclude: ^tests/utils\.py$
- id: mixed-line-ending
args: [--fix=lf]

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.15.12
hooks:
- id: ruff
name: Fix code
args: [--exit-non-zero-on-fix, --fix, --line-length=180]
exclude: "\\.ipynb$"
name: Lint code
- id: ruff-format
name: Format code
exclude: "\\.ipynb$"
8 changes: 5 additions & 3 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ version: 2
build:
os: ubuntu-22.04
tools:
python: "3.10"
python: "3.12"
# You can also specify other tool versions:
# nodejs: "19"
# rust: "1.64"
Expand All @@ -25,5 +25,7 @@ formats:

# Optionally declare the Python requirements required to build your docs
python:
install:
- requirements: docs/requirements.txt
install:
- method: pip
path: .
extra_requirements: all, docs
20 changes: 0 additions & 20 deletions MANIFEST.in

This file was deleted.

2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @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jRINlYyOGg2WiIgZmlsbD0iI2ViZjJlZSIvPjxyZWN0IGNsYXNzPSJjbHMtMSIgZGF0YS1uYW1lPSImbHQ7VHJhbnNwYXJlbnQgUmVjdGFuZ2xlJmd0OyIgaGVpZ2h0PSIzMiIgaWQ9Il9UcmFuc3BhcmVudF9SZWN0YW5nbGVfIiB3aWR0aD0iMzIiIGZpbGw9IiNlYmYyZWUiLz48L3N2Zz4=
:alt: License
:target: https://github.com/KulikDM/pythresh/blob/master/LICENSE
:target: https://github.com/KulikDM/pythresh/blob/main/LICENSE

.. |badge_citation| image:: https://zenodo.org/badge/497683169.svg
:alt: Zenodo DOI
Expand Down
Loading
Loading