Repository navigation
86 lines (68 loc) · 2.77 KB
/
Copy pathpython-package.yml
File metadata and controls
86 lines (68 loc) · 2.77 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
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Python package
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12", "3.13", "3.14", "3.15"]
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Install dependencies
run: uv sync --all-extras
- name: Code checks
run: uv run pre-commit run --all-files --show-diff-on-failure
- name: Check README modifications
run: |
# Get the list of changed files in the last commit
CHANGED_FILES=$(git diff --name-only HEAD^)
# Check if README.md was modified but README.py wasn't
if echo "$CHANGED_FILES" | grep -q "README.md" && ! echo "$CHANGED_FILES" | grep -q "README.py"; then
echo "ERROR: README.md was modified directly"
echo "Please make all documentation updates in README.py instead"
exit 1
fi
- name: Test with pytest
run: uv run pytest
- name: Run documentation examples
run: uv run python scripts/check_docs.py
minimum-dependencies:
name: Python 3.12 minimum dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: "3.12"
- uses: astral-sh/setup-uv@v7
- name: Build and install wheel without optional dependencies
run: |
uv build
uv venv "$RUNNER_TEMP/minimum-venv"
uv pip install --python "$RUNNER_TEMP/minimum-venv/bin/python" dist/*.whl 'typing-extensions==4.6.0'
cd "$RUNNER_TEMP"
"$RUNNER_TEMP/minimum-venv/bin/python" -c 'from expression import Some; assert Some(1).map(str) == Some("1")'
- name: Install minimum Pydantic and test dependencies
run: |
uv pip install --python "$RUNNER_TEMP/minimum-venv/bin/python" 'pydantic==2.11.0' 'typing-extensions==4.12.2' pytest pytest-asyncio hypothesis
- name: Test the installed wheel outside the checkout
run: |
mkdir "$RUNNER_TEMP/wheel-tests"
cp -r tests "$RUNNER_TEMP/wheel-tests/tests"
cp pyproject.toml "$RUNNER_TEMP/wheel-tests/pyproject.toml"
cd "$RUNNER_TEMP/wheel-tests"
"$RUNNER_TEMP/minimum-venv/bin/python" -m pytest