Skip to content

Commit c6ab9c7

Browse files
authored
Merge pull request #5815 from plotly/cam/5814/update-plotly.js-fetch-location
ci: Update plotly.js fetch location
2 parents 0b1e5b7 + 1a34e16 commit c6ab9c7

7 files changed

Lines changed: 151 additions & 167 deletions

File tree

‎.github/workflows/build-package.yml‎

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -11,46 +11,6 @@ permissions:
1111
contents: read
1212

1313
jobs:
14-
plotlyjs-dev-build:
15-
name: plotly.js dev build
16-
runs-on: ubuntu-latest
17-
steps:
18-
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
19-
- name: Set up Python
20-
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
21-
with:
22-
python-version: "3.12"
23-
- name: Set up Node
24-
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
25-
with:
26-
node-version: "22"
27-
- name: Set up uv
28-
uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
29-
- name: Install dependencies
30-
run: |
31-
uv venv
32-
source .venv/bin/activate
33-
uv sync --locked --extra dev_optional
34-
- name: Update plotly.js to dev
35-
run: |
36-
source .venv/bin/activate
37-
python commands.py updateplotlyjsdev
38-
- name: Test core (excluding nodev)
39-
run: |
40-
source .venv/bin/activate
41-
pytest -k 'not nodev' tests/test_core
42-
- name: Build source distribution packages
43-
run: |
44-
source .venv/bin/activate
45-
uv sync --locked --extra dev_build
46-
python -m build --sdist --wheel -o dist
47-
- name: Upload dist artifacts
48-
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
49-
with:
50-
name: plotlyjs-dev-build-dist
51-
path: dist/
52-
if-no-files-found: error
53-
5414
full-build:
5515
name: Full prod build
5616
runs-on: ubuntu-latest
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Test plotly.js dev
2+
3+
# Run codegen and the core tests against the plot-schema.json on plotly.js main
4+
# once a week. This catches plotly.js schema changes that break codegen or
5+
# validation before the next plotly.js release.
6+
on:
7+
schedule:
8+
- cron: "0 9 * * 1" # Monday 09:00 UTC
9+
workflow_dispatch:
10+
inputs:
11+
plotlyjs_ref:
12+
description: "plotly.js branch, tag, or commit SHA to test"
13+
required: false
14+
default: "main"
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
test-plotlyjs-dev:
21+
name: Test against plotly.js dev schema
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
25+
with:
26+
persist-credentials: false
27+
- name: Set up Python
28+
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
29+
with:
30+
python-version: "3.12"
31+
- name: Set up uv
32+
uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
33+
- name: Install dependencies
34+
run: |
35+
uv venv
36+
source .venv/bin/activate
37+
uv sync --locked --extra dev_optional
38+
- name: Download plot-schema.json from plotly.js
39+
# plotly.js CI keeps test/plot-schema.json identical to the built schema
40+
env:
41+
PLOTLYJS_REF: ${{ inputs.plotlyjs_ref || 'main' }}
42+
run: |
43+
curl -fsSL -o codegen/resources/plot-schema.json \
44+
"https://raw.githubusercontent.com/plotly/plotly.js/${PLOTLYJS_REF}/test/plot-schema.json"
45+
- name: Run codegen
46+
run: |
47+
source .venv/bin/activate
48+
python commands.py codegen
49+
- name: Test core (excluding nodev)
50+
run: |
51+
source .venv/bin/activate
52+
pytest -k 'not nodev' tests/test_core
53+
54+
report-failure:
55+
name: Open an issue for a failed scheduled run
56+
needs: test-plotlyjs-dev
57+
# Manual runs can test any plotly.js ref, so only report scheduled runs
58+
if: failure() && github.event_name == 'schedule'
59+
runs-on: ubuntu-latest
60+
permissions:
61+
issues: write
62+
steps:
63+
- name: Open or update the failure issue
64+
env:
65+
GH_TOKEN: ${{ github.token }}
66+
GH_REPO: ${{ github.repository }}
67+
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
68+
TITLE: "Weekly plotly.js dev test failed"
69+
run: |
70+
BODY="The weekly test against the plot-schema.json on plotly.js main failed: ${RUN_URL}"
71+
# Comment on an open issue from an earlier failure instead of opening a duplicate
72+
EXISTING=$(gh issue list --state open --search "in:title \"${TITLE}\"" \
73+
--json number,title --jq "map(select(.title == \"${TITLE}\")) | .[0].number // empty")
74+
if [ -n "${EXISTING}" ]; then
75+
gh issue comment "${EXISTING}" --body "${BODY}"
76+
else
77+
gh issue create --title "${TITLE}" --body "${BODY}"
78+
fi

