[ENH] Faster and more flexible code, and code sharing for kernel test… #81
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
name: gh-ci-checks | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.type }} | |
cancel-in-progress: true | |
on: | |
pull_request: | |
paths: | |
- "**.py" | |
- pyproject.toml | |
- .github/workflows/main.yml | |
push: | |
branches: [main] | |
paths: | |
- "**.py" | |
tags: | |
- "v*.*.*" | |
workflow_dispatch: | |
jobs: | |
style: | |
timeout-minutes: 10 | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
poetry-version: [1.6.1] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Setup Python 3.9 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.9" | |
architecture: "x64" | |
- name: Install Poetry ${{ matrix.poetry-version }} | |
uses: abatilo/actions-poetry@v2.3.0 | |
with: | |
poetry-version: ${{ matrix.poetry-version }} | |
- name: Install dependencies | |
run: poetry install --only style | |
# check formatting of the code style | |
- name: Check code formatting | |
run: poetry run poe format_check | |
# this applies various linting | |
- name: Lint codebase | |
run: poetry run poe lint | |
- name: Type check | |
run: poetry run poe type_check | |
build: | |
timeout-minutes: 15 | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu, macos, windows] | |
python-version: [3.8, 3.9, "3.10"] | |
poetry-version: [1.6.1] | |
name: build ${{ matrix.os }} - py${{ matrix.python-version }} | |
runs-on: ${{ matrix.os }}-latest | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Setup Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
architecture: "x64" | |
- name: Install Poetry ${{ matrix.poetry-version }} | |
uses: abatilo/actions-poetry@v2.3.0 | |
with: | |
poetry-version: ${{ matrix.poetry-version }} | |
- name: Install from source | |
run: | | |
poetry install | |
- name: Test package install | |
run: poetry run python -c "import pywhy_stats; print(pywhy_stats.__version__)" | |
- name: Remove package install | |
run: python -m pip uninstall -yq pywhy-stats | |
- name: Check poetry lock file | |
run: poetry update --dry-run | |
- name: Build package | |
run: poetry build | |
- name: Upload package distribution files | |
if: ${{ matrix.os == 'ubuntu' && matrix.python-version == '3.10' }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: package | |
path: dist | |
# | |
# Test wheel-based Installation | |
# | |
- name: Install wheel | |
run: pip install ./dist/*.whl | |
- name: Test wheel install | |
run: python -c "import pywhy_stats; print(pywhy_stats.__version__)" | |
- name: Remove wheel install | |
run: python -m pip uninstall -yq pywhy-stats | |
# | |
# Test sdist-based Installation | |
# | |
- name: Install sdist | |
run: pip install ./dist/*.tar.gz | |
- name: Test sdist install | |
run: python -c "import pywhy_stats; print(pywhy_stats.__version__)" | |
- name: Remove sdist install | |
run: python -m pip uninstall -yq pywhy-stats | |
test: | |
timeout-minutes: 30 | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu, macos, windows] | |
python-version: [3.8, "3.10"] # oldest and newest supported versions | |
poetry-version: [1.6.1] | |
name: Unit-test ${{ matrix.os }} - py${{ matrix.python-version }} | |
runs-on: ${{ matrix.os }}-latest | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Setup Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
architecture: "x64" | |
- name: Install Poetry ${{ matrix.poetry-version }} | |
uses: abatilo/actions-poetry@v2.3.0 | |
with: | |
poetry-version: ${{ matrix.poetry-version }} | |
- name: Install packages via poetry | |
run: | | |
poetry install --with test | |
- name: Run pytest | |
run: poetry run poe unit_test | |
- name: Upload coverage stats to codecov | |
if: ${{ matrix.os == 'ubuntu' && matrix.python-version == '3.10'}} | |
uses: codecov/codecov-action@v3 | |
with: | |
files: ./coverage.xml | |
fail_ci_if_error: true | |
verbose: true | |
# release is ran when a release is made on Github | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
needs: [style, build, test] | |
if: startsWith(github.ref, 'refs/tags/') | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Setup Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
architecture: "x64" | |
- name: Install Poetry ${{ matrix.poetry-version }} | |
uses: abatilo/actions-poetry@v2.3.0 | |
with: | |
poetry-version: ${{ matrix.poetry-version }} | |
- name: Install Poetry Dynamic Versioning Plugin | |
run: pip install poetry-dynamic-versioning | |
- name: Prepare environment | |
run: | | |
echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV | |
echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | |
- name: Build the release artifact | |
run: | | |
poetry-dynamic-versioning | |
poetry build | |
- name: Download package distribution files | |
uses: actions/download-artifact@v3 | |
with: | |
name: package | |
path: dist | |
- name: Publish package to PyPI | |
run: poetry publish --username ${{ secrets.PYPI_USERNAME }} --password ${{ secrets.PYPI_PASSWORD }} | |
- name: Publish GitHub release | |
uses: softprops/action-gh-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
# body_path: ${{ github.workspace }}-RELEASE_NOTES.md | |
prerelease: ${{ contains(env.TAG, 'rc') }} | |
files: | | |
dist/* |