|
| 1 | +name: Lazy imports all |
| 2 | + |
| 3 | +# Run the standard library test suite with global lazy imports forced on |
| 4 | +# (``PYTHON_LAZY_IMPORTS=all``, equivalent to ``-X lazy_imports=all``). |
| 5 | +# |
| 6 | +# Modules that are known to fail under lazy imports are listed in |
| 7 | +# Lib/test/lazy_imports_all_exclude.txt and skipped here. Remove entries from |
| 8 | +# that file as the modules are fixed so this workflow starts guarding them |
| 9 | +# against regressions. |
| 10 | + |
| 11 | +on: |
| 12 | + workflow_dispatch: |
| 13 | + push: |
| 14 | + branches: &branches |
| 15 | + - 'main' |
| 16 | + - '3.*' |
| 17 | + paths-ignore: &paths-ignore |
| 18 | + - 'Doc/**' |
| 19 | + - 'Misc/**' |
| 20 | + - '**/*.md' |
| 21 | + - '**/*.rst' |
| 22 | + pull_request: |
| 23 | + branches: *branches |
| 24 | + paths-ignore: *paths-ignore |
| 25 | + |
| 26 | +permissions: |
| 27 | + contents: read |
| 28 | + |
| 29 | +concurrency: |
| 30 | + group: ${{ github.workflow }}-${{ github.actor }}-${{ github.head_ref || github.run_id }} |
| 31 | + cancel-in-progress: true |
| 32 | + |
| 33 | +env: |
| 34 | + FORCE_COLOR: 1 |
| 35 | + |
| 36 | +jobs: |
| 37 | + lazy-imports: |
| 38 | + name: Stdlib tests (lazy imports all) |
| 39 | + runs-on: ubuntu-24.04 |
| 40 | + timeout-minutes: 60 |
| 41 | + env: |
| 42 | + PYTHON_LAZY_IMPORTS: all |
| 43 | + EXCLUDE_FILE: Lib/test/lazy_imports_all_exclude.txt |
| 44 | + steps: |
| 45 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 46 | + with: |
| 47 | + persist-credentials: false |
| 48 | + - name: Register gcc problem matcher |
| 49 | + run: echo "::add-matcher::.github/problem-matchers/gcc.json" |
| 50 | + - name: Install dependencies |
| 51 | + run: sudo ./.github/workflows/posix-deps-apt.sh |
| 52 | + - name: Configure CPython |
| 53 | + run: ./configure --config-cache --with-pydebug |
| 54 | + - name: Build CPython |
| 55 | + run: make -j4 |
| 56 | + - name: Display build info |
| 57 | + run: make pythoninfo |
| 58 | + - name: Verify lazy imports are fullly enabled |
| 59 | + run: ./python -c "import sys; assert sys.flags.lazy_imports == 1, sys.flags.lazy_imports; print('lazy imports all enabled')" |
| 60 | + - name: Build test list (all tests minus the known-failing exclusions) |
| 61 | + run: | |
| 62 | + set -euo pipefail |
| 63 | + ./python -m test --list-tests > all_tests.txt |
| 64 | + # Strip comments/blank lines from the exclusion file, then drop those |
| 65 | + # exact test names (whole-line, fixed-string match) from the run list. |
| 66 | + grep -vE '^\s*(#.*)?$' "$EXCLUDE_FILE" > exclude_tests.txt |
| 67 | + grep -vxF -f exclude_tests.txt all_tests.txt > run_tests.txt |
| 68 | + # Fail loudly if any exclusion entry matched nothing: a stale or |
| 69 | + # mistyped name (or a change in `--list-tests` output) would otherwise |
| 70 | + # silently stop excluding a module and let it fail the run. |
| 71 | + stale=$(comm -23 <(sort -u exclude_tests.txt) <(sort -u all_tests.txt)) |
| 72 | + if [ -n "$stale" ]; then |
| 73 | + echo "::error::Stale entries in $EXCLUDE_FILE (no longer match 'python -m test --list-tests'); remove or fix them:" |
| 74 | + echo "$stale" |
| 75 | + exit 1 |
| 76 | + fi |
| 77 | + echo "Excluding $(wc -l < exclude_tests.txt) module(s); running $(wc -l < run_tests.txt) of $(wc -l < all_tests.txt)." |
| 78 | + - name: Run stdlib tests with lazy imports |
| 79 | + run: xvfb-run xargs ./python -m test --fast-ci --timeout=900 < run_tests.txt |
0 commit comments