Skip to content

Commit

Permalink
CI Upgrade (#11)
Browse files Browse the repository at this point in the history
* Removed broken zenodo for now

* bump version to 0.2.0

* bump version to 0.1.3

* Codecov v4

* lsbi continuous integration copied across

* Updated documentation

* Added double-check for previously different formatted version
  • Loading branch information
williamjameshandley authored Apr 9, 2024
1 parent ce1aa5b commit 0d54adb
Show file tree
Hide file tree
Showing 21 changed files with 389 additions and 653 deletions.
84 changes: 0 additions & 84 deletions .github/workflows/CI.yaml

This file was deleted.

131 changes: 107 additions & 24 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
name: Build and push to PyPI on merging to master
name: Build
on:
push:
branches:
- master
jobs:
git-tag-and-release:
get-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.step1.outputs.v }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Get version number
run: |
VERSION="$(grep ':Version:' README.rst | awk '{print $2}')"
echo "DIST_VERSION=v${VERSION}" >> $GITHUB_ENV
id: step1
run: echo "v=$(grep ':Version:' README.rst | awk '{print $2}')" >> $GITHUB_OUTPUT

git-tag-and-release:
runs-on: ubuntu-latest
needs: get-version
steps:
- uses: actions/checkout@v4
- name: set version number
run: echo "DIST_VERSION=v${{ needs.get-version.outputs.version }}" >> $GITHUB_ENV
- name: Create Tag
uses: actions/github-script@v6
with:
Expand All @@ -34,11 +43,11 @@ jobs:
pypi-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: '3.9'
- name: Install pypa/build
run: python -m pip install build --user
- name: Build a binary wheel and a source tarball
Expand All @@ -48,32 +57,35 @@ jobs:
with:
password: ${{ secrets.PYPI_API_TOKEN }}

pypi-public:
needs:
- get-version
- pypi-release
runs-on: ubuntu-latest
steps:
- name: Wait for PyPi
uses: nev7n/wait_for_response@v1
with:
url: "https://files.pythonhosted.org/packages/source/u/unimpeded/unimpeded-${{ needs.get-version.outputs.version }}.tar.gz"
responseCode: 200
timeout: 600000
interval: 10000

aur-release:
needs: pypi-release
needs: pypi-public
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: '3.9'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tomli
- name: Generate PKGBUILD
run: python ./bin/gen_PKGBUILD.py > ./PKGBUILD
- name: Get version number
run: |
VERSION="$(cat ./PKGBUILD | grep pkgver= | awk -F= '{print $2}')"
echo "DIST_VERSION=${VERSION}" >> $GITHUB_ENV
- name: Wait for PyPi
uses: nev7n/wait_for_response@v1
with:
url: "https://files.pythonhosted.org/packages/source/u/unimpeded/unimpeded-${{ env.DIST_VERSION }}.tar.gz"
responseCode: 200
timeout: 600000
interval: 10000
- name: Publish AUR package
uses: KSXGitHub/[email protected]
with:
Expand All @@ -83,3 +95,74 @@ jobs:
commit_username: ${{ secrets.AUR_USERNAME }}
commit_email: ${{ secrets.AUR_EMAIL }}
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}

conda-release:
needs: pypi-public
name: Build and deploy to conda
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Conda environment creation and activation
uses: conda-incubator/setup-miniconda@v2
with:
python-version: '3.9'
auto-update-conda: false
auto-activate-base: false
show-channel-urls: true
- name: install dependencies
shell: bash -el {0}
run: conda install grayskull conda-build anaconda-client
- name: Generate meta.yaml from grayskull
shell: bash -el {0}
run: grayskull pypi --strict-conda-forge unimpeded
- name: Build and upload the conda packages
uses: uibcdf/[email protected]
with:
meta_yaml_dir: unimpeded
python-version: '3.9'
user: handley-lab
label: 'main'
token: ${{ secrets.ANACONDA_TOKEN }} # Replace with the right name of your secret

conda-build:
needs:
- conda-release
- get-version
name: test installation from conda
runs-on: ubuntu-latest
steps:
- name: Conda environment creation and activation
uses: conda-incubator/setup-miniconda@v2
with:
python-version: '3.9'
auto-update-conda: false
auto-activate-base: false
show-channel-urls: true
- name: install from conda
shell: bash -el {0}
run: conda install -c handley-lab unimpeded
- name: get install version
shell: bash -el {0}
run: echo "install_version=$(python -c 'import unimpeded; print(unimpeded.__version__)')" >> $GITHUB_ENV
- name: fail if versions not matching
if: ${{ env.install_version != needs.get-version.outputs.version }}
run: exit 1

pypi-build:
needs:
- pypi-public
- get-version
name: test installation from pypi
runs-on: ubuntu-latest
steps:
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install from pypi
run: pip install unimpeded
- name: get install version
run: echo "install_version=$(python -c 'import unimpeded; print(unimpeded.__version__)')" >> $GITHUB_ENV
- name: fail if versions not matching
if: ${{ env.install_version != needs.get-version.outputs.version }}
run: exit 1
49 changes: 49 additions & 0 deletions .github/workflows/code_style.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Code style

on:
push:
branches: [master]
pull_request:
branches: [master]
schedule:
- cron: "0 0 * * *"

jobs:
black:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
- name: Install black
run: pip install black
- name: Run black
run: black . --check

isort:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
- name: Install isort
run: pip install isort
- name: Run isort
run: isort . --check-only

pydocstyle:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
- name: Install pydocstyle
run: pip install pydocstyle
- name: run pydocstyle
run: python -m pydocstyle --convention=numpy anesthetic
58 changes: 58 additions & 0 deletions .github/workflows/pr_checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: PR checks

on:
pull_request:
branches: [master]

jobs:
version-is-unit-incremented:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
- name: Upgrade pip and install linters
run: |
python -m pip install --upgrade pip
python -m pip install packaging
- name: Check version number
run: python ./bin/check_version.py

sphinx:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
- name: Upgrade pip and install doc requirements
run: pip install -e ".[all,docs]"
- name: build documentation
run: |
cd docs
make clean
make html SPHINXOPTS="-W --keep-going -n"
test-pypi-release:
name: Build and deploy to test PyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
- name: Install pypa/build
run: pip install build --user
- name: Build a binary wheel and a source tarball
run: python -m build --sdist --wheel --outdir dist/
- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
continue-on-error: true
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
skip-existing: true
29 changes: 29 additions & 0 deletions .github/workflows/unittests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Unit tests

on:
push:
branches: [master]
pull_request:
branches: [master]
schedule:
- cron: "0 0 * * *"

jobs:
pip:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
- name: Install dependencies
run: pip install -e ".[test]"

- name: Test with pytest
run: pytest --cov=unimpeded tests

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
Loading

0 comments on commit 0d54adb

Please sign in to comment.