-
Notifications
You must be signed in to change notification settings - Fork 62
154 lines (144 loc) · 5.43 KB
/
Copy pathpython-package.yml
File metadata and controls
154 lines (144 loc) · 5.43 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# 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:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Python 3.14
uses: actions/setup-python@v6
with:
python-version: "3.14"
cache: "pip"
- name: Install ruff
# Keep this version aligned with the ruff-pre-commit revision.
run: pip install ruff==0.16.1
- name: Lint with ruff
run: |
ruff check . --output-format=github
ruff format --check .
complexity:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
# wily needs history to compare against the base; the gate itself
# only needs the working tree.
fetch-depth: 0
- name: Set up Python 3.14
uses: actions/setup-python@v6
with:
python-version: "3.14"
cache: "pip"
- name: Install metrics tooling
# Versions pinned in the [metrics] extra so CI and the local
# pre-commit hook grade identically.
run: pip install -e .[metrics]
- name: Complexity gate
# Ratchet, not an aspiration: these are the tightest thresholds the
# package currently passes. A change that regresses complexity fails
# here with the offending block named. Mirrors the xenon pre-commit
# hook, so a contributor sees the same verdict before pushing.
run: xenon --max-absolute C --max-modules B --max-average A dataretrieval
- name: Complexity trend vs base
# Advisory: reports which files moved and by how much, so a reviewer
# can see direction rather than a pass/fail. Never fails the build --
# the gate above is what blocks.
if: github.event_name == 'pull_request'
continue-on-error: true
run: |
base="${{ github.event.pull_request.base.sha }}"
git fetch --quiet origin "$base" || true
wily build dataretrieval --max-revisions 40 >/dev/null 2>&1 || true
echo '### Complexity trend' >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
wily diff dataretrieval --revision "$base" 2>&1 | tail -40 \
>> "$GITHUB_STEP_SUMMARY" || echo 'no comparable revision' \
>> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
package-artifact:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Python 3.13
uses: actions/setup-python@v6
with:
python-version: "3.13"
cache: "pip"
- name: Build wheel
run: |
python -m pip install --upgrade pip
python -m pip wheel --no-deps --wheel-dir wheelhouse .
- name: Smoke test installed wheel outside the checkout
run: |
venv="$RUNNER_TEMP/dataretrieval-wheel-smoke"
python -m venv "$venv"
"$venv/bin/python" -m pip install "$GITHUB_WORKSPACE"/wheelhouse/*.whl
cd "$RUNNER_TEMP"
"$venv/bin/python" -I - <<'PY'
import os
from importlib.resources import files
from pathlib import Path
import dataretrieval
import dataretrieval.transport
from dataretrieval import ngwmn, waterdata, wateruse
from dataretrieval.ogc import engine
checkout = Path(os.environ["GITHUB_WORKSPACE"]).resolve()
installed = Path(dataretrieval.__file__).resolve()
assert not installed.is_relative_to(checkout), (installed, checkout)
assert files("dataretrieval").joinpath("py.typed").is_file()
assert waterdata.get_daily
assert ngwmn.get_sites
assert wateruse.get_wateruse
assert engine.get_ogc_data
PY
type-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Python 3.13
uses: actions/setup-python@v6
with:
python-version: "3.13"
cache: "pip"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[type-check]
- name: Type-check with mypy
run: mypy
test:
needs: lint
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.10", "3.13", "3.14"]
steps:
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[test,nldi]
- name: Test with pytest and report coverage
# Pinned to bash on every OS. The default Windows shell is PowerShell,
# which does not stop on a failing native command and takes the step's
# exit code from the last one -- so a pytest failure was masked by the
# coverage report that followed it, and the Windows matrix reported
# success while tests were red.
shell: bash
run: |
coverage run -m pytest tests/
coverage report -m