Skip to content

Commit

Permalink
misc maintenance (#124)
Browse files Browse the repository at this point in the history
* misc maintenance

* ditch os.path

* fixes

* remove Makefile, add pypi trusted publishing
  • Loading branch information
sappelhoff authored Nov 23, 2024
1 parent a8a6459 commit 6500615
Show file tree
Hide file tree
Showing 15 changed files with 217 additions and 175 deletions.
82 changes: 32 additions & 50 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ Then, in your Python environment follow these steps:
```Shell
git clone https://github.com/USERNAME/pybv
cd pybv
pip install -e ".[dev]"
git fetch --tags --prune --prune-tags
python -m pip install -e ".[dev]"
pre-commit install
```

Expand All @@ -33,21 +34,15 @@ See https://pre-commit.com/ for more information.
## Running tests and coverage

If you have followed the steps to get the development version,
you can run tests by making use of the `Makefile` and
[GNU Make](https://www.gnu.org/software/make/).
you can run tests as follows.
From the project root, call:

- `make test` to run tests and coverage
- `pytest` to run tests and coverage
- `pre-commit run -a` to run style checks (Ruff and some additional hooks)

## Building the documentation

The documentation can be built using [Sphinx](https://www.sphinx-doc.org).
Again, assuming that you followed the steps to get the development version,
you can use the `Makefile`.
From the project root, call:

- `make build-doc` to build the documentation and open a browser window to view it

The publicly accessible documentation is built and hosted by
[Read the Docs](https://readthedocs.org/).
Expand All @@ -56,6 +51,9 @@ Credentials for Read the Docs are currently held by:
- [@sappelhoff](https://github.com/sappelhoff/)
- [@choldgraf](https://github.com/choldgraf/)

## Info about versioning

We follow a [semantic versioning scheme](https://semver.org/).

## Making a release on GitHub, PyPi, and Conda-Forge

Expand All @@ -67,64 +65,48 @@ and [Conda-Forge](https://anaconda.org/conda-forge/pybv).
Credentials are currently held by:

- GitHub
- Admin
- any admin of the [bids-standard GitHub organization](https://github.com/bids-standard)
- [@sappelhoff](https://github.com/sappelhoff/)
- [@choldgraf](https://github.com/choldgraf/)
- [@cbrnr](https://github.com/cbrnr/)
- Write
- [@hoechenberger](https://github.com/hoechenberger/)
- Admin
- any admin of the [bids-standard GitHub organization](https://github.com/bids-standard)
- [@sappelhoff](https://github.com/sappelhoff/)
- [@choldgraf](https://github.com/choldgraf/)
- [@cbrnr](https://github.com/cbrnr/)
- Write
- [@hoechenberger](https://github.com/hoechenberger/)
- PyPi
- Owner
- [@sappelhoff](https://github.com/sappelhoff/)
- [@choldgraf](https://github.com/choldgraf/)
- Maintainer
- [@cbrnr](https://github.com/cbrnr/)
- Owner
- [@sappelhoff](https://github.com/sappelhoff/)
- [@choldgraf](https://github.com/choldgraf/)
- Maintainer
- [@cbrnr](https://github.com/cbrnr/)
- Conda-Forge
- see: https://github.com/conda-forge/pybv-feedstock#feedstock-maintainers
- see: https://github.com/conda-forge/pybv-feedstock#feedstock-maintainers

Releasing on GitHub will automatically trigger a release on PyPi via a GitHub Action
(The credentials for PyPi are stored as "GitHub Secrets").
(see `.github/workflows/release.yml`).
A release on PyPi in turn will automatically trigger a release on Conda-Forge.
Thus, the release protocol can be briefly described as follows:
The release protocol can be briefly described as follows:

1. You will need admin rights for the `pybv` GitHub repository.
1. Go to your Python environment for `pybv`.
1. Activate your Python environment for `pybv`.
1. Make sure all tests pass and the docs are built cleanly.
1. Update the `__version__` variable in `__init__.py`:
- Remove the `.devN` suffix.
- If the version preceding the `.devN` suffix is not the version to be
released, update the version as well according to
[semantic versioning](https://semver.org/) with its `major.minor.patch`
style.
1. If applicable, append new authors to the author metadata in the `CITATION.cff` file.
1. Update `docs/changelog.rst`, renaming the "current" headline to the new
version and (if applicable) extending the "Authors" section of the document.
- "Authors" are all people who committed code or in other ways contributed
to `pybv` (e.g., by extensively reviewing PRs).
1. Commit the change and git push to `main` (or make a pull request and merge it).
1. Update `docs/changes.rst`, renaming the "current" headline to the new
version
1. Commit the change and git push to upstream `main`.
Include "REL" in your commit message.
1. Then, make an annotated tag `git tag -a -m "v1.2.3" v1.2.3 upstream/main` (This
assumes that you have a git remote configured with the name "upstream" and
pointing to https://github.com/bids-standard/pybv). Note also that the
version from `__init__.py` is preprended with a `v`: `1.2.3` --> `v1.2.3`
1. Then, make an annotated tag, for example for the version `1.2.3`:
`git tag -a -m "1.2.3" 1.2.3 upstream/main`
(This assumes that you have a git remote configured with the name "upstream" and
pointing to https://github.com/bids-standard/pybv).
**NOTE: Make sure you have your `main` branch up to date for this step!**
1. `git push --follow-tags upstream`
1. Make a [release on GitHub](https://help.github.com/en/articles/creating-releases),
using the git tag from the previous step (e.g., `v1.2.3`).
using the git tag from the previous step (e.g., `1.2.3`).
Fill the tag name into the "Release title" field, and fill the "Description" field
as you see fit.
1. This will trigger a GitHub Action that will build the package and release it to PyPi.
1. The PyPi release will trigger a release on Conda-Forge.

Then the release is done and `main` has to be prepared for development of
the next release:

1. Update the `__version__` variable in `__init__.py`:
- Bump up the `major.minor.patch` version according to
[semantic versioning](https://semver.org/) so that the version will be
the version that is planned to be released next (e.g., `1.3.0`).
- Append `.dev0` to the version (e.g., `1.3.0.dev0`).
- (if you had a version like `1.3.0.dev0` before, release `1.3.0.dev1` instead, etc.)
1. Add a "Current (unreleased)" headline to `docs/changelog.rst`.
1. Add a "Current (unreleased)" headline to `docs/changes.rst`.
1. Commit the changes and git push to `main` (or make a pull request).
2 changes: 2 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Documentation
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
version: 2
updates:
- package-ecosystem: "github-actions"
Expand Down
33 changes: 23 additions & 10 deletions .github/workflows/python_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ concurrency:

on:
push:
branches: [main]
branches: [ main ]
pull_request:
branches: [main]
branches: [ main ]
schedule:
- cron: "0 4 1 * *"
- cron: "0 4 * * MON"

jobs:
build:
Expand All @@ -19,38 +19,51 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.10", "3.11", "3.12"]
python-version: ["3.12"]
env:
TZ: Europe/Berlin
FORCE_COLOR: true
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
- name: Update pip etc.
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools wheel build
python -m pip install --upgrade setuptools wheel build twine
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Build sdist
run: python -m build --sdist
- name: Check sdist
run: twine check --strict dist/*
- name: Install sdist
run: pip install ./dist/pybv-*
run: python -m pip install ./dist/pybv-*
- name: Clean up working directory
run: rm -rf ./*
- name: Try importing pybv
run: python -c 'import pybv; print(pybv.__version__)'
- name: Remove sdist install
run: pip uninstall -y pybv
run: python -m pip uninstall -y pybv

- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Build wheel
run: python -m build --wheel
- name: Check wheel
run: twine check --strict dist/*
- name: Install wheel
run: pip install ./dist/pybv-*.whl
run: python -m pip install ./dist/pybv-*.whl
- name: Clean up working directory
run: rm -rf ./*
- name: Try importing pybv
run: python -c 'import pybv; print(pybv.__version__)'
- name: Remove wheel install
run: pip uninstall -y pybv
run: python -m pip uninstall -y pybv
31 changes: 0 additions & 31 deletions .github/workflows/python_publish.yml

This file was deleted.

35 changes: 22 additions & 13 deletions .github/workflows/python_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ concurrency:

on:
push:
branches: [main]
branches: [ main ]
pull_request:
branches: [main]
branches: [ main ]
schedule:
- cron: "0 4 1 * *"
- cron: "0 4 * * MON"


jobs:
Expand All @@ -29,29 +29,36 @@ jobs:
python-version: "3.12"
mne-version: mne-main

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

env:
TZ: Europe/Berlin
FORCE_COLOR: true

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

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

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

- uses: actions/cache@v4
with:
path: ${{ env.pythonLocation }}
key: v-0-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e .[dev]
python -m pip install -e ".[dev]"
- name: install MNE-Python main
- name: Install MNE-Python main (development version)
if: matrix.mne-version == 'mne-main'
run: |
pip install -U https://github.com/mne-tools/mne-python/archive/refs/heads/main.zip
python -m pip install -U https://github.com/mne-tools/mne-python/archive/refs/heads/main.zip
- name: Display versions and environment information
run: |
Expand All @@ -62,17 +69,19 @@ jobs:
mne sys_info
- name: Check formatting
if: matrix.platform == 'ubuntu-latest'
run: |
make check-manifest
check-manifest
pre-commit run --all-files
- name: Test with pytest
run: |
make test
# Options defined in pyproject.toml
run: pytest

- name: Build docs
run: |
make build-doc
make -C docs/ clean
make -C docs/ html
- name: Upload artifacts
if: ${{ matrix.platform == 'ubuntu-latest' && matrix.python-version == '3.12' && matrix.mne-version == 'mne-stable'}}
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Upload a Python Package using Twine when a release is created

name: release
on: # yamllint disable-line rule:truthy
release:
types: [published]
push:
branches:
- main
pull_request:
branches:
- main

permissions:
contents: read

jobs:
package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools wheel build twine
- run: python -m build --sdist --wheel
- run: twine check --strict dist/*
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist
include-hidden-files: true

pypi-upload:
needs: package
runs-on: ubuntu-latest
if: github.event_name == 'release'
permissions:
id-token: write # for trusted publishing
environment:
name: pypi
url: https://pypi.org/p/pybv
steps:
- uses: actions/download-artifact@v4
with:
name: dist
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
if: github.event_name == 'release'
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ htmlcov/
.vscode/
.venv
.idea
.ruff_cache
*.vmrk
*.eeg
*.vhdr
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ exclude .readthedocs.yaml
exclude .git-blame-ignore-revs
exclude .pre-commit-config.yaml
exclude .gitignore
exclude Makefile
global-exclude *.pyc
Loading

0 comments on commit 6500615

Please sign in to comment.