Skip to content

Commit 73d4a6d

Browse files
committed
add CI step to check that Python generated files are up to date
1 parent 800faba commit 73d4a6d

3 files changed

Lines changed: 66 additions & 4 deletions

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Check Python codegen
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types: [opened, reopened, synchronize]
9+
10+
jobs:
11+
check-python-codegen:
12+
name: Check Python codegen
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
16+
- name: Set up Python
17+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
18+
with:
19+
python-version: "3.x"
20+
21+
- name: Set up uv
22+
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
23+
24+
- name: Install dependencies
25+
run: |
26+
uv venv
27+
source .venv/bin/activate
28+
uv pip install ".[dev_codegen]"
29+
- name: Run codegen
30+
run: |
31+
source .venv/bin/activate
32+
python commands.py codegen
33+
- name: Check for changes
34+
run: |
35+
# Fail if codegen produced any changes to the working directory.
36+
# This means the committed generated files are out of date and codegen
37+
# needs to be re-run locally and the results committed.
38+
if [ -n "$(git status --porcelain)" ]; then
39+
echo "::error::Generated files are out of date. Please run 'python commands.py codegen' locally and commit the result."
40+
echo "The following files differ after running codegen:"
41+
git status --porcelain
42+
echo ""
43+
exit 1
44+
fi
45+
echo "Generated files are up to date."

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,20 @@ dev_build = [
5353
"build",
5454
"jupyterlab"
5555
]
56+
dev_codegen = [
57+
"plotly[dev_core]",
58+
"inflect"
59+
]
5660
dev_optional = [
5761
"plotly[dev_build]",
62+
"plotly[dev_codegen]",
5863
"plotly[express]",
5964
"plotly[kaleido]",
6065
"anywidget",
6166
"colorcet",
6267
# fiona>1.9.6 is not compatible with geopandas<1; geopandas>=1 is not compatible with python 3.8
6368
"fiona<=1.9.6;python_version<='3.8'",
6469
"geopandas",
65-
"inflect",
6670
"orjson",
6771
"pandas",
6872
"pdfrw",

uv.lock

Lines changed: 16 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)