Skip to content

Sc/hier shrinkage

Sc/hier shrinkage #300

Workflow file for this run

name: Python package
on:
workflow_dispatch:
push:
paths:
- "Python/**"
- "src/**"
- ".github/workflows/python.yaml"
branches:
- master
tags:
- "[0-9]+.[0-9]+.[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+-rc[1-9]+"
- "[0-9]+.[0-9]+.[0-9]+rc[1-9]+"
- "[0-9]+.[0-9]+.[0-9]+-b[1-9]+"
- "[0-9]+.[0-9]+.[0-9]+b[1-9]+"
pull_request:
paths:
- "Python/**"
- "src/**"
- ".github/workflows/python.yaml"
jobs:
build_sdist:
name: sdist build
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9
cache: pip
cache-dependency-path: Python/ci-requirements.txt
- name: Install CI dependencies
working-directory: Python/
run: pip install -r ci-requirements.txt
- name: flake8
working-directory: Python/
run: |
python3 -m flake8
- name: bandit
working-directory: Python/
run: |
python3 -m bandit -r .
- name: isort
working-directory: Python/
run: |
python3 -m isort . --diff --check --color
- name: black
working-directory: Python/
run: |
python3 -m black . --check --diff --exclude extension
- name: Build
working-directory: Python/
run: |
python -m build --sdist
# Ensure exactly one artifact was produced.
[[ $(shopt -s nullglob; ls dist/*.tar.gz | wc -w) == 1 ]] || {
echo "Unexpected content in dist dir: '$(ls dist/*.tar.gz)'."
exit 1
}
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: sdist
path: Python/dist/*.tar.gz
build_linux_wheels:
name: linux wheels build
runs-on: ubuntu-latest
permissions:
packages: read
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build wheels
uses: pypa/cibuildwheel@v2.11.2
env:
CIBW_ARCHS: x86_64
CIBW_MANYLINUX_X86_64_IMAGE: ghcr.io/forestry-labs/rforestry/python_build_env:latest
CIBW_BUILD: cp38-manylinux* cp39-manylinux* cp310-manylinux* cp311-manylinux*
CIBW_TEST_EXTRAS: test
CIBW_TEST_COMMAND: pytest /project/Python/tests --cov-report xml:/host/coverage.xml
with:
package-dir: Python/
output-dir: Python/dist
- name: Get Coverage
if: github.event_name == 'pull_request'
uses: petrovicboban/coverage@1.2
with:
coverageFile: /coverage.xml
thresholdAll: 0.60
thresholdModified: 0.60
thresholdNew: 0.60
token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: linux_wheels
path: Python/dist/*.whl
build_macos_wheels:
name: macos wheels build for ${{ matrix.config.arch }}
runs-on: macos-11
permissions:
packages: read
strategy:
fail-fast: false
matrix:
config:
- { arch: x86_64 }
- { arch: arm64 }
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Build wheels
uses: pypa/cibuildwheel@v2.11.2
env:
CIBW_ARCHS: ${{ matrix.config.arch }}
CIBW_BUILD: cp38-* cp39-* cp310-* cp311-*
CIBW_TEST_EXTRAS: test
CIBW_TEST_COMMAND: pytest work/Rforestry/Rforestry/Python/tests -v --color=yes
with:
package-dir: Python/
output-dir: Python/dist
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: macos_${{ matrix.config.arch }}_wheels
path: Python/dist/*.whl
release:
needs: [build_sdist, build_linux_wheels, build_macos_wheels]
if: github.event_name == 'push' && github.ref_type == 'tag'
runs-on: ubuntu-22.04
permissions:
contents: write
steps:
- uses: actions/download-artifact@v3
with:
name: sdist
path: packages
- uses: actions/download-artifact@v3
with:
name: linux_wheels
path: packages
- uses: actions/download-artifact@v3
with:
name: macos_x86_64_wheels
path: packages
- uses: actions/download-artifact@v3
with:
name: macos_arm64_wheels
path: packages
- name: List
run: |
ls -alh packages
- name: Extract Tag
id: tag
uses: aaronbarnaby/get-tag@v1.0.0
- name: Parse tag
id: version
uses: akshens/semver-tag@v4
with:
version: ${{ steps.tag.outputs.tag }}
- name: Publish prerelease packages to Test PyPI
if: steps.version.outputs.is-prerelease == 'true'
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
packages-dir: packages/
repository-url: https://test.pypi.org/legacy/
- name: Publish packages to PyPI
if: steps.version.outputs.is-prerelease == 'false'
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
packages-dir: packages/
- name: Create Release
uses: softprops/action-gh-release@v1
with:
generate_release_notes: true
files: |
packages/*