Merge pull request #134 from tarilabs/tarilabs-20241015-sync #348
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: Python workflows | |
on: | |
push: | |
branches: | |
- "main" | |
pull_request: | |
paths-ignore: | |
- "LICENSE*" | |
- "**.gitignore" | |
- "**.md" | |
- "**.txt" | |
- ".github/ISSUE_TEMPLATE/**" | |
- ".github/dependabot.yml" | |
- "docs/**" | |
jobs: | |
tests: | |
name: ${{ matrix.session }} ${{ matrix.python }} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
python: ["3.12"] | |
session: [lint, tests, mypy, docs-build] | |
include: | |
- python: "3.9" | |
session: tests | |
- python: "3.10" | |
session: tests | |
- python: "3.11" | |
session: tests | |
env: | |
NOXSESSION: ${{ matrix.session }} | |
FORCE_COLOR: "1" | |
PRE_COMMIT_COLOR: "always" | |
steps: | |
- name: Check out the repository | |
uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python }} | |
- name: Upgrade pip | |
run: | | |
pip install --constraint=.github/workflows/constraints.txt pip | |
pip --version | |
- name: Upgrade pip in virtual environments | |
shell: python | |
run: | | |
import os | |
import pip | |
with open(os.environ["GITHUB_ENV"], mode="a") as io: | |
print(f"VIRTUALENV_PIP={pip.__version__}", file=io) | |
- name: Install Poetry | |
# use absolute path as recommended with: https://github.com/pypa/pipx/issues/1331 | |
run: | | |
pipx install --pip-args=--constraint=${{ github.workspace }}/.github/workflows/constraints.txt poetry | |
poetry --version | |
- name: Install Nox | |
run: | | |
pipx install --pip-args=--constraint=${{ github.workspace }}/.github/workflows/constraints.txt nox | |
pipx inject --pip-args=--constraint=${{ github.workspace }}/.github/workflows/constraints.txt nox nox-poetry | |
nox --version | |
- name: Run Nox | |
working-directory: clients/python | |
run: | | |
if [[ ${{ matrix.session }} == "tests" ]]; then | |
make build-mr | |
nox --python=${{ matrix.python }} -- --cov-report=xml | |
poetry build | |
elif [[ ${{ matrix.session }} == "mypy" ]]; then | |
nox --python=${{ matrix.python }} ||\ | |
echo "::error title='mypy failure'::Check the logs for more details" | |
else | |
nox --python=${{ matrix.python }} | |
fi | |
- name: Upload coverage report | |
uses: codecov/[email protected] | |
if: always() && matrix.session == 'tests' | |
with: | |
files: coverage.xml | |
fail_ci_if_error: true | |
token: ${{ secrets.CODECOV_TOKEN }} | |
- name: Upload dist | |
if: matrix.session == 'tests' && matrix.python == '3.12' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: py-dist | |
path: clients/python/dist | |
- name: Upload documentation | |
if: matrix.session == 'docs-build' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: py-docs | |
path: clients/python/docs/_build |