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

cmake build and cross-platform github CI (test, wheels, conda) #91

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
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
11 changes: 11 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Set default behaviour to automatically normalize line endings.
* text=auto

# Force batch scripts to always use CRLF line endings so that if a repo is
# accessed in Windows via a file share from Linux, the scripts will work.
*.{cmd,[cC][mM][dD]} text eol=crlf
*.{bat,[bB][aA][tT]} text eol=crlf

# Force bash scripts to always use LF line endings so that if a repo is
# accessed in Unix via a file share from Windows, the scripts will work.
*.sh text eol=lf
91 changes: 91 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: CI

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

jobs:
build:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}
PYTHONIOENCODING: utf-8
PIP_DOWNLOAD_CACHE: ${{ github.workspace }}/../.pip_download_cache
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-latest, windows-latest]
python-version: [3.6, 3.7, 3.8, 3.9]

steps:
- name: Set git crlf/eol
run: |
git config --global core.autocrlf false
git config --global core.eol lf

- uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: true

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

- name: Set HAVE_LIBDATRIE_PKG var
if: runner.os == 'Linux'
shell: bash
env:
HAVE_LIBDATRIE_PKG: true
run: |
echo "HAVE_LIBDATRIE_PKG is ${HAVE_LIBDATRIE_PKG}"
echo "HAVE_LIBDATRIE_PKG=${HAVE_LIBDATRIE_PKG}" >> $GITHUB_ENV

- name: Install deps with apt helper action
if: runner.os == 'Linux'
uses: ryankurte/[email protected]
with:
# architectures to pass to dpkg --add-architecture
#architectures: # optional
packages: pybind11-dev libdatrie-dev

- name: Install macos deps with brew
if: runner.os == 'macOS'
run: |
brew install pybind11

- name: Prepare build environment for windows
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64

#- name: Install deps with vcpkg
#if: runner.os == 'Windows'
#run: |
#echo $VCPKG_ROOT
#vcpkg install pybind11:x64-windows
#vcpkg integrate install

- name: Add pip requirements
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions

- name: Test via pip develop
run: |
tox -e dev

- name: Build dist pkgs
run: |
tox -e deploy

- name: Test with built wheel
run: |
tox -e check
56 changes: 56 additions & 0 deletions .github/workflows/conda.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Conda

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

jobs:
build:
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, windows-2016, macos-latest]
python-version: [3.6, 3.7, 3.8, 3.9]

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

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

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: true

- name: Cache conda
uses: actions/cache@v1
with:
path: ~/conda_pkgs_dir
key: ${{matrix.os}}-conda-pkgs-${{hashFiles('**/conda.recipe/meta.yaml')}}

- name: Get conda
uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.python-version }}
channels: conda-forge
channel-priority: strict
use-only-tar-bz2: true
auto-activate-base: true

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

- name: Build
run: conda build conda.recipe

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

- name: Test
run: pytest -v
126 changes: 126 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: Release

on:
push:
# release on tag push
tags:
- '*'

env:
CIBW_TEST_COMMAND: pytest {project}/tests
CIBW_TEST_EXTRAS: test

jobs:
sdist:
name: Build sdist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true

- name: Build SDist
run: pipx run build --sdist

- name: Check metadata
run: pipx run twine check dist/*

- uses: actions/upload-artifact@v2
with:
path: dist/*.tar.gz

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

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

- uses: pypa/[email protected]
env:
CMAKE_BUILD_OVERRIDE: Release
CIBW_SKIP: cp27-*
CIBW_ARCHS_MACOS: auto universal2
CIBW_TEST_SKIP: "*universal2:arm64"
CIBW_TEST_EXTRAS: test
CIBW_TEST_COMMAND: pytest {project}/tests
CIBW_ENVIRONMENT_MACOS: MACOSX_DEPLOYMENT_TARGET=10.09
CIBW_ENVIRONMENT_WINDOWS: 'CMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake'

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

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

create_release:
needs: [cibw_wheels, sdist]
runs-on: ubuntu-20.04

steps:
- name: Get version
id: get_version
run: |
echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
echo ${{ env.VERSION }}

- uses: actions/checkout@v2
with:
fetch-depth: 0

# download all artifacts to project dir
- uses: actions/download-artifact@v2
with:
name: artifact
path: dist

- name: Display artifacts
run: |
ls -l dist/

- name: Generate changes file
uses: sarnold/gitchangelog-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN}}

- name: Create draft release
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.VERSION }}
name: Release v${{ env.VERSION }}
body_path: CHANGES.md
draft: true
prerelease: true
# uncomment below to upload wheels to github releases
files: dist/*.whl

#upload_pypi:
#needs: [cibw_wheels, sdist]
#runs-on: ubuntu-latest
## upload to PyPI on every tag starting with 'v'
#if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
## alternatively, to publish when a GitHub Release is created, use the following rule:
## if: github.event_name == 'release' && github.event.action == 'published'
#steps:
#- uses: actions/download-artifact@v2
#with:
#name: artifact
#path: dist

#- uses: pypa/gh-action-pypi-publish@master
#with:
#user: __token__
#password: ${{ secrets.pypi_password }}

38 changes: 38 additions & 0 deletions .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Smoke

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

jobs:
build:
strategy:
fail-fast: false
matrix:
platform: [windows-latest, macos-latest, ubuntu-20.04]
python-version: ["3.6", "3.7", "3.8", "3.9"]

runs-on: ${{ matrix.platform }}
env:
CMAKE_BUILD_OVERRIDE: Release

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

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

- name: Add requirements
run: python -m pip install --upgrade wheel setuptools

- name: Build and install
run: pip install --verbose .[test]

- name: Test
run: python -m pytest
17 changes: 17 additions & 0 deletions .github/workflows/wheel-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

set -euxo pipefail

EXPECTED_WHEEL_COUNT=$1

if ! [ -n $EXPECTED_WHEEL_COUNT ]; then
exit 0
fi

WHEELS=$(find . -maxdepth 3 -name \*.whl)
if [ $(echo $WHEELS | wc -w) -ne $EXPECTED_WHEEL_COUNT ]; then
echo "Error: Expected $EXPECTED_WHEEL_COUNT wheels"
exit 1
else
exit 0
fi
Loading