-
Notifications
You must be signed in to change notification settings - Fork 58
166 lines (160 loc) · 6.14 KB
/
Copy pathbuild-and-test.yml
File metadata and controls
166 lines (160 loc) · 6.14 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
155
156
157
158
159
160
161
162
163
164
165
166
name: Build and Test Workflow
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
# midnight EST
- cron: '0 5 * * *'
# allow this to be scheduled manually in addition to cron
workflow_dispatch:
permissions:
contents: read
jobs:
tests:
# Default matrix: bare-import balance on every OS / python combination —
# the regression guard against accidentally hard-depending on diff-diff.
# `extras='did'` permutations are layered in via the `include:` block
# below so the `diff-diff-pin` axis only multiplies jobs for the `did`
# arm (avoids the earlier mistake where two `extras: ''` excludes
# silently removed every bare-import job).
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14']
extras: ['']
diff-diff-pin: ['']
include:
# diff-diff [did] integration coverage. Restricted to ubuntu-latest
# AND a single Python version (3.12) to keep the matrix small (2
# jobs total: one min-pin, one resolved-latest). diff-diff is a
# pure-Python adapter dependency, so multi-Python coverage adds
# very little signal -- the bare-import balance matrix above
# already exercises 3.9 - 3.14 across all three OSes. The weekly
# canary in diff-diff-canary.yml additionally tests against the
# absolute latest PyPI release (no pin) on 3.12. If you need
# macOS/Windows or other-Python coverage of the [did] arm, add
# explicit matrix entries here rather than relying on the canary.
- os: ubuntu-latest
python-version: '3.12'
extras: 'did'
diff-diff-pin: '==3.3.0'
- os: ubuntu-latest
python-version: '3.12'
extras: 'did'
diff-diff-pin: 'resolved-latest'
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Pkg + Dependencies
run: |
if [ -z "${{ matrix.extras }}" ]; then
python -m pip install -e ".[dev]"
else
python -m pip install -e ".[dev,${{ matrix.extras }}]"
fi
shell: bash
- name: Verify bare `import balance` works (no diff-diff)
if: matrix.extras == ''
run: |
python -c "import balance; print('balance', balance.__version__)"
shell: bash
- name: Pin diff-diff to exact minimum (==3.3.0)
# NOTE: bracket notation `matrix['diff-diff-pin']` is required because
# GitHub Actions parses `-` in expressions as the subtraction operator,
# so `matrix.diff-diff-pin` would be evaluated as
# `matrix.diff - diff - pin` (arithmetic on undefined identifiers) and
# would never match the literal `'==3.3.0'`, silently skipping this
# step for every `did` matrix job.
if: matrix.extras == 'did' && matrix['diff-diff-pin'] == '==3.3.0'
run: |
python -m pip install "diff-diff==3.3.0"
- name: Show installed diff-diff (debugging aid)
if: matrix.extras == 'did'
run: |
python -c "import diff_diff; print('diff_diff', diff_diff.__version__)"
- name: Test with pytest
run: |
python -m pytest -ra
- name: Build wheels pkg
run: |
python -m pip install --upgrade pip build
python -m build --wheel --outdir dist
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install dependencies
run: |
pip install flake8 black==25.1.0 ufmt==2.8.0 usort==1.0.8.post1
- name: Flake8
run: |
flake8 .
- name: ufmt (formatting check)
run: |
echo "Checking for formatting issues..."
ufmt diff .
ufmt check .
pyre:
# NOTE: .pyre_configuration.external has "ignore_all_errors" for tests/ - this is intentional.
# Meta's internal Pyre uses python/typeshed_internal with permissive pandas stubs
# (Axes = ... | list | tuple), but external pyre-check-nightly uses stricter typeshed
# stubs that reject tuple/list for DataFrame index/columns. This causes ~85 false-positive
# errors in tests that don't occur internally. The main library code (balance/) is still
# fully type-checked.
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install project dependencies
run: |
python -m pip install --upgrade pip
pip install .[dev]
- name: Install Pyre nightly
run: |
pip install pyre-check-nightly==0.0.101750936314
- name: Pyre type check
run: |
cp .pyre_configuration.external .pyre_configuration
pyre --noninteractive check
test-deploy-website:
name: Test website build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: 22
cache: yarn
cache-dependency-path: "./website/yarn.lock"
- name: Set up Python
uses: actions/setup-python@v5
with:
# 3.12 matches the brfss tutorial kernel, the canary, the [did]
# arm in the test matrix, and the notebook-CI workflow. Earlier
# versions used 3.9 — diff-diff supports 3.9-3.14 so [did] would
# still install, but consolidating on 3.12 keeps the docs-build
# interpreter aligned with the version that actually runs the
# tutorial in CI.
python-version: "3.12"
- name: Install Pkg + Dependencies
run: |
python -m pip install ".[dev,did]"
- name: Build website
run: bash ./scripts/make_docs.sh -n