Skip to content

Commit

Permalink
Use PyPI GitHub Action to publish releases (#181)
Browse files Browse the repository at this point in the history
* Use GitHub Action to publish releases and run tests in Python version matrices
* Drop support for Python 2
* Use Ruff for formatting & linting

Closes #176
  • Loading branch information
acdha authored Oct 15, 2024
1 parent 5b77243 commit ed07624
Show file tree
Hide file tree
Showing 16 changed files with 230 additions and 417 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/pypi-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: "PyPI releases"

on: release

jobs:
build_sdist:
name: Build Python source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Build sdist
run: pipx run build --sdist

- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz

pypi-publish:
name: Upload release to PyPI
if: github.event_name == 'release' && github.event.action == 'published'
needs:
- build_sdist
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/bagit
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v3
with:
# unpacks default artifact into dist/
# if `name: artifact` is omitted, the action will create extra parent dir
name: artifact
path: dist
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
36 changes: 36 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Test

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
ruff: # https://docs.astral.sh/ruff
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: pip install --user ruff
- run: ruff check --output-format=github

test:
needs: ruff
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
pip install coverage
pip install --editable .
- name: Run test
run: python -m unittest discover
19 changes: 0 additions & 19 deletions .github/workflows/tox.yml

This file was deleted.

36 changes: 36 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
exclude: ".*test-data.*"

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.9
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-added-large-files
args: ["--maxkb=128"]
- id: check-ast
- id: check-byte-order-marker
- id: check-case-conflict
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-json
- id: check-merge-conflict
- id: check-symlinks
- id: check-xml
- id: check-yaml
args: ["--unsafe"]
- id: debug-statements
- id: detect-aws-credentials
args: ["--allow-missing-credentials"]
- id: detect-private-key
- id: end-of-file-fixer
- id: mixed-line-ending
args: ["--fix=lf"]
- id: trailing-whitespace
- id: pretty-format-json
args: ["--autofix", "--no-sort-keys", "--indent=4"]
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.6
FROM python:3.11
RUN useradd --user-group bagit-tester
RUN install -d -o bagit-tester /bagit
USER bagit-tester
Expand Down
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
prune test-data
exclude .*
exclude Dockerfile
exclude tox.ini
exclude MANIFEST.in
exclude test.py
exclude bench.py
Expand Down
12 changes: 0 additions & 12 deletions Pipfile

This file was deleted.

207 changes: 0 additions & 207 deletions Pipfile.lock

This file was deleted.

15 changes: 3 additions & 12 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ project as needed or you can install globally with:

pip install bagit

Python v2.7+ is required.
A supported version of Python 3 is required.

Command Line Usage
------------------
Expand Down Expand Up @@ -226,20 +226,11 @@ Contributing to bagit-python development
Running the tests
~~~~~~~~~~~~~~~~~

You can quickly run the tests by having setuptools install dependencies:
You can quickly run the tests using the built-in unittest framework:

::

python setup.py test

Once your code is working, you can use
`Tox <https://tox.readthedocs.io/>`__ to run the tests with every
supported version of Python which you have installed on the local
system:

::

tox
python -m unittest discover

If you have Docker installed, you can run the tests under Linux inside a
container:
Expand Down
Loading

0 comments on commit ed07624

Please sign in to comment.