-
Notifications
You must be signed in to change notification settings - Fork 0
123 lines (106 loc) · 3.5 KB
/
build.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# Build Workflow
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: 📦 Nested Dict Tools CI build
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
python-version:
- "3.12"
# - "3.13"
os:
- ubuntu-latest
# - macos-latest
# - windows-latest
include:
- os: ubuntu-latest
path: ~/.cache/pip
# - os: macos-latest
# path: ~/Library/Caches/pip
# - os: windows-latest
# path: ~\AppData\Local\pip\Cache
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
env:
UV_SYSTEM_PYTHON: 1
steps:
- name: 🛎️ Checkout
uses: actions/checkout@v4
- name: 🐍 Install uv with caching
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
- name: 🐍 Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: 💾 Setup pip cache
uses: actions/cache@v4
with:
path: ${{ matrix.path }}
key: ${{ runner.os }}-pip-${{ hashFiles('uv.lock') }}
restore-keys: ${{ runner.os }}-pip-
- name: 📥 Install the project
run: uv sync --all-extras --dev
- name: 🏞️ Activate virtual environment
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
source .venv\\Scripts\\activate
echo PATH=$PATH >> $GITHUB_ENV
uv pip install pipx # Problems with ruff action without this
else
source .venv/bin/activate
echo PATH=$PATH >> $GITHUB_ENV
fi
- name: 🧹 Lint with ruff @astral-sh
uses: astral-sh/ruff-action@v1
continue-on-error: true
- name: 🪄 Format with ruff @astral-sh
uses: astral-sh/ruff-action@v1
with:
args: "format --diff"
continue-on-error: true
- name: 🧪 Run Pytest with doctest
env:
REPORT_OUTPUT: md_report.md
run: |
echo "REPORT_FILE=${REPORT_OUTPUT}" >> "$GITHUB_ENV"
pytest --doctest-modules --md-report --md-report-flavor gfm --md-report-output "$REPORT_OUTPUT" --cov=. # -rA
- name: 🧪 Add test output reports to the job summary
run: |
if [ -f "$REPORT_FILE" ]; then
echo "<details><summary>Test Report</summary>" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
cat "$REPORT_FILE" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "</details>" >> $GITHUB_STEP_SUMMARY
fi
- name: 📊 Upload coverage to Codecov
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: ✅ Type checking with BasedPyright
run: |
uv pip install pytest hatchling # For some reason basedpyright doesn't find those packages
basedpyright # --stats
continue-on-error: true
- name: ✅ Verify public API types with BasedPyright
run: |
uv pip install .
basedpyright --verifytypes nested_dict_tools
continue-on-error: true
- name: 🏗️ Build
run: |
pipx install hatch
hatch build