Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build wheels and publish to PyPi on release via GitHub-Actions #16

Merged
merged 6 commits into from
Jan 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions .github/workflows/build-wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Build and publish wheels

on:
pull_request:
branches: [ master ]
release:
types: [ prereleased, released ]

jobs:
build_manylinux_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v2

- name: Build wheels
uses: pypa/cibuildwheel@v2.3.1
env:
CIBW_BEFORE_ALL_LINUX: "yum install -y boost boost-thread boost-devel && python -m pip install --upgrade pip"
CIBW_ARCHS_LINUX: "auto64"
CIBW_SKIP: "*-musllinux_* cp36-*"
### At the moment, CIBW_TEST seems to not work (the gh-action just hangs with no output at all). Keeping this here
### in case we figure it out later.
# # Install pytest before running CIBW_TEST_COMMAND
# CIBW_TEST_REQUIRES: pytest
# CIBW_TEST_COMMAND: >
# # Run c++ unit tests
# make -C test runtests
# # Run python unit tests, but ignore googletest library
# pytest -m "not random" --ignore=test/googletest-1.8.1/

- uses: actions/upload-artifact@v2
with:
name: confseq_manylinux_wheels
path: ./wheelhouse/*.whl

build_macos_dist:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [macos-latest]
python-version: ["3.7", "3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install boost dependency
run: |
brew install boost

- name: Build and upload macOS wheels
run: |
python -m pip install build
python -m build

- uses: actions/upload-artifact@v2
with:
name: confseq_macos_dist
path: ./dist/confseq-*

publish:
name: Publish Python distributions to PyPI and TestPyPI
needs: [build_manylinux_wheels, build_macos_dist]
runs-on: ubuntu-latest

steps:
- name: Download confseq_macos_dist artifact
uses: actions/download-artifact@v2
with:
name: confseq_macos_dist
path: dist
- name: Download confsesq_manylinux_wheels artifact
uses: actions/download-artifact@v2
with:
name: confseq_manylinux_wheels
path: dist
- name: Publish distribution to Test PyPI
if: github.event_name == 'release' && github.event.action == 'prereleased'
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
- name: Publish distribution to PyPI
if: github.event_name == 'release' && github.event.action == 'released' && github.repository_owner == 'gostevehoward'
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_TOKEN }}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# This workflow will install boost dependencies, lint, run unit tests, and build wheels with a variety of OS/Python configurations.
# This workflow will install boost dependencies, lint, and run unit tests for the latest Ubuntu/macOS on Python 3.7--3.10.
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python package
name: Install, lint, and test Python package

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
push:
branches: [ master ]

jobs:
build:
Expand All @@ -25,7 +25,8 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies

- name: Install boost
run: |
# Install boost library to OS
if [ "$RUNNER_OS" == "Linux" ]; then
Expand All @@ -34,28 +35,24 @@ jobs:
elif [ "$RUNNER_OS" == "macOS" ]; then
brew install boost
fi
python -m pip install --upgrade pip
python -m pip install flake8 pytest build

- name: Install confseq package
run: |
pip install ./
python -m pip install --upgrade pip
python -m pip install ./

- name: Lint with flake8
run: |
python -m pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude test/googletest-*
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude test/googletest-*

- name: Run unit tests
run: |
python -m pip install pytest
# Run c++ unit tests
make -C test runtests
# Run python unit tests, but ignore googletest library
pytest -m "not random" --ignore=test/googletest-1.8.1/
- name: Build and upload wheels
run: |
python -m build

- uses: actions/upload-artifact@v2
with:
name: confseq_dist
path: ./dist/confseq-*
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.15...3.19)

project(confseq VERSION "0.0.7")
project(confseq VERSION "0.0.8")

# specify the C++ standard
set(CMAKE_CXX_STANDARD 14)
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ build-backend = "setuptools.build_meta"
markers = [
"random: marks tests as random (deselect with '-m \"not random\"')"
]

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from setuptools import find_packages

__version__ = '0.0.7'
__version__ = '0.0.8'

with open("README.md", "r") as fh:
long_description = fh.read()
Expand Down