ci: Stub out CI for new python package #45
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file was initially generated by maturin v1.2.0, using: | |
# | |
# maturin generate-ci github --pytest -o ../.github/workflows/ci_python.yml | |
# | |
# TODO: | |
# - `safety` | |
# - `typeguard` | |
# - `xdoctest` | |
name: CI | |
# Only one job per-ref | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- '*' | |
pull_request: | |
branches: | |
- main | |
merge_group: | |
branches: | |
- main | |
defaults: | |
run: | |
shell: bash | |
working-directory: python | |
permissions: | |
contents: read | |
jobs: | |
# Run lint separately from the build -- it doesn't need the built Rust code. | |
# | |
# Also, only do it on one machine. | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install poetry | |
run: | | |
pipx install poetry | |
poetry config virtualenvs.create true --local | |
poetry config virtualenvs.in-project true --local | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: 3.11 | |
cache: poetry | |
- name: install deps | |
run: | | |
poetry install --only=main --only=lint | |
- name: black | |
run: | | |
poetry run black --diff pysrc pytests docs/source | |
- name: flake8 | |
run: | | |
poetry run flake8 pysrc pytests docs/source | |
- name: isort | |
run: | | |
poetry run isort --filter-files --diff pysrc pytests docs/source | |
- name: darglint | |
run: | | |
poetry run darglint pysrc | |
- name: pydocstyle | |
run: | | |
poetry run pydocstyle pysrc | |
build-wheel-macos: | |
runs-on: macos-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install poetry | |
run: | | |
pipx install poetry | |
poetry config virtualenvs.create true --local | |
poetry config virtualenvs.in-project true --local | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: | | |
3.8 | |
3.9 | |
3.10 | |
3.11 | |
architecture: x64 | |
cache: poetry | |
- name: Install Protoc | |
uses: arduino/setup-protoc@v1 | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build wheel (Mac x86_64) | |
uses: messense/maturin-action@v1 | |
with: | |
target: x86_64 | |
args: --release --out dist --sdist | |
working-directory: python | |
- name: pytest and mypy (Mac x86_64) | |
run: | | |
for V in 3.8 3.9 3.10 3.11; do | |
echo "::group::Install for Python $V" | |
poetry env use $V | |
source $(poetry env info --path)/bin/activate | |
poetry install --only=test --only=typecheck | |
pip install dist/kaskada-*.whl --force-reinstall | |
echo "::endgroup::" | |
echo "::group::Test Python $V" | |
poetry run pytest | |
echo "::endgroup::" | |
echo "::group::MyPy Python $V" | |
poetry run mypy -- --install-types --non-interactive pysrc pytests | |
echo "::endgroup::" | |
deactivate | |
done | |
- name: Build wheel (Mac universal2) | |
uses: messense/maturin-action@v1 | |
with: | |
target: universal2 | |
args: --release --out dist --sdist | |
working-directory: python | |
- name: pytest and mypy (Mac universal2) | |
run: | | |
echo "::group::Install for Python 3.11" | |
poetry env use 3.11 | |
source $(poetry env info --path)/bin/activate | |
poetry install --only=test --only=typecheck | |
pip install dist/kaskada-*universal2.whl --force-reinstall | |
echo "::endgroup::" | |
echo "::group::Test Python 3.11" | |
poetry run pytest | |
echo "::endgroup::" | |
echo "::group::MyPy Python 3.11" | |
poetry run mypy -- --install-types --non-interactive pysrc pytests | |
echo "::endgroup:: | |
deactivate | |
- name: Upload wheels | |
uses: actions/upload-artifact@v2 | |
with: | |
name: wheels | |
path: ${{ github.workspace }}/python/dist | |
build-wheel-windows: | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install poetry | |
run: | | |
pipx install poetry | |
poetry config virtualenvs.create true --local | |
poetry config virtualenvs.in-project true --local | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: 3.11 | |
architecture: x64 | |
cache: poetry | |
# - name: Install Rust toolchain | |
# uses: actions-rs/toolchain@v1 | |
# with: | |
# toolchain: stable | |
# profile: minimal | |
# default: true | |
- name: Install Protoc | |
uses: arduino/setup-protoc@v1 | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build wheels | |
uses: messense/maturin-action@v1 | |
with: | |
target: x64 | |
args: --release --out dist | |
working-directory: python | |
- name: pytest and mypy (Windows x64) | |
shell: bash | |
run: | | |
echo "::group::Install for Python 3.11" | |
ls $(poetry env info --path) | |
ls $(poetry env info --path)\\bin | |
source $(poetry env info --path)\\bin\\activate | |
poetry install --only=test --only=typecheck | |
pip install dist/kaskada-*.whl --force-reinstall | |
echo "::endgroup::" | |
echo "::group::Test Python 3.11" | |
poetry run pytest | |
echo "::endgroup::" | |
echo "::group::MyPy Python 3.11" | |
poetry run mypy -- --install-types --non-interactive pysrc pytests | |
echo "::endgroup::" | |
deactivate | |
- name: Upload wheels | |
uses: actions/upload-artifact@v2 | |
with: | |
name: wheels | |
path: ${{ github.workspace }}/python/dist | |
build-wheel-linux: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
- target: x86_64 | |
protoc_target: x86_64 | |
- target: i686 | |
protoc_target: x86_32 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install poetry | |
run: | | |
pipx install poetry | |
poetry config virtualenvs.create true --local | |
poetry config virtualenvs.in-project true --local | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: | | |
3.8 | |
3.9 | |
3.10 | |
3.11 | |
cache: poetry | |
- name: Build wheels | |
uses: messense/maturin-action@v1 | |
with: | |
target: ${{ matrix.target }} | |
manylinux: auto | |
args: --release --out dist --zig | |
working-directory: python | |
before-script-linux: | | |
set -e | |
# We need to add the protobuf-compiler since manylinux builds happen | |
# in a docker container that doesn't have it. | |
PB_REL="https://github.com/protocolbuffers/protobuf/releases" | |
curl -LO $PB_REL/download/v24.0/protoc-24.0-linux-${{ matrix.protoc_target }}.zip | |
unzip protoc-24.0-linux-${{ matrix.protoc_target }}.zip -d $HOME/.local | |
export PATH="$PATH:$HOME/.local/bin" | |
- name: pytest and mypy (Linux x86_64) | |
if: matrix.target == 'x86_64' | |
run: | | |
for V in 3.8 3.9 3.10 3.11; do | |
echo "::group::Install for Python $V" | |
poetry env use $V | |
poetry env info | |
source $(poetry env info --path)/bin/activate | |
poetry install --only=test --only=typecheck | |
pip install dist/kaskada-*.whl --force-reinstall | |
echo "::endgroup::" | |
echo "::group::Test Python $V" | |
poetry run pytest | |
echo "::endgroup::" | |
echo "::group::MyPy Python $V" | |
poetry run mypy -- --install-types --non-interactive pysrc pytests | |
echo "::endgroup::" | |
deactivate | |
done | |
- name: Upload wheels | |
uses: actions/upload-artifact@v2 | |
with: | |
name: wheels | |
path: ${{ github.workspace }}/python/dist | |
- name: Build docs | |
if: matrix.target == 'x86_64' | |
run: | | |
poetry env use 3.11 | |
source $(poetry env info --path)/bin/activate | |
poetry install --with=docs | |
sphinx-build docs/source docs/_build -j auto -W | |
deactivate | |
- name: Upload artifact | |
if: matrix.target == 'x86_64' | |
uses: actions/upload-pages-artifact@v2 | |
with: | |
# Automatically uploads an artifact from the './_site' directory by default | |
path: ${{ github.workspace }}/python/docs/_build | |
# Make the source distribution | |
sdist: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Build sdist | |
uses: PyO3/maturin-action@v1 | |
with: | |
command: sdist | |
args: --out dist | |
working-directory: python | |
- name: Upload sdist | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wheels | |
path: ${{ github.workspace }}/python/dist | |
docs-deploy: | |
# Deployment job | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment | |
permissions: | |
pages: write # to deploy to Pages | |
id-token: write # to verify the deployment originates from an appropriate source | |
if: github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
needs: [build-wheel-linux] | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v2 | |
# release: | |
# name: Release | |
# runs-on: ubuntu-latest | |
# if: "startsWith(github.ref, 'refs/tags/')" | |
# needs: [linux, windows, macos, sdist] | |
# steps: | |
# - uses: actions/download-artifact@v3 | |
# with: | |
# name: wheels | |
# - name: Publish to PyPI | |
# uses: PyO3/maturin-action@v1 | |
# env: | |
# MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} | |
# with: | |
# command: upload | |
# args: --skip-existing * | |
# working-directory: python |