-
-
Notifications
You must be signed in to change notification settings - Fork 35.2k
gh-149640: Add new GitHub action to test lazy_imports=all against test suite #151105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
brittanyrey
wants to merge
17
commits into
python:main
Choose a base branch
from
brittanyrey:lazy-imports-all-ci
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
0e6e080
Add new github action to test lazy imports all against stdlib.
brittanyrey 90cf964
Adjust GH Action naming to better match existing checks
brittanyrey 71d3aa7
Address comments for reusability
brittanyrey d3fb4eb
Fix double typo + add flaky module
brittanyrey f07ad18
Update test name
brittanyrey a036677
Remove concurrency configeration for reusable-test-lazy-imports-all.yml
brittanyrey dbb1390
bikeshed renames
brittanyrey 860f80d
Take a swing at adding exclusion checks
brittanyrey e1c07b6
remove allegedly passing modules?
brittanyrey 77d1dcf
clean up
brittanyrey 1dbdf0b
Fix bug with env var not flowing through and bring back exclusions
brittanyrey e577926
Accidentally added random files
brittanyrey 47fb4a4
Add more modules
brittanyrey 651cb43
Address incorrect exclusions
brittanyrey 5540969
Address feedback: update ubuntu version and CODEOWNERS file
brittanyrey d41581f
Prune test_idle and test_zoneinfo from the exclusion list
brittanyrey 8f7988d
Address comments. Variety of small nits and cleanups.
brittanyrey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
|
brittanyrey marked this conversation as resolved.
|
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| name: Reusable Lazy Imports Tests | ||
|
|
||
| # Run the CPython test suite with global lazy imports forced on | ||
| # (``-X lazy_imports=all``). | ||
| # | ||
| # Modules that are known to fail under lazy imports are listed in | ||
| # Lib/test/lazy_imports_all_exclude.txt and skipped here. Remove entries from | ||
| # that file as the modules are fixed so this workflow starts guarding them | ||
| # against regressions. Excluded modules are also checked separately so the | ||
| # workflow fails when one starts passing and its exclusion should be removed. | ||
|
|
||
| on: | ||
| workflow_call: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| env: | ||
| FORCE_COLOR: 1 | ||
|
|
||
| jobs: | ||
|
brittanyrey marked this conversation as resolved.
|
||
| test-lazy-imports-all: | ||
| name: 'Run Tests with lazy_imports=all' | ||
| runs-on: ubuntu-26.04 | ||
| timeout-minutes: 60 | ||
| env: | ||
| EXCLUDE_FILE: Lib/test/lazy_imports_all_exclude.txt | ||
| steps: | ||
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | ||
| with: | ||
| persist-credentials: false | ||
| - name: Register gcc problem matcher | ||
| run: echo "::add-matcher::.github/problem-matchers/gcc.json" | ||
| - name: Install dependencies | ||
| run: sudo ./.github/workflows/posix-deps-apt.sh | ||
| - name: Configure CPython | ||
| run: ./configure --config-cache --with-pydebug | ||
| - name: Build CPython | ||
| run: make -j4 | ||
| - name: Display build info | ||
| run: make pythoninfo | ||
| - name: Verify lazy imports are fully enabled | ||
| run: ./python -X lazy_imports=all -c "import sys; assert sys.flags.lazy_imports == 1, sys.flags.lazy_imports; print('lazy imports all enabled')" | ||
| - name: Build test list (all tests minus the known-failing exclusions) | ||
| run: | | ||
| set -euo pipefail | ||
| ./python -m test --list-tests > all_tests.txt | ||
| # Strip comments/blank lines from the exclusion file, then drop those | ||
|
brittanyrey marked this conversation as resolved.
|
||
| # exact test names (whole-line, fixed-string match) from the run list. | ||
| grep -vE '^\s*(#.*)?$' "$EXCLUDE_FILE" > exclude_tests.txt || true | ||
| grep -vxF -f exclude_tests.txt all_tests.txt > run_tests.txt | ||
| # Fail loudly if any exclusion entry matched nothing: a stale or | ||
| # mistyped name (or a change in `--list-tests` output) would otherwise | ||
| # silently stop excluding a module and let it fail the run. | ||
| stale=$(comm -23 <(sort -u exclude_tests.txt) <(sort -u all_tests.txt)) | ||
| if [ -n "$stale" ]; then | ||
| echo "::error::Stale entries in $EXCLUDE_FILE (no longer match 'python -m test --list-tests'); remove or fix them:" | ||
| echo "$stale" | ||
| exit 1 | ||
| fi | ||
| echo "Excluding $(wc -l < exclude_tests.txt) module(s); running $(wc -l < run_tests.txt) of $(wc -l < all_tests.txt)." | ||
| - name: Run tests with lazy imports | ||
| run: xvfb-run xargs -a run_tests.txt ./python -X lazy_imports=all -m test --fast-ci --timeout=900 < /dev/null | ||
| - name: Verify excluded tests still need exclusion | ||
| run: | | ||
| set -euo pipefail | ||
| unexpected_passes=() | ||
| while IFS= read -r test_name; do | ||
| [ -n "$test_name" ] || continue | ||
| echo "Checking excluded test: $test_name" | ||
| if xvfb-run ./python -X lazy_imports=all -m test --fast-ci --timeout=900 "$test_name"; then | ||
|
brittanyrey marked this conversation as resolved.
|
||
| unexpected_passes+=("$test_name") | ||
| fi | ||
| done < exclude_tests.txt | ||
| if [ "${#unexpected_passes[@]}" -ne 0 ]; then | ||
| echo "::error::These tests still appear in $EXCLUDE_FILE but now pass with -X lazy_imports=all. Remove them from the exclude file:" | ||
| printf '%s\n' "${unexpected_passes[@]}" | ||
| exit 1 | ||
| fi | ||
Empty file.
|
brittanyrey marked this conversation as resolved.
|
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| # Test modules that currently FAIL under global lazy imports | ||
| # (``-X lazy_imports=all`` / ``PYTHON_LAZY_IMPORTS=all``). | ||
| # | ||
| # The "Lazy Imports All" CI workflow | ||
| # (.github/workflows/reusable-test-lazy-imports-all.yml) runs the whole test | ||
| # suite with lazy_imports=all, skipping every module listed here. Exclusion is | ||
| # whole-module: a listed module is skipped entirely, so any passing tests it | ||
| # contains are not covered until its line is removed. As each module is fixed, | ||
| # delete its line so the workflow starts guarding it against regressions. The | ||
| # workflow also checks listed modules separately and fails if one now passes, | ||
| # so accidental fixes prompt cleanup of this file. | ||
| # | ||
| # Format: one test name per line, exactly as printed by | ||
| # ``python -m test --list-tests``. Lines starting with ``#`` and blank lines | ||
| # are ignored. Note that split test packages use a dotted path | ||
| # (e.g. test.test_future_stmt.test_future) while ordinary modules use the bare | ||
| # name (e.g. test_builtin). | ||
|
|
||
| test.test_inspect.test_inspect | ||
| test___all__ | ||
| test__interpreters | ||
| test_builtin | ||
| test_clinic | ||
| test_crossinterp | ||
| test_datetime | ||
| test_generated_cases | ||
| test_heapq | ||
| test_import | ||
| test_importlib | ||
| test_json | ||
| test_pkg | ||
| test_profile | ||
| test_profiling | ||
| test_pyrepl | ||
| test_subprocess | ||
| test_symtable | ||
| test_tools | ||
| test_trace | ||
| test_type_annotations | ||
| test_unittest |
Empty file.
Empty file.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.