Lockstep widgets with matterviz-anywidget 0.6.0 #2327
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Tests | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| workflow_call: | |
| env: | |
| MPLBACKEND: Agg # non-interactive backend for matplotlib | |
| jobs: | |
| tests: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest] | |
| split: [1, 2, 3, 4] | |
| uses: janosh/workflows/.github/workflows/pytest.yml@main | |
| secrets: inherit | |
| with: | |
| os: ${{ matrix.os }} | |
| python-version: '3.12' | |
| # Widget assets are the matterviz-anywidget npm release pinned in | |
| # MATTERVIZ_ANYWIDGET_VERSION, fetched from jsDelivr at runtime (no Node build). | |
| # playwright + chromium so the headless export and JS prop parity tests run | |
| install-cmd: | | |
| uv pip install -e '.[test,brillouin,export]' --system | |
| playwright install --with-deps chromium | |
| # pytest-split distributes work load so parallel jobs finish in similar time | |
| # update durations file with `pytest --store-durations --durations-path tests/files/.pytest-split-durations` | |
| test-cmd: pytest --durations 20 --cov-branch --cov-report=xml --cov pymatviz --splits 4 --group ${{ matrix.split }} --splitting-algorithm least_duration | |
| # 'yes' uploads coverage but keeps CI green if Codecov errors (its GPG key | |
| # import from keybase flakes intermittently); 'strict' would fail the job | |
| upload-coverage: 'yes' | |
| run-widget-demos: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v6 | |
| - name: Setup Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.12' | |
| - name: Setup uv | |
| uses: astral-sh/setup-uv@v8.2.0 | |
| - name: Run all widget demos | |
| run: | | |
| uv pip install -e '.[test]' marimo nbconvert ipykernel --system | |
| python examples/widgets/vscode_interactive_demo.py | |
| marimo export script examples/widgets/marimo_demo.py -o /tmp/marimo_flat.py && python /tmp/marimo_flat.py | |
| jupyter nbconvert --to notebook --execute --ExecutePreprocessor.timeout=120 examples/widgets/jupyter_demo.ipynb --output /tmp/jupyter_out.ipynb | |
| find-example-scripts: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| example_scripts: ${{ steps.set-matrix.outputs.example_scripts }} | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v6 | |
| - name: Find Python scripts | |
| id: set-matrix | |
| run: | | |
| SCRIPTS=$(find assets/scripts -name "*.py" | jq -R -s -c 'split("\n")[:-1]') | |
| echo "example_scripts=$SCRIPTS" >> $GITHUB_OUTPUT | |
| test-example-scripts: | |
| needs: find-example-scripts | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| example_script: ${{fromJson(needs.find-example-scripts.outputs.example_scripts)}} | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v6 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: 3.12 | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v8.2.0 | |
| - name: Run script | |
| run: uv run --with-editable .[make-assets] ${{ matrix.example_script }} |