Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update python-package.yml #68

Merged
merged 9 commits into from
Sep 11, 2024
140 changes: 85 additions & 55 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,48 @@
# 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:
cqa:
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]
korikuzma marked this conversation as resolved.
Show resolved Hide resolved

- 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
Expand All @@ -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
Expand All @@ -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
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand Down Expand Up @@ -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:
Expand Down
28 changes: 18 additions & 10 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,31 @@

# -- Project information -----------------------------------------------------

project = 'bioutils'
copyright = '2019, bioutils Contributors'
author = 'bioutils Contributors'
project = "bioutils"
copyright = "2019, bioutils Contributors"
author = "bioutils Contributors"


# -- General configuration ---------------------------------------------------

# 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.
Expand All @@ -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"]
1 change: 0 additions & 1 deletion src/bioutils/normalize.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
"""Provides functionality for normalizing alleles, ensuring comparable representations."""

import copy
import enum
import logging
import math
Expand Down
1 change: 0 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import logging
import os

import pytest
import vcr

# set vcr logging level
Expand Down
1 change: 0 additions & 1 deletion tests/test_seqfetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from bioutils.seqfetcher import (
_add_eutils_api_key,
_fetch_seq_ensembl,
_fetch_seq_ncbi,
fetch_seq,
)
Expand Down