‎CONTRIBUTING.md‎

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ Steps to update plotly.js:
283283

284284
This command does the following:
285285

286-
- Downloads new versions of `plot-schema.json` and `plotly.min.js` from the [plotly.js GitHub repository](https://github.com/plotly/plotly.js)
286+
- Downloads new versions of `plot-schema.json` and `plotly.min.js` from the [`plotly.js` npm package](https://www.npmjs.com/package/plotly.js)
287287
and places them in `codegen/resources/` and `plotly/package_data/`, respectively.
288288
- Updates `plotly/offline/_plotlyjs_version.py` with the new version
289289
- Regenerates all of the classes under `graph_objs/` (`go.Figure`, `go.Layout`, etc.), and `plotly/validators/_validators.json`, based on the new schema
@@ -318,23 +318,9 @@ and places them in `codegen/resources/` and `plotly/package_data/`, respectively
318318

319319
7. Add a changelog entry to `CHANGELOG.md` with a link to the PR. We typically mention the version update, link to the plotly.js GitHub release page, and list out the most important changes. Follow the format of previous plotly.js version bump changelog updates.
320320

321-
### Using a Development Branch of Plotly.js
321+
### Using a Development Version of Plotly.js
322322

323-
If your development branch is in [the plotly.js repository](https://github.com/plotly/plotly.js)
324-
you can update to development versions of `plotly.js` with this command:
325-
326-
```bash
327-
python commands.py updateplotlyjsdev --devrepo reponame --devbranch branchname
328-
```
329-
330-
This downloads `dist/plotly.min.js` and `dist/plot-schema.json` from the latest commit of the branch `branchname` of the repo `reponame`.
331-
If `--devrepo` or `--devbranch` are omitted,
332-
`updateplotlyjsdev` defaults to `plotly/plotly.js` and `main` respectively.
333-
334-
### Local Repository
335-
336-
If you have a local repository of `plotly.js` you'd like to try,
337-
you can prepare the package by running the following commands
323+
To test plotly.py against a local repository of `plotly.js`, prepare the package by running the following commands
338324
*in your local plotly.js repository*:
339325

340326
```bash
@@ -347,7 +333,7 @@ You can then run the following command
347333
*in your local plotly.py repository*:
348334

349335
```bash
350-
python commands.py updateplotlyjsdev --local /path/to/your/plotly.js/
336+
python commands.py updateplotlyjsdev /path/to/your/plotly.js/
351337
```
352338

353339
## Documentation for `commands.py`
@@ -362,5 +348,5 @@ Usage: `python commands.py <subcommand> <args>`
362348
| `lint` | Lint all Python code in `plotly/`. |
363349
| `format` | Format all Python code in `plotly/`. |
364350
| `updateplotlyjs` | Update `plotly.min.js` and `plot-schema.json` to match the `plotly.js` version specified in `js/package.json`, run codegen to regenerate the Python files, then run `npm install` in `js/` to refresh `js/package-lock.json`. Set `SKIP_NPM=1` to skip the npm step. |
365-
| `updateplotlyjsdev [--devrepo REPONAME --devbranch BRANCHNAME] \| [--local PATH]` | Update `plot-schema.json` and `plotly.min.js` to match the version in the provided plotly.js repo name and branch name, OR local path. Then, run codegen to regenerate the Python files. |
351+
| `updateplotlyjsdev PATH` | Update `plot-schema.json` and `plotly.min.js` from the local plotly.js repository at `PATH`. Then, run codegen to regenerate the Python files. |
366352
| `bumpversion X.Y.Z` | Update the plotly.py version number to X.Y.Z across all files where it needs to be updated. |

0 commit comments

Comments
 (0)