Skip to content

Commit

Permalink
prepare workflows to ne contributions requirements (#87)
Browse files Browse the repository at this point in the history
* Updated workflows
* Build system for cython based exts now using cibuildwheel
  • Loading branch information
o-murphy authored Aug 15, 2024
1 parent fbb1d92 commit a84d3cf
Show file tree
Hide file tree
Showing 12 changed files with 194 additions and 395 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

#github: [o-murphy] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
#patreon: o-murphy
open_collective: o-murphy # Replace with a single Open Collective username
#open_collective: o-murphy # Replace with a single Open Collective username
ko_fi: o_murphy
custom: https://www.paypal.com/donate/?hosted_button_id=45PS4KH4RNXFY
15 changes: 8 additions & 7 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
name: Mypy typing check

on: [push, pull_request]
on:
pull_request:
branches:
- '*'
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["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 }}
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e .[dev,charts]
python -m pip install pandas-stubs matplotlib-stubs
python -m pip install -e .[dev]
- name: Analysing the code with mypy
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,22 @@

name: Python package tests

on: [push, pull_request]
on:
pull_request:
branches:
- '*'
workflow_dispatch:


jobs:
build:
runs-on: ubuntu-latest
test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
os: [ ubuntu-latest, windows-latest, macos-13, macos-14 ]
python-version: ["3.9", "3.10", "3.11", "3.12"]

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -22,30 +27,34 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install build-essential -y
run: |
python -m pip install --upgrade pip
python -m pip install setuptools cython
python -m pip install -e .[dev]
- name: Check Python version and install tomli if less than 3.11
- name: Run tests in pure python mode
run: |
python_version=$(python -c "import sys; print('.'.join(map(str, sys.version_info[:2])))")
if [ $(echo "${python_version} < 3.11" | bc -l) -eq 1 ]; then
python -m pip install tomli
pytest tests --no-header --no-summary -v
if [ $? -ne 0 ]; then
echo "Pytest failed, running without capture"
pytest tests -v
else
echo "Pytest succeeded."
fi
shell: bash
if: runner.os != 'Windows'

- name: Run unittest tests in pure python mode
- name: Run tests in pure python mode on Windows
run: |
if pytest tests --no-header --no-summary -v; then
echo "Pytest succeeded."
else
echo "Pytest failed, running without capture"
# Add your additional commands here
pytest tests --no-header --no-summary -v
if %ERRORLEVEL% neq 0 (
echo Pytest failed, running without capture
pytest tests -v
fi
) else (
echo Pytest succeeded.
)
shell: cmd
if: runner.os == 'Windows'

- name: Build cython modules
run: |
Expand All @@ -55,10 +64,24 @@ jobs:
- name: Run unittest tests in binary mode
run: |
if pytest tests --no-header --no-summary -v; then
echo "Pytest succeeded."
else
pytest tests --no-header --no-summary -v
if [ $? -ne 0 ]; then
echo "Pytest failed, running without capture"
# Add your additional commands here
pytest tests --no-header --no-summary -v -s
pytest tests -v
else
echo "Pytest succeeded."
fi
shell: bash
if: runner.os != 'Windows'

- name: Run unittest tests in binary mode on Windows
run: |
pytest tests --no-header --no-summary -v
if %ERRORLEVEL% neq 0 (
echo Pytest failed, running without capture
pytest tests -v
) else (
echo Pytest succeeded.
)
shell: cmd
if: runner.os == 'Windows'
12 changes: 7 additions & 5 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
name: Pylint

on: [push, pull_request]
on:
pull_request:
branches:
- '*'
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["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 }}
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Upload Python Package to PyPI

on:
release:
types: [ published, edited ]

permissions:
contents: read

jobs:

build-deploy:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macos-13, macos-14 ]

runs-on: ${{ matrix.os }}
environment: release
permissions:
id-token: write
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install dependencies
run: |
python -m pip install build cibuildwheel twine
- name: Build pure python package
run: python -m build

- name: Build binary python package
run: |
cd py_ballisticcalc_exts
python -m build --sdist --outdir ../dist
cibuildwheel --output-dir ../dist
cd ..
- name: List ./dist
run: ls ./dist

- name: Publish package distributions to PyPI
run: |
python -m twine upload dist/* --skip-existing --verbose --non-interactive
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
51 changes: 51 additions & 0 deletions .github/workflows/pypi-test-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Upload Python Package to Test PyPI

on:
workflow_dispatch:

permissions:
contents: read

jobs:

build-deploy:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macos-13, macos-14 ]

runs-on: ${{ matrix.os }}
environment: release
permissions:
id-token: write
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install dependencies
run: |
python -m pip install build cibuildwheel twine
- name: Build pure python package
run: python -m build

- name: Build binary python package
run: |
cd py_ballisticcalc_exts
python -m build --sdist --outdir ../dist
cibuildwheel --output-dir ../dist
cd ..
- name: List ./dist
run: ls ./dist

- name: Publish package distributions to Test PyPI
run: |
python -m twine upload --repository-url https://test.pypi.org/legacy/ dist/* --skip-existing --verbose --non-interactive
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
Loading

0 comments on commit a84d3cf

Please sign in to comment.