diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 433340c..b659172 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -1,7 +1,15 @@ +# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ name: Python package on: push: + tags: + - '[0-9]+.[0-9]+.[0-9]+' # release + - '[0-9]+.[0-9]+.[0-9]+a[0-9]+' # alpha + - '[0-9]+.[0-9]+.[0-9]+b[0-9]+' # beta + - '[0-9]+.[0-9]+.[0-9]+rc[0-9]+' # release candidate + - '[0-9]+.[0-9]+.[0-9]+.dev[0-9]+' # dev (not semver compliant) + - '[0-9]+.[0-9]+.[0-9]+.post[0-9]+' # post (not semver compliant) pull_request: jobs: @@ -9,39 +17,32 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + + - uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: zsh + version: 1.0 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: - python-version: "3.10" + python-version: "3.12" cache: pip - cache-dependency-path: '**/setup.cfg' + cache-dependency-path: '**/pyproject.yaml' - name: Install test dependencies run: | python -m pip install --upgrade pip - pip install --use-deprecated=legacy-resolver -e .[dev] + pip install --use-deprecated=legacy-resolver -e .[dev,test] - - name: Lint with flake8 + - name: Lint with Ruff 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: Format check with isort - run: | - isort --check src + ruff check . - name: Format check with Ruff run: | - ruff format --check src - - # Disable bandit until issues are resolved - # - name: Security check with bandit - # run: | - # bandit -ll -r src + ruff format --check . test: runs-on: ubuntu-latest @@ -52,10 +53,15 @@ jobs: python-version: ["3.10", "3.11", "3.12"] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + + - uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: zsh + version: 1.0 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} cache: pip @@ -64,46 +70,70 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install --use-deprecated=legacy-resolver -e .[test] + make develop - name: Test with pytest run: | make test - deploy: + - name: Upload coverage data to Codecov + run: | + # Verify integrity of codecov download + curl https://uploader.codecov.io/verification.gpg | gpg --no-default-keyring --keyring trustedkeys.gpg --import + curl -Os https://uploader.codecov.io/latest/linux/codecov + curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM + curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM.sig + gpgv codecov.SHA256SUM.sig codecov.SHA256SUM + shasum -a 256 -c codecov.SHA256SUM + # Upload coverage report + chmod +x codecov + ./codecov + + build: + name: Build distribution + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + runs-on: ubuntu-latest needs: - cqa - test + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + cache: pip + cache-dependency-path: '**/setup.cfg' + - 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 Python distribution to PyPI + needs: + - build runs-on: ubuntu-latest - + environment: + name: pypi + url: https://pypi.org/p/bioutils + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing steps: - - name: hello world - run: | - echo "::group::Environment info" - echo github.event_name = ${{ github.event_name }} - echo refs = ${{ github.ref }} - echo tags = ${{ startsWith(github.ref, 'refs/tags') }} - echo "::endgroup::" - - - uses: actions/checkout@v3 - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: "3.10" - cache: pip - cache-dependency-path: '**/setup.cfg' - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install build - - - name: Build package - run: python -m build --wheel - - - name: Publish package - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@release/v1 - with: - password: ${{ secrets.PYPI_API_TOKEN }} + - name: Download all the dists + uses: actions/download-artifact@v4 + with: + name: python-package-distributions + path: dist/ + - name: Publish distribution to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file diff --git a/Makefile b/Makefile index e95df5f..6451005 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ SHELL:=/bin/bash -e -o pipefail SELF:=$(firstword $(MAKEFILE_LIST)) PY_VERSION:=$(shell python3 --version | cut -d" " -f2 | cut -d. -f1-2) -VE_DIR:=venv/${PY_VERSION} +VE_DIR=venv $(info Using Python ${PY_VERSION}) @@ -46,10 +46,10 @@ ${VE_DIR}: venv/%: pip install --upgrade pip setuptools wheel #=> develop: install package in develop mode -.PHONY: develop install +#=> develop: install package in develop mode +.PHONY: develop develop: - @if [ -z "$${VIRTUAL_ENV}" ]; then echo "Not in a virtual environment; see README.md" 1>&2; exit 1; fi - pip install -e .[dev,test] + pip install -e ".[dev, test]" #=> install: install package install: diff --git a/docs/source/conf.py b/docs/source/conf.py index 0316f24..ffe106c 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -6,9 +6,9 @@ # -- Project information ----------------------------------------------------- -project = 'bioutils' -copyright = '2019, bioutils Contributors' -author = 'bioutils Contributors' +project = "bioutils" +copyright = "2019, bioutils Contributors" +author = "bioutils Contributors" # -- General configuration --------------------------------------------------- @@ -16,13 +16,21 @@ # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. -extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'sphinx.ext.todo', - 'sphinx.ext.autosummary', 'sphinx.ext.viewcode', 'sphinx.ext.coverage', - 'sphinx.ext.doctest', 'sphinx.ext.ifconfig', 'sphinx.ext.mathjax', - 'sphinx.ext.napoleon'] +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.intersphinx", + "sphinx.ext.todo", + "sphinx.ext.autosummary", + "sphinx.ext.viewcode", + "sphinx.ext.coverage", + "sphinx.ext.doctest", + "sphinx.ext.ifconfig", + "sphinx.ext.mathjax", + "sphinx.ext.napoleon", +] # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. @@ -35,9 +43,9 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -html_theme = 'alabaster' +html_theme = "alabaster" # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +html_static_path = ["_static"] diff --git a/src/bioutils/normalize.py b/src/bioutils/normalize.py index 2e9cff6..0e6e676 100644 --- a/src/bioutils/normalize.py +++ b/src/bioutils/normalize.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- """Provides functionality for normalizing alleles, ensuring comparable representations.""" -import copy import enum import logging import math diff --git a/tests/conftest.py b/tests/conftest.py index dd3488a..e4c0c32 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,7 +1,6 @@ import logging import os -import pytest import vcr # set vcr logging level diff --git a/tests/test_seqfetcher.py b/tests/test_seqfetcher.py index 4685408..0a2c3ea 100644 --- a/tests/test_seqfetcher.py +++ b/tests/test_seqfetcher.py @@ -6,7 +6,6 @@ from bioutils.seqfetcher import ( _add_eutils_api_key, - _fetch_seq_ensembl, _fetch_seq_ncbi, fetch_seq, )