Skip to content

Commit 3cd4d87

Browse files
committed
Updating Distribution
Changed GitHub actions to new method of testing and releasing.
1 parent ce34671 commit 3cd4d87

File tree

10 files changed

+159
-149
lines changed

10 files changed

+159
-149
lines changed

.github/workflows/build.yml

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

.github/workflows/codecov.yml

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

.github/workflows/build_documentation.yml renamed to .github/workflows/documentation.yml

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,23 @@
1-
name: Build Documentation
1+
name: Publish Documentation
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
pull_request:
8-
branches:
9-
- main
10-
workflow_dispatch:
4+
workflow_call:
115

126
jobs:
13-
build:
14-
7+
publish-documentation:
158
runs-on: ubuntu-latest
16-
179
steps:
1810
- uses: actions/checkout@v4
11+
- uses: actions/setup-python@v5
1912
with:
20-
fetch-tags: true
21-
22-
- name: Set up Python 3.10
23-
uses: actions/setup-python@v5
24-
with:
25-
python-version: '3.10'
26-
27-
# Install dependencies
13+
python-version: '3.x'
2814
- name: Upgrade pip, install package, install requirements, build docs
2915
run: |
30-
python -m pip install --upgrade pip
31-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
16+
pip install --upgrade pip
3217
pip install .
3318
if [ -f ./docs/requirements.txt ]; then pip install -r ./docs/requirements.txt; fi
3419
pip install sphinx
3520
sphinx-build docs ./docs/_build/html/
36-
shell: bash
37-
3821
# Create an artifact of the html output.
3922
- uses: actions/upload-artifact@v1
4023
with:
@@ -49,11 +32,9 @@ jobs:
4932
git config --global user.name "${GITHUB_ACTOR}"
5033
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
5134
git clone "https://token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" --branch gh-pages --single-branch gh-pages
52-
5335
cp -r docs/_build/html/* gh-pages/
5436
cd gh-pages
5537
touch .nojekyll
56-
5738
git add .
5839
git commit -m "Update documentation." -a || true
5940
# The above command will fail if no changes were present, so we ignore
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Package and Documentation Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
release-version:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- id: parse-version
12+
name: Parse release version
13+
run: |
14+
echo "version=${RELEASE_VERSION/v/}" >> "$GITHUB_OUTPUT"
15+
env:
16+
RELEASE_VERSION: ${{ github.event.release.tag_name }}
17+
outputs:
18+
version: ${{ steps.parse-version.outputs.version }}
19+
publish-test-pypi:
20+
uses: ./.github/workflows/pypi.yml
21+
with:
22+
repository_url: https://test.pypi.org/legacy/
23+
secrets:
24+
API_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }}
25+
test-test-pypi:
26+
needs: [release-version, publish-test-pypi]
27+
uses: ./.github/workflows/tests.yml
28+
with:
29+
install_command: "python3 -m pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple messes==${{ needs.release-version.outputs.version }}"
30+
# publish-pypi:
31+
# needs: test-test-pypi
32+
# uses: ./.github/workflows/pypi.yml
33+
# with:
34+
# repository_url: https://upload.pypi.org/legacy/
35+
# secrets:
36+
# API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
37+
# test-pypi:
38+
# needs: [release-version, publish-pypi]
39+
# uses: ./.github/workflows/tests.yml
40+
# with:
41+
# install_command: "python3 -m pip install messes==${{ needs.release-version.outputs.version }}"
42+
# publish-documentation:
43+
# needs: test-pypi
44+
# uses: ./.github/workflows/documentation.yml

.github/workflows/pull_request.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Pull request
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
workflow_dispatch:
11+
12+
jobs:
13+
pull-request:
14+
uses: ./.github/workflows/tests.yml
15+
with:
16+
install_command: "python3 -m pip install -e ."

.github/workflows/pypi.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Publish package
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
repository_url:
7+
description: The URL of the PyPi distribution
8+
required: true
9+
type: string
10+
secrets:
11+
API_TOKEN:
12+
required: true
13+
14+
jobs:
15+
publish-package:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: actions/setup-python@v5
20+
with:
21+
python-version: '3.x'
22+
- name: Install dependencies
23+
run: |
24+
python3 -m pip install --upgrade pip
25+
python3 -m pip install build
26+
- name: Build package
27+
run: python3 -m build --sdist
28+
- name: Publish package to a PyPi distribution
29+
uses: pypa/gh-action-pypi-publish@release/v1
30+
with:
31+
password: ${{ secrets.API_TOKEN }}
32+
repository-url: ${{ inputs.repository_url }}

.github/workflows/tests.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Run Tests
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
install_command:
7+
description: The command for installing the package to test.
8+
required: true
9+
type: string
10+
11+
jobs:
12+
run-tests:
13+
strategy:
14+
matrix:
15+
python-version: ["3.10", "3.11", "3.12"]
16+
os: [ ubuntu-latest, windows-latest, macOS-latest ]
17+
runs-on: ${{matrix.os}}
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
- name: Install testing environment
25+
run: |
26+
python3 -m pip install --upgrade pip
27+
python3 -m pip install pytest pytest-mock pytest-cov
28+
- name: Install package
29+
uses: Wandalen/wretry.action@master
30+
with:
31+
command: ${{ inputs.install_command }}
32+
attempt_limit: 10
33+
attempt_delay: 10000
34+
- name: Run tests on package
35+
run: python3 -m pytest test --cov --cov-branch --cov-report=term-missing
36+
- name: Debug with tmate on failure
37+
if: ${{ failure() }}
38+
uses: mxschmitt/action-tmate@v3
39+
with:
40+
limit-access-to-actor: true

pyproject.toml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["setuptools", "wheel", "setuptools_scm[toml]>=6.2", "numpy>=1.22.4", "Cython>=3.0.0a11"]
2+
requires = ["setuptools", "wheel", "build", "setuptools_scm[toml]>=6.2", "numpy>=1.22.4", "Cython>=3.0.0a11"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
@@ -34,7 +34,4 @@ dependencies = {file = "requirements.txt"}
3434
messes = "messes.__main__:main"
3535

3636
[tool.setuptools_scm]
37-
write_to = "src/messes/_version.py"
38-
39-
[tool.setuptools.cmdclass]
40-
build_py = "_custom_build.build_py"
37+
write_to = "src/messes/_version.py"

setup.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# -*- coding: utf-8 -*-
2+
from setuptools import Extension, setup
3+
from Cython.Build import cythonize
4+
import numpy
5+
6+
ext_modules = [
7+
Extension(
8+
"messes.extract.cythonized_tagSheet",
9+
sources=["src/messes/extract/cythonized_tagSheet.pyx"],
10+
include_dirs=[numpy.get_include()]
11+
)
12+
]
13+
14+
setup(
15+
ext_modules = cythonize(ext_modules)
16+
)
17+
18+
19+

src/_custom_build.py

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

0 commit comments

Comments
 (0)