Skip to content

feat: refactor integration pipeline and add poetry-dynamic-versioning support #2

feat: refactor integration pipeline and add poetry-dynamic-versioning support

feat: refactor integration pipeline and add poetry-dynamic-versioning support #2

Workflow file for this run

name: CI
on:
pull_request:
push:
branches: [main]
tags: ["*"]
workflow_dispatch:
inputs:
pytest_addopts:
description: Extra options for pytest; use -vv for full details; see
https://docs.pytest.org/en/latest/example/simple.html#how-to-change-command-line-options-defaults
required: false
default: ""
env:
LANG: "en_US.utf-8"
LC_ALL: "en_US.utf-8"
PIP_CACHE_DIR: ${{ github.workspace }}/.cache/pip
POETRY_CACHE_DIR: ${{ github.workspace }}/.cache/pypoetry
POETRY_VIRTUALENVS_IN_PROJECT: "true"
PRE_COMMIT_HOME: ${{ github.workspace }}/.cache/pre-commit
PYTEST_ADDOPTS: ${{ github.event.inputs.pytest_addopts }}
PYTHONIOENCODING: "UTF-8"
TARGET_PYTHON_VERSION: "3.9"
jobs:
build:
strategy:
fail-fast: false
matrix:
os:
- macos-latest
- ubuntu-latest
python-version: ["3.8", "3.9", "3.10", "3.11"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Needs all tags to compute dynamic version
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Generate Cache Key PY
shell: bash
run:
echo "PY=$((python -VV; pip freeze) | sha256sum | cut -d' ' -f1)" >>
$GITHUB_ENV
- name: Cache venv
uses: actions/cache@v3
with:
path: |
.cache
.venv
key:
cache|${{ runner.os }}|${{ env.PY }}|${{ hashFiles('pyproject.toml') }}|${{
hashFiles('poetry.lock') }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Install dependencies
run: |
python -m pip install poetry poetry-dynamic-versioning
poetry install --with dev,docs --all-extras -v --no-interaction
- name: Run pytest
run: poetry run pytest --cov=./ --cov-report=xml
- name: Upload coverage to Codecov
continue-on-error: true
if: matrix.os == 'ubuntu-latest' && matrix.python-version == ${{ env.TARGET_PYTHON_VERSION }}
uses: codecov/codecov-action@v3
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}
with:
file: ./coverage.xml
files: ./coverage1.xml,./coverage2.xml
directory: ./coverage/reports/
env_vars: OS,PYTHON
fail_ci_if_error: true
flags: unittests
name: pycytominer
pre-commit-ci:
name: Run pre-commit checks on changed files
strategy:
fail-fast: false
runs-on: ubuntu-latest
steps:
- name: Checkout repo with all branches and tags
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ env.TARGET_PYTHON_VERSION }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.TARGET_PYTHON_VERSION }}
- name: Run pre-commit checks on any files changed between base_ref and HEAD
uses: pre-commit/[email protected]
with:
extra_args: --from-ref origin/${{github.base_ref}} --to-ref HEAD