Repository navigation
118 lines (112 loc) · 3.78 KB
/
Copy pathtest_python.yml
File metadata and controls
118 lines (112 loc) · 3.78 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
name: Test Python package
on:
push:
branches: [main]
pull_request:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: astral-sh/setup-uv@v10.3.0
with:
python-version: "3.12"
# Run the ruff release that .pre-commit-config.yaml pins, so this job and the
# pre-commit hooks agree when pre-commit.ci updates the pin.
- name: Find the ruff version
id: ruff
run: |
version=$(grep -A1 "astral-sh/ruff-pre-commit" .pre-commit-config.yaml | sed -n "s/^ *rev: *v//p")
test -n "$version"
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: ruff check
run: uvx "ruff@${{ steps.ruff.outputs.version }}" check --output-format=github .
- name: ruff format
run: uvx "ruff@${{ steps.ruff.outputs.version }}" format --check --diff .
# 0.2.3 shipped invalid metadata that pip 24.1 and later refuse to install.
# Build the package and install it the way users do before any release.
package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: astral-sh/setup-uv@v10.3.0
with:
python-version: "3.12"
activate-environment: true
- run: uv build
- name: Check metadata
run: uvx twine check --strict dist/*
- name: Install the wheel with current pip
run: |
uv pip install "pip>=24.1"
python -m pip install dist/*.whl
python -c "import complexnn"
# Build the documentation the way Read the Docs does: install the package
# and the docs requirements. -W turns every Sphinx warning into an error.
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: astral-sh/setup-uv@v10.3.0
with:
python-version: "3.12"
- name: Build the documentation
env:
TF_CPP_MIN_LOG_LEVEL: "3"
run: >-
uv run --no-project
--with-requirements docs/requirements.txt --with-editable .
sphinx-build -W --keep-going -b html docs/source docs/build/html
test:
name: ${{ matrix.name }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: Keras 3, Python 3.11
python: "3.11"
packages: tensorflow
- name: Keras 3, Python 3.12
python: "3.12"
packages: tensorflow
- name: Keras 3, Python 3.13
python: "3.13"
packages: tensorflow
# TensorFlow 2.15 is the last release with Keras 2 by default.
- name: Keras 2 (TensorFlow 2.15), Python 3.11
python: "3.11"
packages: tensorflow==2.15.1
# Newer TensorFlow can still run Keras 2 through tf-keras.
- name: Keras 2 (tf-keras), Python 3.11
python: "3.11"
packages: tensorflow tf-keras
legacy-keras: "1"
env:
TF_USE_LEGACY_KERAS: ${{ matrix.legacy-keras }}
steps:
- uses: actions/checkout@v7
with:
# setuptools-scm needs the tags to compute the version.
fetch-depth: 0
- uses: astral-sh/setup-uv@v10.3.0
with:
python-version: ${{ matrix.python }}
activate-environment: true
- name: Install
run: uv pip install -e . pytest ${{ matrix.packages }}
- name: Versions
shell: python
run: |
from importlib import metadata
for package in ("tensorflow", "keras", "tf-keras"):
try:
print(package, metadata.version(package))
except metadata.PackageNotFoundError:
print(package, "not installed")
- name: Test
run: pytest