Skip to content

Commit

Permalink
WIP: python build CI/CD actions
Browse files Browse the repository at this point in the history
  • Loading branch information
jcschaff committed Jun 2, 2024
1 parent aa023e1 commit b2feff6
Show file tree
Hide file tree
Showing 4 changed files with 234 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/conda.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Conda

on:
workflow_dispatch:
push:
branches:
- master
pull_request:

jobs:
build:
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-13, macos-14, windows-latest]
python-version: ["3.8", "3.11"]

runs-on: ${{ matrix.platform }}

# The setup-miniconda action needs this to activate miniconda
defaults:
run:
shell: "bash -l {0}"

steps:
- uses: actions/checkout@v4

- name: Get conda
uses: conda-incubator/[email protected]
with:
python-version: ${{ matrix.python-version }}
channels: conda-forge

- name: Prepare
run: conda install conda-build conda-verify pytest

- name: Build
run: conda build conda.recipe

- name: Install
run: conda install -c ${CONDA_PREFIX}/conda-bld/ pyvcell_fvsolver

- name: Test
run: pytest tests
60 changes: 60 additions & 0 deletions .github/workflows/enscripten.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: WASM

on:
workflow_dispatch:
pull_request:
branches:
- master

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

jobs:
build-wasm-emscripten:
name: Pyodide
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0

- uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install pyodide-build
run: pip install pyodide-build==0.23.4

- name: Compute emsdk version
id: compute-emsdk-version
run: |
pyodide xbuildenv install --download
EMSCRIPTEN_VERSION=$(pyodide config get emscripten_version)
echo "emsdk-version=$EMSCRIPTEN_VERSION" >> $GITHUB_OUTPUT
- uses: mymindstorm/setup-emsdk@v14
with:
version: ${{ steps.compute-emsdk-version.outputs.emsdk-version }}
actions-cache-folder: emsdk-cache

# A future version of pyodide may switch to -fwasm-exceptions
- name: Build
run: CFLAGS=-fexceptions LDFLAGS=-fexceptions pyodide build

- uses: actions/upload-artifact@v4
with:
path: dist/*.whl

- uses: actions/setup-node@v4
with:
node-version: 18

- name: Set up Pyodide virtual environment
run: |
pyodide venv .venv-pyodide
.venv-pyodide/bin/pip install $(echo -n dist/*.whl)[test]
- name: Test
run: .venv-pyodide/bin/pytest
31 changes: 31 additions & 0 deletions .github/workflows/pip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: "Pip"

on:
workflow_dispatch:
pull_request:
push:
branches:
- master

jobs:
build:
name: Build with Pip
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
platform: [windows-latest, macos-13, ubuntu-latest]
python-version: ["3.7", "3.12", "pypy-3.9"]

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Build and install
run: pip install --verbose ./pyvcell-fvsolver

- name: Test
run: pytest
99 changes: 99 additions & 0 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Wheels

on:
workflow_dispatch:
pull_request:
push:
branches:
- master
release:
types:
- published

env:
FORCE_COLOR: 3

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

jobs:
build_sdist:
name: Build SDist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Build SDist
working-directory: pyvcell-fvsolver
run: pipx run build --sdist

- name: Check metadata
working-directory: pyvcell-fvsolver
run: pipx run twine check dist/*

- name: artifact upload
uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/*.tar.gz
working-directory: pyvcell-fvsolver


build_wheels:
name: Wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-13, macos-14, windows-latest]

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: build wheel
uses: pypa/[email protected]
with:
working-directory: pyvcell-fvsolver
env:
CIBW_ARCHS_MACOS: universal2
CIBW_ARCHS_WINDOWS: auto ARM64

- name: Verify clean directory
working-directory: pyvcell-fvsolver
run: git diff --exit-code
shell: bash

- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}
working-directory: pyvcell-fvsolver
path: wheelhouse/*.whl


upload_all:
name: Upload if release
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
environment: pypi
permissions:
id-token: write

steps:
- uses: actions/setup-python@v5
with:
python-version: "3.x"

- uses: actions/download-artifact@v4
with:
working-directory: pyvcell-fvsolver
pattern: cibw-*
merge-multiple: true
path: dist

- uses: pypa/gh-action-pypi-publish@release/v1

0 comments on commit b2feff6

Please sign in to comment.