Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

ci: support test-all label (#6776)

Myles Scolnick03cb04db8b73
diff --git a/.github/workflows/test_be.yaml b/.github/workflows/test_be.yaml
index 676a491320..301d7c2150 100644
--- a/.github/workflows/test_be.yaml
+++ b/.github/workflows/test_be.yaml
@@ -45,9 +45,32 @@ jobs:
- name: 📚 Build docs
run: hatch run docs:build --strict
- test_python:
+ test_check:
needs: changes
if: ${{ needs.changes.outputs.backend == 'true' }}
+ name: Test lint and typecheck
+ runs-on: ubuntu-latest
+ steps:
+ - name: 🛑 Cancel Previous Runs
+ uses: styfle/[email protected]
+
+ - name: ⬇️ Checkout repo
+ uses: actions/checkout@v4
+
+ - name: 🥚 Install Hatch
+ uses: pypa/hatch@install
+
+ - name: 🧹 Lint
+ run: hatch run lint
+
+ - name: 🔍 Typecheck
+ run: hatch run typecheck:check
+
+ # For PRs, we only run the tests for the changed files.
+ # If there is a `test-all` label, we run the tests across unchanged files as well.
+ test_python:
+ needs: changes
+ if: ${{ needs.changes.outputs.backend == 'true' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'test-all')) }}
name: ${{ matrix.os }} / Py ${{ matrix.python-version }} / ${{ matrix.dependencies }} deps
runs-on: ${{ matrix.os }}
timeout-minutes: 20
@@ -107,47 +130,55 @@ jobs:
cp frontend/index.html marimo/_static/index.html
cp frontend/public/favicon.ico marimo/_static/favicon.ico
- - name: Lint
- if: ${{ matrix.python-version == '3.12' }}
- run: hatch run lint
-
- - name: Typecheck
- if: ${{ matrix.python-version == '3.12' }}
- run: hatch run typecheck:check
-
# Required since python3.14 not pulled automatically for now.
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
+ # Setup test flags based on conditions
+ - name: Setup test flags
+ id: setup-flags
+ run: |
+ # Set CHANGED_FROM: On PRs, compare against base branch; on main, compare against HEAD~1
+ CHANGED_FROM="${{ github.base_ref && format('origin/{0}', github.base_ref) || 'HEAD~1' }}"
+ echo "changed_from=$CHANGED_FROM"
+ echo "changed_from=$CHANGED_FROM" >> $GITHUB_OUTPUT
+
+ # Set INCLUDE_UNCHANGED: true if test-all label, python 3.13 + optional deps, or main branch
+ if [[ "${{ contains(github.event.pull_request.labels.*.name, 'test-all') }}" == "true" ]] || \
+ [[ "${{ matrix.python-version }}" == "3.13" && "${{ matrix.dependencies }}" == "core,optional" ]] || \
+ [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
+ echo "include_unchanged=true"
+ echo "include_unchanged=true" >> $GITHUB_OUTPUT
+ else
+ echo "include_unchanged=false"
+ echo "include_unchanged=false" >> $GITHUB_OUTPUT
+ fi
+
# Test with base dependencies
- name: Test changed with base dependencies
if: ${{ matrix.dependencies == 'core' }}
run: |
- # On PRs, compare against base branch; on main, compare against HEAD~1
- CHANGED_FROM="${{ github.base_ref && format('origin/{0}', github.base_ref) || 'HEAD~1' }}"
hatch run +py=${{ matrix.python-version }} test:test tests/ \
-v \
-k "not test_cli" \
--durations=10 \
- -p packages.pytest_changed --changed-from=$CHANGED_FROM \
+ -p packages.pytest_changed \
+ --changed-from=${{ steps.setup-flags.outputs.changed_from }} \
+ --include-unchanged=${{ steps.setup-flags.outputs.include_unchanged }} \
--picked=first
# Test with optional dependencies
- name: Test changed with optional dependencies
if: ${{ matrix.dependencies == 'core,optional' }}
- # Include all tests on 3.13 or main
run: |
- INCLUDE_UNCHANGED=${{ matrix.python-version == '3.13' }} || ${{ github.ref == 'refs/heads/main' }}
- # On PRs, compare against base branch; on main, compare against HEAD~1
- CHANGED_FROM="${{ github.base_ref && format('origin/{0}', github.base_ref) || 'HEAD~1' }}"
-
hatch run +py=${{ matrix.python-version }} test-optional:test tests/ \
-v \
-k "not test_cli" \
--durations=10 \
- -p packages.pytest_changed --changed-from=$CHANGED_FROM \
- --include-unchanged=$INCLUDE_UNCHANGED \
+ -p packages.pytest_changed \
+ --changed-from=${{ steps.setup-flags.outputs.changed_from }} \
+ --include-unchanged=${{ steps.setup-flags.outputs.include_unchanged }} \
--picked=first
# Test with minimal dependencies using lowest resolution
@@ -156,14 +187,14 @@ jobs:
- name: Test with minimal dependencies (lowest resolution)
if: ${{ matrix.dependencies == 'minimal' }}
run: |
- # On PRs, compare against base branch; on main, compare against HEAD~1
- CHANGED_FROM="${{ github.base_ref && format('origin/{0}', github.base_ref) || 'HEAD~1' }}"
hatch run +py=${{ matrix.python-version }} test:test tests/ \
-v \
-k "not test_cli" \
--durations=10 \
- --picked=first \
- -p packages.pytest_changed --changed-from=$CHANGED_FROM
+ -p packages.pytest_changed \
+ --changed-from=${{ steps.setup-flags.outputs.changed_from }} \
+ --include-unchanged=${{ steps.setup-flags.outputs.include_unchanged }} \
+ --picked=first
env:
UV_RESOLUTION: lowest
@@ -192,7 +223,7 @@ jobs:
- name: Test with optional dependencies
run: |
- hatch run +py=3.12 test-optional:test \
+ hatch run +py=3.13 test-optional:test \
-v \
tests/ \
-k "not test_cli" \
@@ -201,8 +232,8 @@ jobs:
--cov=marimo --cov-report=xml --junitxml=junit.xml -o junit_family=legacy
# Only upload coverage on `main` so it is not blocking
- # and only on `3.12`, `ubuntu-latest`, with optional deps since it is mostly duplicate
- # coverage from the other matrix jobs.
+ # and only on `3.13`, `ubuntu-latest`, with optional deps since it will cover
+ # the most surface area.
- name: Upload coverage reports to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v5
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index c8376e9760..cce043c207 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -33,8 +33,8 @@ Install [pixi](https://github.com/prefix-dev/pixi) to manage your development en
pixi shell
```
-If you have the right non-python dependencies installed via other methods (e.g. homebrew) you can simply activate your `marimo` development
-environment with `hatch shell`.
+If you have the right non-python dependencies installed via other methods (e.g. homebrew) you can simply activate your `marimo` development
+environment with `hatch shell`.
Now you can install the environment frontend and Python dependencies.
@@ -86,8 +86,6 @@ To build the frontend unminified, run:
NODE_ENV=development make fe -B
```
-
-
## `make` commands
> [!NOTE]
@@ -355,6 +353,14 @@ If you use vscode, you might find the following `settings.json` useful:
}
```
+## PRs
+
+When submitting a pull request, marimo will run: lint, typecheck, and test jobs.
+
+We have some labels which can influence which tests are run:
+
+- `test-all`: Run all tests across unchanged files as well.
+
## Your first PR
Marimo has a variety of CI jobs that run on pull requests. All new PRs will fail until you have signed the [CLA](https://marimo.io/cla). Don't fret. You can sign the CLA by leaving a comment in the PR with text of `I have read the CLA Document and I hereby sign the CLA`
diff --git a/packages/pytest_changed/__init__.py b/packages/pytest_changed/__init__.py
index 3255d05807..526248fec1 100644
--- a/packages/pytest_changed/__init__.py
+++ b/packages/pytest_changed/__init__.py
@@ -251,6 +251,14 @@ def pytest_configure(config: pytest.Config) -> None:
# Store the test files in config for collection hook
config.option.changed_test_files = test_files
+ include_unchanged: bool = config.getoption("include_unchanged")
+ if test_files and not include_unchanged:
+ # Convert to relative paths for cleaner output
+ test_paths = [
+ str(f.relative_to(repo_root)) for f in sorted(test_files)
+ ]
+ config.args[:] = test_paths
+
def pytest_collection_modifyitems(
config: pytest.Config, items: list[pytest.Item]
@@ -275,7 +283,7 @@ def pytest_collection_modifyitems(
)
return
- include_unchanged = config.getoption("include_unchanged")
+ include_unchanged: bool = config.getoption("include_unchanged")
# Filter items to only those in affected test files
selected: list[pytest.Item] = []
diff --git a/tests/_sql/test_engine_utils.py b/tests/_sql/test_engine_utils.py
index 7dbf658b9b..ed4ec22814 100644
--- a/tests/_sql/test_engine_utils.py
+++ b/tests/_sql/test_engine_utils.py
@@ -55,7 +55,7 @@ def assert_multiple_called_once(
class TestNativeOutputFormat:
- """Test native output format scenarios."""
+ """Test different native output format scenarios."""
def test_with_to_native(self, mock_functions: MockFnDict) -> None:
"""Test native output format when to_native is provided."""