forked from kubeflow/model-registry
-
Notifications
You must be signed in to change notification settings - Fork 8
95 lines (94 loc) · 3.06 KB
/
python-tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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/codecov-action@v4.5.0
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