Skip to content

Commit ed07624

Browse files
authored
Use PyPI GitHub Action to publish releases (#181)
* 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
1 parent 5b77243 commit ed07624

16 files changed

+230
-417
lines changed

.github/workflows/pypi-release.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: "PyPI releases"
2+
3+
on: release
4+
5+
jobs:
6+
build_sdist:
7+
name: Build Python source distribution
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
12+
- name: Build sdist
13+
run: pipx run build --sdist
14+
15+
- uses: actions/upload-artifact@v3
16+
with:
17+
path: dist/*.tar.gz
18+
19+
pypi-publish:
20+
name: Upload release to PyPI
21+
if: github.event_name == 'release' && github.event.action == 'published'
22+
needs:
23+
- build_sdist
24+
runs-on: ubuntu-latest
25+
environment:
26+
name: pypi
27+
url: https://pypi.org/p/bagit
28+
permissions:
29+
id-token: write
30+
steps:
31+
- uses: actions/download-artifact@v3
32+
with:
33+
# unpacks default artifact into dist/
34+
# if `name: artifact` is omitted, the action will create extra parent dir
35+
name: artifact
36+
path: dist
37+
- name: Publish package distributions to PyPI
38+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/test.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
jobs:
10+
ruff: # https://docs.astral.sh/ruff
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- run: pip install --user ruff
15+
- run: ruff check --output-format=github
16+
17+
test:
18+
needs: ruff
19+
runs-on: ubuntu-latest
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
24+
steps:
25+
- uses: actions/checkout@v4
26+
- name: Set up Python ${{ matrix.python-version }}
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: ${{ matrix.python-version }}
30+
- name: Install dependencies
31+
run: |
32+
python -m pip install --upgrade pip setuptools wheel
33+
pip install coverage
34+
pip install --editable .
35+
- name: Run test
36+
run: python -m unittest discover

.github/workflows/tox.yml

-19
This file was deleted.

.pre-commit-config.yaml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
exclude: ".*test-data.*"
2+
3+
repos:
4+
- repo: https://github.com/astral-sh/ruff-pre-commit
5+
rev: v0.6.9
6+
hooks:
7+
- id: ruff
8+
args: [--fix, --exit-non-zero-on-fix]
9+
- id: ruff-format
10+
11+
- repo: https://github.com/pre-commit/pre-commit-hooks
12+
rev: v5.0.0
13+
hooks:
14+
- id: check-added-large-files
15+
args: ["--maxkb=128"]
16+
- id: check-ast
17+
- id: check-byte-order-marker
18+
- id: check-case-conflict
19+
- id: check-docstring-first
20+
- id: check-executables-have-shebangs
21+
- id: check-json
22+
- id: check-merge-conflict
23+
- id: check-symlinks
24+
- id: check-xml
25+
- id: check-yaml
26+
args: ["--unsafe"]
27+
- id: debug-statements
28+
- id: detect-aws-credentials
29+
args: ["--allow-missing-credentials"]
30+
- id: detect-private-key
31+
- id: end-of-file-fixer
32+
- id: mixed-line-ending
33+
args: ["--fix=lf"]
34+
- id: trailing-whitespace
35+
- id: pretty-format-json
36+
args: ["--autofix", "--no-sort-keys", "--indent=4"]

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.6
1+
FROM python:3.11
22
RUN useradd --user-group bagit-tester
33
RUN install -d -o bagit-tester /bagit
44
USER bagit-tester

MANIFEST.in

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
prune test-data
22
exclude .*
33
exclude Dockerfile
4-
exclude tox.ini
54
exclude MANIFEST.in
65
exclude test.py
76
exclude bench.py

Pipfile

-12
This file was deleted.

Pipfile.lock

-207
This file was deleted.

README.rst

+3-12
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ project as needed or you can install globally with:
1616

1717
pip install bagit
1818

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

2121
Command Line Usage
2222
------------------
@@ -226,20 +226,11 @@ Contributing to bagit-python development
226226
Running the tests
227227
~~~~~~~~~~~~~~~~~
228228

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

231231
::
232232

233-
python setup.py test
234-
235-
Once your code is working, you can use
236-
`Tox <https://tox.readthedocs.io/>`__ to run the tests with every
237-
supported version of Python which you have installed on the local
238-
system:
239-
240-
::
241-
242-
tox
233+
python -m unittest discover
243234

244235
If you have Docker installed, you can run the tests under Linux inside a
245236
container:

0 commit comments

Comments
 (0)