Skip to content

Commit 2319430

Browse files
Packaging tidy up (#123)
* Update pre-commit config * Fix noqa typo * Add pre-commit.ci to pre-commit config * Migrate to pyproject.toml * Run Ruff safe fixes * Run Ruff unsafe fixes * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Simplify CI config We have pre-commit.ci and Ruff for this now. * Remove test variable * Add pre-commit.ci badge to README * Migrate CI to GitHub Actions * Install pytest-cov for CI --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent fc40f8c commit 2319430

25 files changed

+225
-413
lines changed

.azure-pipelines/azure-pipelines.yml

Lines changed: 0 additions & 131 deletions
This file was deleted.

.azure-pipelines/ci.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

.azure-pipelines/flake8-validation.py

Lines changed: 0 additions & 43 deletions
This file was deleted.

.azure-pipelines/syntax-validation.py

Lines changed: 0 additions & 32 deletions
This file was deleted.
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Build and Test
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
- name: Set up Python
12+
uses: actions/setup-python@v4
13+
with:
14+
python-version: 3.11
15+
- name: Install dependencies
16+
run: |
17+
python -m pip install --upgrade pip
18+
pip install build
19+
- name: Build distribution
20+
run: |
21+
python -m build
22+
pip install dist/*.whl
23+
- uses: actions/upload-artifact@v3
24+
with:
25+
path: ./dist/*
26+
27+
test:
28+
needs: build
29+
runs-on: ubuntu-latest
30+
strategy:
31+
matrix:
32+
python-version: ['3.10', '3.11', '3.12']
33+
34+
steps:
35+
- uses: actions/checkout@v3
36+
- uses: actions/download-artifact@v3
37+
with:
38+
name: artifact
39+
path: dist
40+
41+
- name: Set up Python ${{ matrix.python-version }}
42+
uses: actions/setup-python@v4
43+
with:
44+
python-version: ${{ matrix.python-version }}
45+
- name: Install dependencies
46+
run: |
47+
python -m pip install --upgrade pip
48+
pip install pytest dist/*.whl -r requirements_dev.txt pytest-md pytest-emoji pytest-cov
49+
- name: Run pytest
50+
uses: pavelzw/pytest-action@b09a85cd1831cbaae76125fcae4a1e4b137ef026 # v2.1.3
51+
with:
52+
click-to-expand: false
53+
emoji: true
54+
job-summary: true
55+
verbose: false
56+
custom-arguments: -v -ra --cov=tristan --cov-report=xml --cov-branch
57+
custom-pytest: PYTHONDEVMODE=1 pytest
58+
report-title: Test Report
59+
- name: Upload Coverage to Codecov
60+
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
61+
62+
pypi-publish:
63+
name: Upload release to PyPI
64+
needs: test
65+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
66+
runs-on: ubuntu-latest
67+
environment:
68+
name: release
69+
url: https://pypi.org/project/tristan/
70+
permissions:
71+
id-token: write
72+
steps:
73+
- uses: actions/download-artifact@v3
74+
with:
75+
name: artifact
76+
path: dist
77+
- name: Publish package distributions to PyPI
78+
uses: pypa/gh-action-pypi-publish@b7f401de30cb6434a1e19f805ff006643653240e

.pre-commit-config.yaml

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,21 @@
11
# Run 'libtbx.precommit install' to enable repository pre-commits.
2+
ci:
3+
autoupdate_schedule: quarterly
24
repos:
3-
4-
# Bring Python code up to date with pyupgrade
5+
# Bring Python code up to date with pyupgrade
56
- repo: https://github.com/asottile/pyupgrade
67
rev: v3.17.0
78
hooks:
89
- id: pyupgrade
910

10-
# Automatically sort imports with isort
11-
- repo: https://github.com/pycqa/isort
12-
rev: 5.13.2
13-
hooks:
14-
- id: isort
15-
16-
# Automatic source code formatting with Black
17-
- repo: https://github.com/psf/black
18-
rev: 24.8.0
19-
hooks:
20-
- id: black
21-
args: [--safe, --quiet]
22-
23-
# Enforce style with Flake8
24-
- repo: https://github.com/pycqa/flake8
25-
rev: 7.1.1
11+
- repo: https://github.com/astral-sh/ruff-pre-commit
12+
rev: v0.6.2
2613
hooks:
27-
- id: flake8
28-
args: [--max-line-length=88, '--select=E401,E711,E712,E713,E714,E721,E722,E901,F401,F402,F403,F405,F631,F632,F633,F811,F812,F821,F822,F841,F901,W191,W291,W292,W293,W602,W603,W604,W605,W606']
14+
- id: ruff
15+
args: [--fix, --show-fixes, --exit-non-zero-on-fix]
16+
- id: ruff-format
2917

30-
# Format YAML & TOML files prettily
18+
# Format YAML & TOML files prettily
3119
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
3220
rev: v2.14.0
3321
hooks:
@@ -36,7 +24,7 @@ repos:
3624
- id: pretty-format-toml
3725
args: [--autofix]
3826

39-
# Syntax check with pre-commit out-of-the-box hooks
27+
# Syntax check with pre-commit out-of-the-box hooks
4028
- repo: https://github.com/pre-commit/pre-commit-hooks
4129
rev: v4.6.0
4230
hooks:

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/DiamondLightSource/python-tristan/main.svg)](https://results.pre-commit.ci/latest/github/DiamondLightSource/python-tristan/main)
2+
13
# tristan
24

35
A set of prototype data processing tools for Tristan, the experimental [Timepix3-based](https://doi.org/10.1016/j.nima.2016.04.075) event-mode X-ray detector at Diamond Light Source.

0 commit comments

Comments
 (0)