Skip to content

Commit

Permalink
Merge branch 'main' into format
Browse files Browse the repository at this point in the history
  • Loading branch information
jsstevenson authored Sep 11, 2024
2 parents 4031383 + 6ccb466 commit 22dd4b0
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 67 deletions.
142 changes: 86 additions & 56 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -1,61 +1,67 @@
# 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]
- 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

strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10"]
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
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ authors = [
description = "miscellaneous simple bioinformatics utilities and lookup tables"
readme = "README.rst"
license = { file="LICENSE.txt" }
requires-python = ">=3.8"
requires-python = ">=3.10"
classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Topic :: Scientific/Engineering :: Bio-Informatics",
Expand Down
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
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py39,py310
envlist = py310,py311,py312
isolated_build = True

[testenv]
Expand Down

0 comments on commit 22dd4b0

Please sign in to comment.