From 0a4279bd96f1ba93b80eac7386394e7eeecc0910 Mon Sep 17 00:00:00 2001 From: Andreas Prlic Date: Thu, 5 Sep 2024 21:45:01 -0700 Subject: [PATCH 1/9] Update python-package.yml I think we need this change to fix the deploy action --- .github/workflows/python-package.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 433340c..751842d 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -106,4 +106,5 @@ jobs: if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@release/v1 with: + user: __token__ password: ${{ secrets.PYPI_API_TOKEN }} From 0a31bb355063cd593ab3e85fbf2bf839221f2776 Mon Sep 17 00:00:00 2001 From: Andreas Prlic Date: Mon, 9 Sep 2024 22:46:05 -0700 Subject: [PATCH 2/9] feat(CI/CD): updating release workflow based on new template --- .github/workflows/python-package.yml | 139 ++++++++++++++++----------- 1 file changed, 84 insertions(+), 55 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 751842d..2eb7b6f 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] - - 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,47 +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: - user: __token__ - 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 From b25aea827bd2a042e735a16859130cd42bc33e3f Mon Sep 17 00:00:00 2001 From: Andreas Prlic Date: Mon, 9 Sep 2024 22:52:53 -0700 Subject: [PATCH 3/9] fix(ruff): fix things ruff is complaining about --- src/bioutils/normalize.py | 1 - tests/conftest.py | 1 - tests/test_seqfetcher.py | 1 - 3 files changed, 3 deletions(-) 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 27cdfbc..8914acd 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, ) From 76a7ee43ec3e0c1acc8364ce837305f5e2d413ee Mon Sep 17 00:00:00 2001 From: Andreas Prlic Date: Mon, 9 Sep 2024 22:54:23 -0700 Subject: [PATCH 4/9] fix(ruff): fix things ruff is complaining about --- docs/source/conf.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) 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"] From f55d4518663761281f4a8f431ba9aae9b8eb1b70 Mon Sep 17 00:00:00 2001 From: Andreas Prlic Date: Mon, 9 Sep 2024 23:04:20 -0700 Subject: [PATCH 5/9] fix(CICD): trying to get unit tests to run again --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 2eb7b6f..4863ee2 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -70,7 +70,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - make develop + make devready - name: Test with pytest run: | From 27174e65737bedb0035e8e20011f6d5bbd1f40c4 Mon Sep 17 00:00:00 2001 From: Andreas Prlic Date: Tue, 10 Sep 2024 20:31:12 -0700 Subject: [PATCH 6/9] fix(CICD): trying to get unit tests to run again --- .github/workflows/python-package.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 4863ee2..ee82d5c 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -35,6 +35,7 @@ jobs: run: | python -m pip install --upgrade pip pip install --use-deprecated=legacy-resolver -e .[dev] + pip install pytest - name: Lint with Ruff run: | From 6a067739407cda6b5d2de0577ec27105d8d608ce Mon Sep 17 00:00:00 2001 From: Andreas Prlic Date: Tue, 10 Sep 2024 21:17:47 -0700 Subject: [PATCH 7/9] fix(CICD): trying to get unit tests to run again --- .github/workflows/python-package.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index ee82d5c..b659172 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -34,8 +34,7 @@ jobs: - name: Install test dependencies run: | python -m pip install --upgrade pip - pip install --use-deprecated=legacy-resolver -e .[dev] - pip install pytest + pip install --use-deprecated=legacy-resolver -e .[dev,test] - name: Lint with Ruff run: | @@ -71,7 +70,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - make devready + make develop - name: Test with pytest run: | From 52fd838ddd55ebc5622554df9d77a4f63229574c Mon Sep 17 00:00:00 2001 From: Andreas Prlic Date: Tue, 10 Sep 2024 21:23:24 -0700 Subject: [PATCH 8/9] fix(CICD): trying to get unit tests to run again, making Makefile also more in sync with example repo --- Makefile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index e95df5f..a856089 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,11 @@ ${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]" + pre-commit install #=> install: install package install: From 8d7ed77b94374c1bd53d00669314f5ad825279c7 Mon Sep 17 00:00:00 2001 From: Andreas Prlic Date: Tue, 10 Sep 2024 21:24:32 -0700 Subject: [PATCH 9/9] fix(CICD): trying to get unit tests to run again --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index a856089..6451005 100644 --- a/Makefile +++ b/Makefile @@ -50,7 +50,6 @@ ${VE_DIR}: venv/%: .PHONY: develop develop: pip install -e ".[dev, test]" - pre-commit install #=> install: install package install: