Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into fix/mem_leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
bpinsard committed Jan 9, 2024
2 parents ae56e99 + 6c9df6f commit b6d4c3a
Show file tree
Hide file tree
Showing 13 changed files with 686 additions and 39 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Test suite

on:
push:
branches:
- master
tags:
- "*"
pull_request:
branches:
- master

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

defaults:
run:
shell: bash -el {0}

# Commented sections to be uncommented once CI is active
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python:
- ["conda", "2.7"]
- ["conda", "3.6"]
- ["conda", "3.7"]
- ["native", "3.8"]
- ["native", "3.9"]
- ["native", "3.10"]
- ["native", "3.11"]
- ["native", "3.12"]
requires: ["", "requirements.txt"]

steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }} (native)
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python[1] }}
allow-prereleases: true
if: matrix.python[0] == 'native'
- name: Set up Python ${{ matrix.python-version }} (miniconda)
uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.python[1] }}
if: matrix.python[0] == 'conda'
- name: Check environment
run: |
which python
which python3
echo $CONDA_PREFIX
echo $PATH
- name: Update pip and pytest
run: python -m pip install --upgrade pip pytest pytest-cov
- name: Install requires
run: |
python -m pip install -r ${{ matrix.requires }}
if: ${{ matrix.requires }}
- name: Install gradunwarp
run: |
python -m pip install .
- name: Test
run: pytest --pyargs gradunwarp --cov gradunwarp
working-directory: /tmp
150 changes: 150 additions & 0 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
name: Build

on:
push:
branches:
- master
tags:
- "*"
pull_request:
branches:
- master

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
# Extract metadata to allow for conditioning builds on commit messages
job_metadata:
runs-on: ubuntu-latest
outputs:
commit_message: ${{ steps.get_commit_message.outputs.commit_message }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Print head git commit message
id: get_commit_message
run: |
if [[ -z "$COMMIT_MSG" ]]; then
COMMIT_MSG=$(git show -s --format=%s $REF)
fi
echo commit_message=$COMMIT_MSG | tee -a $GITHUB_OUTPUT
env:
COMMIT_MSG: ${{ github.event.head_commit.message }}
REF: ${{ github.event.pull_request.head.sha }}

build-sdist:
name: Build sdist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Build sdist
run: pipx run build -s
- uses: actions/upload-artifact@v3
with:
name: sdist
path: ./dist/*.tar.gz

build-wheel:
# Runs on tags and commits with "[build wheels]" in the message
name: Build wheel for ${{ matrix.python }}-${{ matrix.buildplat[1] }}
needs: [job_metadata, build-sdist]
runs-on: ${{ matrix.buildplat[0] }}
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') || contains(needs.job_metadata.outputs.commit_message, '[build wheels]')
strategy:
fail-fast: false
matrix:
buildplat:
- [ubuntu-20.04, musllinux_x86_64]
- [macos-12, macosx_*]
- [windows-2019, win_amd64]
python: ["cp38", "cp39", "cp310", "cp311", "cp312"]
include:
# Manylinux builds are cheap, do all in one
- { buildplat: ["ubuntu-20.04", "manylinux_x86_64"], python: "*" }
exclude:
- buildplat: [ubuntu-20.04, musllinux_x86_64]
python: "cp38"

steps:
- uses: actions/download-artifact@v3
with:
name: sdist
path: ./dist

- uses: actions/setup-python@v3

- name: Update pip/pipx
run: pip install --upgrade pip pipx

- name: Build wheel(s)
run: pipx run cibuildwheel $( ls dist/*.tar.gz )
env:
CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat[1] }}
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_COMMAND: pytest --pyargs gradunwarp

- uses: actions/upload-artifact@v3
with:
name: ${{ matrix.python == '*' && 'all' || matrix.python }}-${{ startsWith(matrix.buildplat[1], 'macosx') && 'macosx' || matrix.buildplat[1] }}
path: ./wheelhouse/*.whl

test-sdist:
name: Test sdist
needs: [build-sdist]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
name: sdist
path: ./dist
- uses: actions/setup-python@v4
with:
python-version: 3
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install sdist
run: pip install dist/*.tar.gz
- run: python -c 'from gradunwarp.core.globals import VERSION; print(VERSION)'
- name: Install pytest
run: pip install pytest
- name: Run tests
run: pytest -v --pyargs gradunwarp

pre-publish:
runs-on: ubuntu-latest
needs: [test-sdist, build-wheel]
steps:
- uses: actions/download-artifact@v3
with:
path: dist/
- name: Check artifacts
run: ls -lR
- name: Consolidate and re-check
run: |
mv dist/*/*.{tar.gz,whl} dist
rmdir dist/*/
ls -lR
- run: pipx run twine check dist/*

publish:
runs-on: ubuntu-latest
environment: "Package deployment"
needs: [pre-publish]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v3
with:
path: dist/
- name: Consolidate artifacts
run: |
mv dist/*/*.{tar.gz,whl} dist
rmdir dist/*/
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
Loading

0 comments on commit b6d4c3a

Please sign in to comment.