diff --git a/.github/workflows/add-issue-header.yml b/.github/workflows/add-issue-header.yml deleted file mode 100644 index 3cbc23af578d10..00000000000000 --- a/.github/workflows/add-issue-header.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: Add issue header -# Automatically edits an issue's descriptions with a header, -# one of: -# -# - Bug report -# - Crash report -# - Feature or enhancement - -on: - issues: - types: - # Only ever run once - - opened - - -jobs: - add-header: - runs-on: ubuntu-latest - permissions: - issues: write - timeout-minutes: 5 - steps: - - uses: actions/github-script@v7 - with: - # language=JavaScript - script: | - // https://devguide.python.org/triage/labels/#type-labels - const HEADERS = new Map([ - ['type-bug', 'Bug report'], - ['type-crash', 'Crash report'], - ['type-feature', 'Feature or enhancement'], - ]); - let issue_data = await github.rest.issues.get({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo - }).then(issue => issue.data); - let header = ''; - for (const label_data of issue_data.labels) { - const label_name = (typeof label_data === 'string') ? label_data : label_data.name; - if (HEADERS.has(label_name)) { - header = HEADERS.get(label_name); - break; - } - } - if (header !== '') { - console.log(`Setting new header: ${header}`); - await github.rest.issues.update({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: `# ${header}\n\n${issue_data.body.replaceAll('\r', '')}` - }); - } diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b192508c78685c..fe0780f0d15428 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,13 +3,7 @@ name: Tests on: workflow_dispatch: push: - branches: - - 'main' - - '3.*' pull_request: - branches: - - 'main' - - '3.*' permissions: contents: read @@ -36,638 +30,3 @@ jobs: # }} # uses: ./.github/workflows/reusable-context.yml - - check-docs: - name: Docs - needs: build-context - if: fromJSON(needs.build-context.outputs.run-docs) - uses: ./.github/workflows/reusable-docs.yml - - check-autoconf-regen: - name: 'Check if Autoconf files are up to date' - # Don't use ubuntu-latest but a specific version to make the job - # reproducible: to get the same tools versions (autoconf, aclocal, ...) - runs-on: ubuntu-24.04 - container: - image: ghcr.io/python/autoconf:2025.01.02.12581854023 - timeout-minutes: 60 - needs: build-context - if: needs.build-context.outputs.run-tests == 'true' - steps: - - name: Install Git - run: | - apt update && apt install git -yq - git config --global --add safe.directory "$GITHUB_WORKSPACE" - - uses: actions/checkout@v4 - with: - fetch-depth: 1 - persist-credentials: false - - name: Check Autoconf and aclocal versions - run: | - grep "Generated by GNU Autoconf 2.72" configure - grep "aclocal 1.16.5" aclocal.m4 - grep -q "runstatedir" configure - grep -q "PKG_PROG_PKG_CONFIG" aclocal.m4 - - name: Regenerate autoconf files - # Same command used by Tools/build/regen-configure.sh ($AUTORECONF) - run: autoreconf -ivf -Werror - - name: Check for changes - run: | - git add -u - changes=$(git status --porcelain) - # Check for changes in regenerated files - if test -n "$changes"; then - echo "Generated files not up to date." - echo "Perhaps you forgot to run make regen-configure ;)" - echo "configure files must be regenerated with a specific version of autoconf." - echo "$changes" - echo "" - git diff --staged || true - exit 1 - fi - - check-generated-files: - name: 'Check if generated files are up to date' - # Don't use ubuntu-latest but a specific version to make the job - # reproducible: to get the same tools versions (autoconf, aclocal, ...) - runs-on: ubuntu-24.04 - timeout-minutes: 60 - needs: build-context - if: needs.build-context.outputs.run-tests == 'true' - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - uses: actions/setup-python@v5 - with: - python-version: '3.x' - - name: Runner image version - run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV" - - name: Restore config.cache - uses: actions/cache@v4 - with: - path: config.cache - # Include env.pythonLocation in key to avoid changes in environment when setup-python updates Python - key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ needs.build-context.outputs.config-hash }}-${{ env.pythonLocation }} - - name: Install dependencies - run: sudo ./.github/workflows/posix-deps-apt.sh - - name: Add ccache to PATH - run: echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV" - - name: Configure ccache action - uses: hendrikmuhs/ccache-action@v1.2 - with: - save: false - - name: Configure CPython - run: | - # Build Python with the libpython dynamic library - ./configure --config-cache --with-pydebug --enable-shared - - name: Build CPython - run: | - make -j4 regen-all - make regen-stdlib-module-names regen-sbom regen-unicodedata - - name: Check for changes - run: | - git add -u - changes=$(git status --porcelain) - # Check for changes in regenerated files - if test -n "$changes"; then - echo "Generated files not up to date." - echo "Perhaps you forgot to run make regen-all or build.bat --regen. ;)" - echo "configure files must be regenerated with a specific version of autoconf." - echo "$changes" - echo "" - git diff --staged || true - exit 1 - fi - - name: Check exported libpython symbols - run: make smelly - - name: Check limited ABI symbols - run: make check-limited-abi - - name: Check for unsupported C global variables - if: github.event_name == 'pull_request' # $GITHUB_EVENT_NAME - run: make check-c-globals - - build-windows: - name: >- - Windows - ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} - needs: build-context - if: fromJSON(needs.build-context.outputs.run-windows-tests) - strategy: - fail-fast: false - matrix: - arch: - - x64 - - Win32 - - arm64 - free-threading: - - false - - true - exclude: - # Skip Win32 on free-threaded builds - - { arch: Win32, free-threading: true } - uses: ./.github/workflows/reusable-windows.yml - with: - arch: ${{ matrix.arch }} - free-threading: ${{ matrix.free-threading }} - - build-windows-msi: - name: >- # ${{ '' } is a hack to nest jobs under the same sidebar category - Windows MSI${{ '' }} - needs: build-context - if: fromJSON(needs.build-context.outputs.run-windows-msi) - strategy: - fail-fast: false - matrix: - arch: - - x86 - - x64 - - arm64 - uses: ./.github/workflows/reusable-windows-msi.yml - with: - arch: ${{ matrix.arch }} - - build-macos: - name: >- - macOS - ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} - needs: build-context - if: needs.build-context.outputs.run-tests == 'true' - strategy: - fail-fast: false - matrix: - # Cirrus and macos-14 are M1, macos-13 is default GHA Intel. - # macOS 13 only runs tests against the GIL-enabled CPython. - # Cirrus used for upstream, macos-14 for forks. - os: - - ghcr.io/cirruslabs/macos-runner:sonoma - - macos-14 - - macos-13 - is-fork: # only used for the exclusion trick - - ${{ github.repository_owner != 'python' }} - free-threading: - - false - - true - exclude: - - os: ghcr.io/cirruslabs/macos-runner:sonoma - is-fork: true - - os: macos-14 - is-fork: false - - os: macos-13 - free-threading: true - uses: ./.github/workflows/reusable-macos.yml - with: - config_hash: ${{ needs.build-context.outputs.config-hash }} - free-threading: ${{ matrix.free-threading }} - os: ${{ matrix.os }} - - build-ubuntu: - name: >- - Ubuntu - ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} - ${{ fromJSON(matrix.bolt) && '(bolt)' || '' }} - needs: build-context - if: needs.build-context.outputs.run-tests == 'true' - strategy: - fail-fast: false - matrix: - bolt: - - false - - true - free-threading: - - false - - true - os: - - ubuntu-24.04 - - ubuntu-24.04-arm - exclude: - # Do not test BOLT with free-threading, to conserve resources - - bolt: true - free-threading: true - # BOLT currently crashes during instrumentation on aarch64 - - os: ubuntu-24.04-arm - bolt: true - uses: ./.github/workflows/reusable-ubuntu.yml - with: - config_hash: ${{ needs.build-context.outputs.config-hash }} - bolt-optimizations: ${{ matrix.bolt }} - free-threading: ${{ matrix.free-threading }} - os: ${{ matrix.os }} - - build-ubuntu-ssltests: - name: 'Ubuntu SSL tests with OpenSSL' - runs-on: ${{ matrix.os }} - timeout-minutes: 60 - needs: build-context - if: needs.build-context.outputs.run-tests == 'true' - strategy: - fail-fast: false - matrix: - os: [ubuntu-24.04] - openssl_ver: [3.0.16, 3.1.8, 3.2.4, 3.3.3, 3.4.1] - # See Tools/ssl/make_ssl_data.py for notes on adding a new version - env: - OPENSSL_VER: ${{ matrix.openssl_ver }} - MULTISSL_DIR: ${{ github.workspace }}/multissl - OPENSSL_DIR: ${{ github.workspace }}/multissl/openssl/${{ matrix.openssl_ver }} - LD_LIBRARY_PATH: ${{ github.workspace }}/multissl/openssl/${{ matrix.openssl_ver }}/lib - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - name: Runner image version - run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV" - - name: Restore config.cache - uses: actions/cache@v4 - with: - path: config.cache - key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ needs.build-context.outputs.config-hash }} - - 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 OpenSSL env vars - run: | - echo "MULTISSL_DIR=${GITHUB_WORKSPACE}/multissl" >> "$GITHUB_ENV" - echo "OPENSSL_DIR=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}" >> "$GITHUB_ENV" - echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}/lib" >> "$GITHUB_ENV" - - name: 'Restore OpenSSL build' - id: cache-openssl - uses: actions/cache@v4 - with: - path: ./multissl/openssl/${{ env.OPENSSL_VER }} - key: ${{ matrix.os }}-multissl-openssl-${{ env.OPENSSL_VER }} - - name: Install OpenSSL - if: steps.cache-openssl.outputs.cache-hit != 'true' - run: python3 Tools/ssl/multissltests.py --steps=library --base-directory "$MULTISSL_DIR" --openssl "$OPENSSL_VER" --system Linux - - name: Add ccache to PATH - run: | - echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV" - - name: Configure ccache action - uses: hendrikmuhs/ccache-action@v1.2 - with: - save: false - - name: Configure CPython - run: ./configure CFLAGS="-fdiagnostics-format=json" --config-cache --enable-slower-safety --with-pydebug --with-openssl="$OPENSSL_DIR" - - name: Build CPython - run: make -j4 - - name: Display build info - run: make pythoninfo - - name: SSL tests - run: ./python Lib/test/ssltests.py - - build-wasi: - name: 'WASI' - needs: build-context - if: needs.build-context.outputs.run-tests == 'true' - uses: ./.github/workflows/reusable-wasi.yml - with: - config_hash: ${{ needs.build-context.outputs.config-hash }} - - test-hypothesis: - name: "Hypothesis tests on Ubuntu" - runs-on: ubuntu-24.04 - timeout-minutes: 60 - needs: build-context - if: needs.build-context.outputs.run-tests == 'true' - env: - OPENSSL_VER: 3.0.16 - PYTHONSTRICTEXTENSIONBUILD: 1 - steps: - - uses: actions/checkout@v4 - 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 OpenSSL env vars - run: | - echo "MULTISSL_DIR=${GITHUB_WORKSPACE}/multissl" >> "$GITHUB_ENV" - echo "OPENSSL_DIR=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}" >> "$GITHUB_ENV" - echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}/lib" >> "$GITHUB_ENV" - - name: 'Restore OpenSSL build' - id: cache-openssl - uses: actions/cache@v4 - with: - path: ./multissl/openssl/${{ env.OPENSSL_VER }} - key: ${{ runner.os }}-multissl-openssl-${{ env.OPENSSL_VER }} - - name: Install OpenSSL - if: steps.cache-openssl.outputs.cache-hit != 'true' - run: python3 Tools/ssl/multissltests.py --steps=library --base-directory "$MULTISSL_DIR" --openssl "$OPENSSL_VER" --system Linux - - name: Add ccache to PATH - run: | - echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV" - - name: Configure ccache action - uses: hendrikmuhs/ccache-action@v1.2 - with: - save: false - - name: Setup directory envs for out-of-tree builds - run: | - echo "CPYTHON_RO_SRCDIR=$(realpath -m "${GITHUB_WORKSPACE}"/../cpython-ro-srcdir)" >> "$GITHUB_ENV" - echo "CPYTHON_BUILDDIR=$(realpath -m "${GITHUB_WORKSPACE}"/../cpython-builddir)" >> "$GITHUB_ENV" - - name: Create directories for read-only out-of-tree builds - run: mkdir -p "$CPYTHON_RO_SRCDIR" "$CPYTHON_BUILDDIR" - - name: Bind mount sources read-only - run: sudo mount --bind -o ro "$GITHUB_WORKSPACE" "$CPYTHON_RO_SRCDIR" - - name: Runner image version - run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV" - - name: Restore config.cache - uses: actions/cache@v4 - with: - path: ${{ env.CPYTHON_BUILDDIR }}/config.cache - key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ needs.build-context.outputs.config-hash }} - - name: Configure CPython out-of-tree - working-directory: ${{ env.CPYTHON_BUILDDIR }} - run: | - ../cpython-ro-srcdir/configure \ - --config-cache \ - --with-pydebug \ - --enable-slower-safety \ - --with-openssl="$OPENSSL_DIR" - - name: Build CPython out-of-tree - working-directory: ${{ env.CPYTHON_BUILDDIR }} - run: make -j4 - - name: Display build info - working-directory: ${{ env.CPYTHON_BUILDDIR }} - run: make pythoninfo - - name: Remount sources writable for tests - # some tests write to srcdir, lack of pyc files slows down testing - run: sudo mount "$CPYTHON_RO_SRCDIR" -oremount,rw - - name: Setup directory envs for out-of-tree builds - run: | - echo "CPYTHON_BUILDDIR=$(realpath -m "${GITHUB_WORKSPACE}"/../cpython-builddir)" >> "$GITHUB_ENV" - - name: "Create hypothesis venv" - working-directory: ${{ env.CPYTHON_BUILDDIR }} - run: | - VENV_LOC=$(realpath -m .)/hypovenv - VENV_PYTHON=$VENV_LOC/bin/python - echo "HYPOVENV=${VENV_LOC}" >> "$GITHUB_ENV" - echo "VENV_PYTHON=${VENV_PYTHON}" >> "$GITHUB_ENV" - ./python -m venv "$VENV_LOC" && "$VENV_PYTHON" -m pip install -r "${GITHUB_WORKSPACE}/Tools/requirements-hypothesis.txt" - - name: 'Restore Hypothesis database' - id: cache-hypothesis-database - uses: actions/cache@v4 - with: - path: ${{ env.CPYTHON_BUILDDIR }}/.hypothesis/ - key: hypothesis-database-${{ github.head_ref || github.run_id }} - restore-keys: | - hypothesis-database- - - name: "Run tests" - working-directory: ${{ env.CPYTHON_BUILDDIR }} - run: | - # Most of the excluded tests are slow test suites with no property tests - # - # (GH-104097) test_sysconfig is skipped because it has tests that are - # failing when executed from inside a virtual environment. - "${VENV_PYTHON}" -m test \ - -W \ - --slowest \ - -j4 \ - --timeout 900 \ - -x test_asyncio \ - -x test_multiprocessing_fork \ - -x test_multiprocessing_forkserver \ - -x test_multiprocessing_spawn \ - -x test_concurrent_futures \ - -x test_socket \ - -x test_subprocess \ - -x test_signal \ - -x test_sysconfig - - uses: actions/upload-artifact@v4 - if: always() - with: - name: hypothesis-example-db - path: ${{ env.CPYTHON_BUILDDIR }}/.hypothesis/examples/ - - build-asan: - name: 'Address sanitizer' - runs-on: ${{ matrix.os }} - timeout-minutes: 60 - needs: build-context - if: needs.build-context.outputs.run-tests == 'true' - strategy: - fail-fast: false - matrix: - os: [ubuntu-24.04] - env: - OPENSSL_VER: 3.0.16 - PYTHONSTRICTEXTENSIONBUILD: 1 - ASAN_OPTIONS: detect_leaks=0:allocator_may_return_null=1:handle_segv=0 - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - name: Runner image version - run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV" - - name: Restore config.cache - uses: actions/cache@v4 - with: - path: config.cache - key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ needs.build-context.outputs.config-hash }} - - 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: Set up GCC-10 for ASAN - uses: egor-tensin/setup-gcc@v1 - with: - version: 10 - - name: Configure OpenSSL env vars - run: | - echo "MULTISSL_DIR=${GITHUB_WORKSPACE}/multissl" >> "$GITHUB_ENV" - echo "OPENSSL_DIR=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}" >> "$GITHUB_ENV" - echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}/lib" >> "$GITHUB_ENV" - - name: 'Restore OpenSSL build' - id: cache-openssl - uses: actions/cache@v4 - with: - path: ./multissl/openssl/${{ env.OPENSSL_VER }} - key: ${{ matrix.os }}-multissl-openssl-${{ env.OPENSSL_VER }} - - name: Install OpenSSL - if: steps.cache-openssl.outputs.cache-hit != 'true' - run: python3 Tools/ssl/multissltests.py --steps=library --base-directory "$MULTISSL_DIR" --openssl "$OPENSSL_VER" --system Linux - - name: Add ccache to PATH - run: | - echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV" - - name: Configure ccache action - uses: hendrikmuhs/ccache-action@v1.2 - with: - save: ${{ github.event_name == 'push' }} - max-size: "200M" - - name: Configure CPython - run: ./configure --config-cache --with-address-sanitizer --without-pymalloc - - name: Build CPython - run: make -j4 - - name: Display build info - run: make pythoninfo - - name: Tests - run: xvfb-run make ci - - build-tsan: - name: >- - Thread sanitizer - ${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }} - needs: build-context - if: needs.build-context.outputs.run-tests == 'true' - strategy: - fail-fast: false - matrix: - free-threading: - - false - - true - uses: ./.github/workflows/reusable-tsan.yml - with: - config_hash: ${{ needs.build-context.outputs.config-hash }} - free-threading: ${{ matrix.free-threading }} - - cross-build-linux: - name: Cross build Linux - runs-on: ubuntu-latest - timeout-minutes: 60 - needs: build-context - if: needs.build-context.outputs.run-tests == 'true' - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - name: Runner image version - run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV" - - name: Restore config.cache - uses: actions/cache@v4 - with: - path: config.cache - key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ needs.build-context.outputs.config-hash }} - - name: Register gcc problem matcher - run: echo "::add-matcher::.github/problem-matchers/gcc.json" - - name: Set build dir - run: - # an absolute path outside of the working directoy - echo "BUILD_DIR=$(realpath ${{ github.workspace }}/../build)" >> "$GITHUB_ENV" - - name: Install dependencies - run: sudo ./.github/workflows/posix-deps-apt.sh - - name: Configure host build - run: ./configure --prefix="$BUILD_DIR/host-python" - - name: Install host Python - run: make -j8 install - - name: Run test subset with host build - run: | - "$BUILD_DIR/host-python/bin/python3" -m test test_sysconfig test_site test_embed - - name: Configure cross build - run: ./configure --prefix="$BUILD_DIR/cross-python" --with-build-python="$BUILD_DIR/host-python/bin/python3" - - name: Install cross Python - run: make -j8 install - - name: Run test subset with host build - run: | - "$BUILD_DIR/cross-python/bin/python3" -m test test_sysconfig test_site test_embed - - # CIFuzz job based on https://google.github.io/oss-fuzz/getting-started/continuous-integration/ - cifuzz: - name: CIFuzz - runs-on: ubuntu-latest - timeout-minutes: 60 - needs: build-context - if: needs.build-context.outputs.run-ci-fuzz == 'true' - permissions: - security-events: write - strategy: - fail-fast: false - matrix: - sanitizer: [address, undefined, memory] - steps: - - name: Build fuzzers (${{ matrix.sanitizer }}) - id: build - uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master - with: - oss-fuzz-project-name: cpython3 - sanitizer: ${{ matrix.sanitizer }} - - name: Run fuzzers (${{ matrix.sanitizer }}) - uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master - with: - fuzz-seconds: 600 - oss-fuzz-project-name: cpython3 - output-sarif: true - sanitizer: ${{ matrix.sanitizer }} - - name: Upload crash - if: failure() && steps.build.outcome == 'success' - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.sanitizer }}-artifacts - path: ./out/artifacts - - name: Upload SARIF - if: always() && steps.build.outcome == 'success' - uses: github/codeql-action/upload-sarif@v3 - with: - sarif_file: cifuzz-sarif/results.sarif - checkout_path: cifuzz-sarif - - all-required-green: # This job does nothing and is only used for the branch protection - name: All required checks pass - runs-on: ubuntu-latest - timeout-minutes: 5 - needs: - - build-context # Transitive dependency, needed to access `run-tests` value - - check-docs - - check-autoconf-regen - - check-generated-files - - build-windows - - build-windows-msi - - build-macos - - build-ubuntu - - build-ubuntu-ssltests - - build-wasi - - test-hypothesis - - build-asan - - build-tsan - - cross-build-linux - - cifuzz - if: always() - - steps: - - name: Check whether the needed jobs succeeded or failed - uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe - with: - allowed-failures: >- - build-windows-msi, - build-ubuntu-ssltests, - test-hypothesis, - cifuzz, - allowed-skips: >- - ${{ - !fromJSON(needs.build-context.outputs.run-docs) - && ' - check-docs, - ' - || '' - }} - ${{ - needs.build-context.outputs.run-tests != 'true' - && ' - check-autoconf-regen, - check-generated-files, - build-macos, - build-ubuntu, - build-ubuntu-ssltests, - build-wasi, - test-hypothesis, - build-asan, - build-tsan, - cross-build-linux, - ' - || '' - }} - ${{ - !fromJSON(needs.build-context.outputs.run-windows-tests) - && ' - build-windows, - ' - || '' - }} - ${{ - !fromJSON(needs.build-context.outputs.run-ci-fuzz) - && ' - cifuzz, - ' - || '' - }} - jobs: ${{ toJSON(needs) }} diff --git a/.github/workflows/documentation-links.yml b/.github/workflows/documentation-links.yml deleted file mode 100644 index a09a30587b35eb..00000000000000 --- a/.github/workflows/documentation-links.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Read the Docs PR preview -# Automatically edits a pull request's descriptions with a link -# to the documentation's preview on Read the Docs. - -on: - pull_request_target: - types: - - opened - paths: - - 'Doc/**' - - '.github/workflows/doc.yml' - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - documentation-links: - runs-on: ubuntu-latest - permissions: - pull-requests: write - timeout-minutes: 5 - - steps: - - uses: readthedocs/actions/preview@v1 - with: - project-slug: "cpython-previews" - single-version: "true" diff --git a/.github/workflows/jit.yml b/.github/workflows/jit.yml deleted file mode 100644 index 116e0c1e945e38..00000000000000 --- a/.github/workflows/jit.yml +++ /dev/null @@ -1,155 +0,0 @@ -name: JIT -on: - pull_request: - paths: - - '**jit**' - - 'Python/bytecodes.c' - - 'Python/optimizer*.c' - - '!Python/perf_jit_trampoline.c' - - '!**/*.md' - - '!**/*.ini' - push: - paths: - - '**jit**' - - 'Python/bytecodes.c' - - 'Python/optimizer*.c' - - '!Python/perf_jit_trampoline.c' - - '!**/*.md' - - '!**/*.ini' - workflow_dispatch: - -permissions: - contents: read - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -env: - FORCE_COLOR: 1 - -jobs: - interpreter: - name: Interpreter (Debug) - runs-on: ubuntu-24.04 - timeout-minutes: 90 - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - name: Build tier two interpreter - run: | - ./configure --enable-experimental-jit=interpreter --with-pydebug - make all --jobs 4 - - name: Test tier two interpreter - run: | - ./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3 - jit: - name: ${{ matrix.target }} (${{ matrix.debug && 'Debug' || 'Release' }}) - needs: interpreter - runs-on: ${{ matrix.runner }} - timeout-minutes: 90 - strategy: - fail-fast: false - matrix: - target: - - i686-pc-windows-msvc/msvc - - x86_64-pc-windows-msvc/msvc - - aarch64-pc-windows-msvc/msvc - - x86_64-apple-darwin/clang - - aarch64-apple-darwin/clang - - x86_64-unknown-linux-gnu/gcc - - aarch64-unknown-linux-gnu/gcc - debug: - - true - - false - llvm: - - 19 - include: - - target: i686-pc-windows-msvc/msvc - architecture: Win32 - runner: windows-latest - - target: x86_64-pc-windows-msvc/msvc - architecture: x64 - runner: windows-latest - - target: aarch64-pc-windows-msvc/msvc - architecture: ARM64 - runner: windows-11-arm - - target: x86_64-apple-darwin/clang - architecture: x86_64 - runner: macos-13 - - target: aarch64-apple-darwin/clang - architecture: aarch64 - runner: macos-14 - - target: x86_64-unknown-linux-gnu/gcc - architecture: x86_64 - runner: ubuntu-24.04 - - target: aarch64-unknown-linux-gnu/gcc - architecture: aarch64 - runner: ubuntu-24.04-arm - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - uses: actions/setup-python@v5 - with: - python-version: '3.11' - - # PCbuild downloads LLVM automatically: - - name: Windows - if: runner.os == 'Windows' - run: | - ./PCbuild/build.bat --experimental-jit ${{ matrix.debug && '-d' || '' }} -p ${{ matrix.architecture }} - ./PCbuild/rt.bat ${{ matrix.debug && '-d' || '' }} -p ${{ matrix.architecture }} -q --multiprocess 0 --timeout 4500 --verbose2 --verbose3 - - # The `find` line is required as a result of https://github.com/actions/runner-images/issues/9966. - # This is a bug in the macOS runner image where the pre-installed Python is installed in the same - # directory as the Homebrew Python, which causes the build to fail for macos-13. This line removes - # the symlink to the pre-installed Python so that the Homebrew Python is used instead. - - name: macOS - if: runner.os == 'macOS' - run: | - brew update - find /usr/local/bin -lname '*/Library/Frameworks/Python.framework/*' -delete - brew install llvm@${{ matrix.llvm }} - export SDKROOT="$(xcrun --show-sdk-path)" - ./configure --enable-experimental-jit --enable-universalsdk --with-universal-archs=universal2 ${{ matrix.debug && '--with-pydebug' || '' }} - make all --jobs 4 - ./python.exe -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3 - - - name: Linux - if: runner.os == 'Linux' - run: | - sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }} - export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH" - ./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '' }} - make all --jobs 4 - ./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3 - - # XXX: GH-133171 - # jit-with-disabled-gil: - # name: Free-Threaded (Debug) - # needs: interpreter - # runs-on: ubuntu-24.04 - # timeout-minutes: 90 - # strategy: - # fail-fast: false - # matrix: - # llvm: - # - 19 - # steps: - # - uses: actions/checkout@v4 - # with: - # persist-credentials: false - # - uses: actions/setup-python@v5 - # with: - # python-version: '3.11' - # - name: Build with JIT enabled and GIL disabled - # run: | - # sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }} - # export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH" - # ./configure --enable-experimental-jit --with-pydebug --disable-gil - # make all --jobs 4 - # - name: Run tests - # run: | - # ./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index d74ce8fcc256dc..00000000000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Lint - -on: [push, pull_request, workflow_dispatch] - -permissions: - contents: read - -env: - FORCE_COLOR: 1 - RUFF_OUTPUT_FORMAT: github - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - lint: - runs-on: ubuntu-latest - timeout-minutes: 10 - - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - uses: actions/setup-python@v5 - with: - python-version: "3.x" - - uses: pre-commit/action@v3.0.1 diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml deleted file mode 100644 index 908daaf3a6019a..00000000000000 --- a/.github/workflows/mypy.yml +++ /dev/null @@ -1,67 +0,0 @@ -# Workflow to run mypy on select parts of the CPython repo -name: mypy - -on: - push: - branches: - - main - pull_request: - paths: - - ".github/workflows/mypy.yml" - - "Lib/_colorize.py" - - "Lib/_pyrepl/**" - - "Lib/test/libregrtest/**" - - "Lib/tomllib/**" - - "Misc/mypy/**" - - "Tools/build/generate_sbom.py" - - "Tools/cases_generator/**" - - "Tools/clinic/**" - - "Tools/jit/**" - - "Tools/peg_generator/**" - - "Tools/requirements-dev.txt" - - "Tools/wasm/**" - workflow_dispatch: - -permissions: - contents: read - -env: - PIP_DISABLE_PIP_VERSION_CHECK: 1 - FORCE_COLOR: 1 - TERM: xterm-256color # needed for FORCE_COLOR to work on mypy on Ubuntu, see https://github.com/python/mypy/issues/13817 - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - mypy: - name: Run mypy on ${{ matrix.target }} - runs-on: ubuntu-latest - timeout-minutes: 10 - strategy: - fail-fast: false - matrix: - target: [ - "Lib/_pyrepl", - "Lib/test/libregrtest", - "Lib/tomllib", - "Tools/build", - "Tools/cases_generator", - "Tools/clinic", - "Tools/jit", - "Tools/peg_generator", - "Tools/wasm", - ] - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - uses: actions/setup-python@v5 - with: - python-version: "3.13" - cache: pip - cache-dependency-path: Tools/requirements-dev.txt - - run: pip install -r Tools/requirements-dev.txt - - run: python3 Misc/mypy/make_symlinks.py --symlink - - run: mypy --config-file ${{ matrix.target }}/mypy.ini diff --git a/.github/workflows/new-bugs-announce-notifier.yml b/.github/workflows/new-bugs-announce-notifier.yml deleted file mode 100644 index 9f1a8a824e5f19..00000000000000 --- a/.github/workflows/new-bugs-announce-notifier.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: new-bugs-announce notifier - -on: - issues: - types: - - opened - -permissions: - issues: read - -jobs: - notify-new-bugs-announce: - runs-on: ubuntu-latest - timeout-minutes: 10 - steps: - - uses: actions/setup-node@v4 - with: - node-version: 20 - - run: npm install mailgun.js form-data - - name: Send notification - uses: actions/github-script@v7 - env: - MAILGUN_API_KEY: ${{ secrets.MAILGUN_PYTHON_ORG_MAILGUN_KEY }} - with: - script: | - const Mailgun = require("mailgun.js"); - const formData = require('form-data'); - const mailgun = new Mailgun(formData); - const DOMAIN = "mailgun.python.org"; - const mg = mailgun.client({username: 'api', key: process.env.MAILGUN_API_KEY}); - github.rest.issues.get({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - }) - .then(function(issue) { - const payload = { - author : issue.data.user.login, - issue : issue.data.number, - title : issue.data.title, - url : issue.data.html_url, - labels : issue.data.labels.map(label => { return label.name }).join(", "), - assignee : issue.data.assignees.map(assignee => { return assignee.login }), - // We need to truncate the body size, because the max size for - // the whole payload is 16kb. We want to be safe and assume that - // body can take up to ~8kb of space. - body : issue.data.body.substring(0, 8000) - }; - - const data = { - from: "CPython Issues ", - to: "new-bugs-announce@python.org", - subject: `[Issue ${issue.data.number}] ${issue.data.title}`, - template: "new-github-issue", - 'o:tracking-clicks': 'no', - 'h:X-Mailgun-Variables': JSON.stringify(payload) - }; - return mg.messages.create(DOMAIN, data) - }) - .then(msg => console.log(msg)); diff --git a/.github/workflows/posix-deps-apt.sh b/.github/workflows/posix-deps-apt.sh deleted file mode 100755 index d5538cd9367ec6..00000000000000 --- a/.github/workflows/posix-deps-apt.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -apt-get update - -apt-get -yq install \ - build-essential \ - pkg-config \ - ccache \ - gdb \ - lcov \ - libb2-dev \ - libbz2-dev \ - libffi-dev \ - libgdbm-dev \ - libgdbm-compat-dev \ - liblzma-dev \ - libncurses5-dev \ - libreadline6-dev \ - libsqlite3-dev \ - libssl-dev \ - lzma \ - lzma-dev \ - strace \ - tk-dev \ - uuid-dev \ - xvfb \ - zlib1g-dev diff --git a/.github/workflows/project-updater.yml b/.github/workflows/project-updater.yml deleted file mode 100644 index 1d9d637ec848a6..00000000000000 --- a/.github/workflows/project-updater.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Update GH projects - -on: - issues: - types: - - opened - - labeled - -permissions: - contents: read - -jobs: - add-to-project: - name: Add issues to projects - runs-on: ubuntu-latest - timeout-minutes: 10 - strategy: - fail-fast: false - matrix: - include: - # if an issue has any of these labels, it will be added - # to the corresponding project - - { project: 2, label: "release-blocker, deferred-blocker" } - - { project: 32, label: sprint } - - steps: - - uses: actions/add-to-project@v1.0.0 - with: - project-url: https://github.com/orgs/python/projects/${{ matrix.project }} - github-token: ${{ secrets.ADD_TO_PROJECT_PAT }} - labeled: ${{ matrix.label }} diff --git a/.github/workflows/regen-abidump.sh b/.github/workflows/regen-abidump.sh deleted file mode 100644 index 251bb3857ecfcb..00000000000000 --- a/.github/workflows/regen-abidump.sh +++ /dev/null @@ -1,8 +0,0 @@ -set -ex - -export DEBIAN_FRONTEND=noninteractive -./.github/workflows/posix-deps-apt.sh -apt-get install -yq abigail-tools python3 -export CFLAGS="-g3 -O0" -./configure --enable-shared && make -make regen-abidump diff --git a/.github/workflows/require-pr-label.yml b/.github/workflows/require-pr-label.yml deleted file mode 100644 index 7e534c58c798d1..00000000000000 --- a/.github/workflows/require-pr-label.yml +++ /dev/null @@ -1,61 +0,0 @@ -name: Check labels - -on: - pull_request: - types: [opened, reopened, labeled, unlabeled, synchronize] - -jobs: - label-dnm: - name: DO-NOT-MERGE - if: github.repository_owner == 'python' - runs-on: ubuntu-latest - permissions: - pull-requests: read - timeout-minutes: 10 - - steps: - - name: Check there's no DO-NOT-MERGE - uses: mheap/github-action-required-labels@v5 - with: - mode: exactly - count: 0 - labels: | - DO-NOT-MERGE - - label-reviews: - name: Unresolved review - if: github.repository_owner == 'python' - runs-on: ubuntu-latest - permissions: - pull-requests: read - timeout-minutes: 10 - - steps: - # Check that the PR is not awaiting changes from the author due to previous review. - - name: Check there's no required changes - uses: mheap/github-action-required-labels@v5 - with: - mode: exactly - count: 0 - labels: | - awaiting changes - awaiting change review - - id: is-feature - name: Check whether this PR is a feature (contains a "type-feature" label) - uses: mheap/github-action-required-labels@v5 - with: - mode: exactly - count: 1 - labels: | - type-feature - exit_type: success # don't fail the check if the PR is not a feature, just record the result - # In case of a feature PR, check for a complete review (contains an "awaiting merge" label). - - id: awaiting-merge - if: steps.is-feature.outputs.status == 'success' - name: Check for complete review - uses: mheap/github-action-required-labels@v5 - with: - mode: exactly - count: 1 - labels: | - awaiting merge diff --git a/.github/workflows/reusable-context.yml b/.github/workflows/reusable-context.yml index 73e036a146f5d4..458cdc24241542 100644 --- a/.github/workflows/reusable-context.yml +++ b/.github/workflows/reusable-context.yml @@ -67,6 +67,20 @@ jobs: || '' }} + - run: git remote -vvv + - run: git -P branch -v + - run: git -P branch -r -v + - run: echo ref= ${{ github.ref }} + - run: echo sha= ${{ github.sha }} + - run: echo repository= ${{ github.repository }} + - run: echo event.pull_request.head.sha= ${{ github.event.pull_request.head.sha }} + - run: echo head_ref= ${{ github.head_ref }} + - run: echo base_ref= ${{ github.base_ref }} + - run: echo env.GITHUB_HEAD_REF= ${{ env.GITHUB_HEAD_REF }} + - run: echo $GITHUB_HEAD_REF + - run: echo $GITHUB_BASE_REF + - run: echo head sha or sha = ${{ github.event.pull_request.head.sha || github.sha }} + # Adapted from https://github.com/actions/checkout/issues/520#issuecomment-1167205721 - name: Fetch commits to get branch diff if: github.event_name == 'pull_request' @@ -89,6 +103,8 @@ jobs: commits: ${{ github.event.pull_request.commits }} refspec_base: '+${{ github.event.pull_request.base.sha }}:remotes/origin/${{ github.event.pull_request.base.ref }}' refspec_pr: '+${{ github.event.pull_request.head.sha }}:remotes/origin/${{ github.event.pull_request.head.ref }}' + - run: git -P branch -v + - run: git -P branch -r -v # We only want to run tests on PRs when related files are changed, # or when someone triggers a manual workflow run. @@ -97,6 +113,8 @@ jobs: run: python Tools/build/compute-changes.py env: GITHUB_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} + CCF_TARGET_REF: ${{ github.base_ref || github.event.repository.default_branch }} + CCF_HEAD_REF: ${{ github.event.pull_request.head.sha || github.sha }} - name: Compute hash for config cache key id: config-hash diff --git a/.github/workflows/reusable-docs.yml b/.github/workflows/reusable-docs.yml deleted file mode 100644 index 657e0a6bf662f7..00000000000000 --- a/.github/workflows/reusable-docs.yml +++ /dev/null @@ -1,104 +0,0 @@ -name: Reusable Docs - -on: - workflow_call: - workflow_dispatch: - -permissions: - contents: read - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -env: - FORCE_COLOR: 1 - -jobs: - build-doc: - name: 'Docs' - runs-on: ubuntu-latest - timeout-minutes: 60 - env: - branch_base: 'origin/${{ github.event.pull_request.base.ref }}' - branch_pr: 'origin/${{ github.event.pull_request.head.ref }}' - commits: ${{ github.event.pull_request.commits }} - refspec_base: '+${{ github.event.pull_request.base.sha }}:remotes/origin/${{ github.event.pull_request.base.ref }}' - refspec_pr: '+${{ github.event.pull_request.head.sha }}:remotes/origin/${{ github.event.pull_request.head.ref }}' - steps: - - name: 'Check out latest PR branch commit' - uses: actions/checkout@v4 - with: - persist-credentials: false - ref: >- - ${{ - github.event_name == 'pull_request' - && github.event.pull_request.head.sha - || '' - }} - # Adapted from https://github.com/actions/checkout/issues/520#issuecomment-1167205721 - - name: 'Fetch commits to get branch diff' - if: github.event_name == 'pull_request' - run: | - # Fetch enough history to find a common ancestor commit (aka merge-base): - git fetch origin "${refspec_pr}" --depth=$(( commits + 1 )) \ - --no-tags --prune --no-recurse-submodules - - # This should get the oldest commit in the local fetched history (which may not be the commit the PR branched from): - COMMON_ANCESTOR=$( git rev-list --first-parent --max-parents=0 --max-count=1 "${branch_pr}" ) - DATE=$( git log --date=iso8601 --format=%cd "${COMMON_ANCESTOR}" ) - - # Get all commits since that commit date from the base branch (eg: master or main): - git fetch origin "${refspec_base}" --shallow-since="${DATE}" \ - --no-tags --prune --no-recurse-submodules - - name: 'Set up Python' - uses: actions/setup-python@v5 - with: - python-version: '3' - cache: 'pip' - cache-dependency-path: 'Doc/requirements.txt' - - name: 'Install build dependencies' - run: make -C Doc/ venv - - # To annotate PRs with Sphinx nitpicks (missing references) - - name: 'Build HTML documentation' - continue-on-error: true - run: | - set -Eeuo pipefail - # Build docs with the nit-picky option; write warnings to file - make -C Doc/ PYTHON=../python SPHINXOPTS="--quiet --nitpicky --fail-on-warning --warning-file sphinx-warnings.txt" html - - name: 'Check warnings' - if: github.event_name == 'pull_request' - run: | - python Doc/tools/check-warnings.py \ - --annotate-diff "${branch_base}" "${branch_pr}" \ - --fail-if-regression \ - --fail-if-improved \ - --fail-if-new-news-nit - - # Run "doctest" on HEAD as new syntax doesn't exist in the latest stable release - doctest: - name: 'Doctest' - runs-on: ubuntu-24.04 - timeout-minutes: 60 - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - uses: actions/cache@v4 - with: - path: ~/.cache/pip - key: ubuntu-doc-${{ hashFiles('Doc/requirements.txt') }} - restore-keys: | - ubuntu-doc- - - name: 'Install Dependencies' - run: sudo ./.github/workflows/posix-deps-apt.sh && sudo apt-get install wamerican - - name: 'Configure CPython' - run: ./configure --with-pydebug - - name: 'Build CPython' - run: make -j4 - - name: 'Install build dependencies' - run: make -C Doc/ PYTHON=../python venv - # Use "xvfb-run" since some doctest tests open GUI windows - - name: 'Run documentation doctest' - run: xvfb-run make -C Doc/ PYTHON=../python SPHINXERRORHANDLING="--fail-on-warning" doctest diff --git a/.github/workflows/reusable-macos.yml b/.github/workflows/reusable-macos.yml deleted file mode 100644 index de0c40221364ad..00000000000000 --- a/.github/workflows/reusable-macos.yml +++ /dev/null @@ -1,81 +0,0 @@ -name: Reusable macOS - -on: - workflow_call: - inputs: - config_hash: - required: true - type: string - free-threading: - required: false - type: boolean - default: false - os: - description: OS to run the job - required: true - type: string - -env: - FORCE_COLOR: 1 - -jobs: - build-macos: - name: build and test (${{ inputs.os }}) - runs-on: ${{ inputs.os }} - timeout-minutes: 60 - env: - HOMEBREW_NO_ANALYTICS: 1 - HOMEBREW_NO_AUTO_UPDATE: 1 - HOMEBREW_NO_INSTALL_CLEANUP: 1 - HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1 - PYTHONSTRICTEXTENSIONBUILD: 1 - TERM: linux - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - name: Runner image version - run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV" - - name: Restore config.cache - uses: actions/cache@v4 - with: - path: config.cache - key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ inputs.config_hash }} - - name: Install Homebrew dependencies - run: | - brew install pkg-config openssl@3.0 xz gdbm tcl-tk@8 make - # Because alternate versions are not symlinked into place by default: - brew link --overwrite tcl-tk@8 - - name: Configure CPython - run: | - MACOSX_DEPLOYMENT_TARGET=10.15 \ - GDBM_CFLAGS="-I$(brew --prefix gdbm)/include" \ - GDBM_LIBS="-L$(brew --prefix gdbm)/lib -lgdbm" \ - ./configure \ - --config-cache \ - --with-pydebug \ - --enable-slower-safety \ - --enable-safety \ - ${{ inputs.free-threading && '--disable-gil' || '' }} \ - --prefix=/opt/python-dev \ - --with-openssl="$(brew --prefix openssl@3.0)" - - name: Build CPython - if : ${{ inputs.free-threading || inputs.os != 'macos-13' }} - run: gmake -j8 - - name: Build CPython for compiler warning check - if : ${{ !inputs.free-threading && inputs.os == 'macos-13' }} - run: set -o pipefail; gmake -j8 --output-sync 2>&1 | tee compiler_output_macos.txt - - name: Display build info - run: make pythoninfo - - name: Check compiler warnings - if : ${{ !inputs.free-threading && inputs.os == 'macos-13' }} - run: >- - python3 Tools/build/check_warnings.py - --compiler-output-file-path=compiler_output_macos.txt - --warning-ignore-file-path=Tools/build/.warningignore_macos - --compiler-output-type=clang - --fail-on-regression - --fail-on-improvement - --path-prefix="./" - - name: Tests - run: make ci diff --git a/.github/workflows/reusable-tsan.yml b/.github/workflows/reusable-tsan.yml deleted file mode 100644 index 6a58e5305f8e09..00000000000000 --- a/.github/workflows/reusable-tsan.yml +++ /dev/null @@ -1,94 +0,0 @@ -name: Reusable Thread Sanitizer - -on: - workflow_call: - inputs: - config_hash: - required: true - type: string - free-threading: - description: Whether to use free-threaded mode - required: false - type: boolean - default: false - -env: - FORCE_COLOR: 1 - -jobs: - build-tsan-reusable: - name: 'Thread sanitizer' - runs-on: ubuntu-24.04 - timeout-minutes: 60 - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - name: Runner image version - run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV" - - name: Restore config.cache - uses: actions/cache@v4 - with: - path: config.cache - key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ inputs.config_hash }} - - name: Install dependencies - run: | - sudo ./.github/workflows/posix-deps-apt.sh - # Install clang-18 - wget https://apt.llvm.org/llvm.sh - chmod +x llvm.sh - sudo ./llvm.sh 17 # gh-121946: llvm-18 package is temporarily broken - sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-17 100 - sudo update-alternatives --set clang /usr/bin/clang-17 - sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-17 100 - sudo update-alternatives --set clang++ /usr/bin/clang++-17 - # Reduce ASLR to avoid TSAN crashing - sudo sysctl -w vm.mmap_rnd_bits=28 - - name: TSAN option setup - run: | - echo "TSAN_OPTIONS=log_path=${GITHUB_WORKSPACE}/tsan_log suppressions=${GITHUB_WORKSPACE}/Tools/tsan/suppressions${{ - fromJSON(inputs.free-threading) - && '_free_threading' - || '' - }}.txt handle_segv=0" >> "$GITHUB_ENV" - echo "CC=clang" >> "$GITHUB_ENV" - echo "CXX=clang++" >> "$GITHUB_ENV" - - name: Add ccache to PATH - run: | - echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV" - - name: Configure ccache action - uses: hendrikmuhs/ccache-action@v1.2 - with: - save: ${{ github.event_name == 'push' }} - max-size: "200M" - - name: Configure CPython - run: >- - ./configure - --config-cache - --with-thread-sanitizer - --with-pydebug - ${{ fromJSON(inputs.free-threading) && '--disable-gil' || '' }} - - name: Build CPython - run: make -j4 - - name: Display build info - run: make pythoninfo - - name: Tests - run: ./python -m test --tsan -j4 - - name: Parallel tests - if: fromJSON(inputs.free-threading) - run: ./python -m test --tsan-parallel --parallel-threads=4 -j4 - - name: Display TSAN logs - if: always() - run: find "${GITHUB_WORKSPACE}" -name 'tsan_log.*' | xargs head -n 1000 - - name: Archive TSAN logs - if: always() - uses: actions/upload-artifact@v4 - with: - name: >- - tsan-logs-${{ - fromJSON(inputs.free-threading) - && 'free-threading' - || 'default' - }} - path: tsan_log.* - if-no-files-found: ignore diff --git a/.github/workflows/reusable-ubuntu.yml b/.github/workflows/reusable-ubuntu.yml deleted file mode 100644 index 76b19fd5d1a72e..00000000000000 --- a/.github/workflows/reusable-ubuntu.yml +++ /dev/null @@ -1,127 +0,0 @@ -name: Reusable Ubuntu - -on: - workflow_call: - inputs: - config_hash: - required: true - type: string - bolt-optimizations: - description: Whether to enable BOLT optimizations - required: false - type: boolean - default: false - free-threading: - description: Whether to use free-threaded mode - required: false - type: boolean - default: false - os: - description: OS to run the job - required: true - type: string - -env: - FORCE_COLOR: 1 - -jobs: - build-ubuntu-reusable: - name: build and test (${{ inputs.os }}) - runs-on: ${{ inputs.os }} - timeout-minutes: 60 - env: - OPENSSL_VER: 3.0.15 - PYTHONSTRICTEXTENSIONBUILD: 1 - TERM: linux - steps: - - uses: actions/checkout@v4 - 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: Install Clang and BOLT - if: ${{ fromJSON(inputs.bolt-optimizations) }} - run: | - sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh 19 - sudo apt-get install bolt-19 - echo PATH="$(llvm-config-19 --bindir):$PATH" >> $GITHUB_ENV - - name: Configure OpenSSL env vars - run: | - echo "MULTISSL_DIR=${GITHUB_WORKSPACE}/multissl" >> "$GITHUB_ENV" - echo "OPENSSL_DIR=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}" >> "$GITHUB_ENV" - echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}/lib" >> "$GITHUB_ENV" - - name: 'Restore OpenSSL build' - id: cache-openssl - uses: actions/cache@v4 - with: - path: ./multissl/openssl/${{ env.OPENSSL_VER }} - key: ${{ inputs.os }}-multissl-openssl-${{ env.OPENSSL_VER }} - - name: Install OpenSSL - if: steps.cache-openssl.outputs.cache-hit != 'true' - run: python3 Tools/ssl/multissltests.py --steps=library --base-directory "$MULTISSL_DIR" --openssl "$OPENSSL_VER" --system Linux - - name: Add ccache to PATH - run: | - echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV" - - name: Configure ccache action - uses: hendrikmuhs/ccache-action@v1.2 - with: - save: ${{ github.event_name == 'push' }} - max-size: "200M" - - name: Setup directory envs for out-of-tree builds - run: | - echo "CPYTHON_RO_SRCDIR=$(realpath -m "${GITHUB_WORKSPACE}"/../cpython-ro-srcdir)" >> "$GITHUB_ENV" - echo "CPYTHON_BUILDDIR=$(realpath -m "${GITHUB_WORKSPACE}"/../cpython-builddir)" >> "$GITHUB_ENV" - - name: Create directories for read-only out-of-tree builds - run: mkdir -p "$CPYTHON_RO_SRCDIR" "$CPYTHON_BUILDDIR" - - name: Bind mount sources read-only - run: sudo mount --bind -o ro "$GITHUB_WORKSPACE" "$CPYTHON_RO_SRCDIR" - - name: Runner image version - run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV" - - name: Restore config.cache - uses: actions/cache@v4 - with: - path: ${{ env.CPYTHON_BUILDDIR }}/config.cache - key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ inputs.config_hash }} - - name: Configure CPython out-of-tree - working-directory: ${{ env.CPYTHON_BUILDDIR }} - # `test_unpickle_module_race` writes to the source directory, which is - # read-only during builds — so we exclude it from profiling with BOLT. - run: >- - PROFILE_TASK='-m test --pgo --ignore test_unpickle_module_race' - ../cpython-ro-srcdir/configure - --config-cache - --with-pydebug - --enable-slower-safety - --enable-safety - --with-openssl="$OPENSSL_DIR" - ${{ fromJSON(inputs.free-threading) && '--disable-gil' || '' }} - ${{ fromJSON(inputs.bolt-optimizations) && '--enable-bolt' || '' }} - - name: Build CPython out-of-tree - if: ${{ inputs.free-threading }} - working-directory: ${{ env.CPYTHON_BUILDDIR }} - run: make -j - - name: Build CPython out-of-tree (for compiler warning check) - if: ${{ !inputs.free-threading }} - working-directory: ${{ env.CPYTHON_BUILDDIR }} - run: set -o pipefail; make -j --output-sync 2>&1 | tee compiler_output_ubuntu.txt - - name: Display build info - working-directory: ${{ env.CPYTHON_BUILDDIR }} - run: make pythoninfo - - name: Check compiler warnings - if: ${{ !inputs.free-threading }} - run: >- - python Tools/build/check_warnings.py - --compiler-output-file-path="${CPYTHON_BUILDDIR}/compiler_output_ubuntu.txt" - --warning-ignore-file-path "${GITHUB_WORKSPACE}/Tools/build/.warningignore_ubuntu" - --compiler-output-type=gcc - --fail-on-regression - --fail-on-improvement - --path-prefix="../cpython-ro-srcdir/" - - name: Remount sources writable for tests - # some tests write to srcdir, lack of pyc files slows down testing - run: sudo mount "$CPYTHON_RO_SRCDIR" -oremount,rw - - name: Tests - working-directory: ${{ env.CPYTHON_BUILDDIR }} - run: xvfb-run make ci diff --git a/.github/workflows/reusable-wasi.yml b/.github/workflows/reusable-wasi.yml deleted file mode 100644 index 6beb91e66d4027..00000000000000 --- a/.github/workflows/reusable-wasi.yml +++ /dev/null @@ -1,84 +0,0 @@ -name: Reusable WASI - -on: - workflow_call: - inputs: - config_hash: - required: true - type: string - -env: - FORCE_COLOR: 1 - -jobs: - build-wasi-reusable: - name: 'build and test' - runs-on: ubuntu-24.04 - timeout-minutes: 60 - env: - WASMTIME_VERSION: 22.0.0 - WASI_SDK_VERSION: 24 - WASI_SDK_PATH: /opt/wasi-sdk - CROSS_BUILD_PYTHON: cross-build/build - CROSS_BUILD_WASI: cross-build/wasm32-wasip1 - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - # No problem resolver registered as one doesn't currently exist for Clang. - - name: "Install wasmtime" - uses: bytecodealliance/actions/wasmtime/setup@v1 - with: - version: ${{ env.WASMTIME_VERSION }} - - name: "Restore WASI SDK" - id: cache-wasi-sdk - uses: actions/cache@v4 - with: - path: ${{ env.WASI_SDK_PATH }} - key: ${{ runner.os }}-wasi-sdk-${{ env.WASI_SDK_VERSION }} - - name: "Install WASI SDK" # Hard-coded to x64. - if: steps.cache-wasi-sdk.outputs.cache-hit != 'true' - run: | - mkdir "${WASI_SDK_PATH}" && \ - curl -s -S --location "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VERSION}/wasi-sdk-${WASI_SDK_VERSION}.0-x86_64-linux.tar.gz" | \ - tar --strip-components 1 --directory "${WASI_SDK_PATH}" --extract --gunzip - - name: "Configure ccache action" - uses: hendrikmuhs/ccache-action@v1.2 - with: - save: ${{ github.event_name == 'push' }} - max-size: "200M" - - name: "Add ccache to PATH" - run: echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV" - - name: "Install Python" - uses: actions/setup-python@v5 - with: - python-version: '3.x' - - name: "Runner image version" - run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV" - - name: "Restore Python build config.cache" - uses: actions/cache@v4 - with: - path: ${{ env.CROSS_BUILD_PYTHON }}/config.cache - # Include env.pythonLocation in key to avoid changes in environment when setup-python updates Python. - # Include the hash of `Tools/wasm/wasi.py` as it may change the environment variables. - # (Make sure to keep the key in sync with the other config.cache step below.) - key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ env.WASI_SDK_VERSION }}-${{ env.WASMTIME_VERSION }}-${{ inputs.config_hash }}-${{ hashFiles('Tools/wasm/wasi.py') }}-${{ env.pythonLocation }} - - name: "Configure build Python" - run: python3 Tools/wasm/wasi.py configure-build-python -- --config-cache --with-pydebug - - name: "Make build Python" - run: python3 Tools/wasm/wasi.py make-build-python - - name: "Restore host config.cache" - uses: actions/cache@v4 - with: - path: ${{ env.CROSS_BUILD_WASI }}/config.cache - # Should be kept in sync with the other config.cache step above. - key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ env.WASI_SDK_VERSION }}-${{ env.WASMTIME_VERSION }}-${{ inputs.config_hash }}-${{ hashFiles('Tools/wasm/wasi.py') }}-${{ env.pythonLocation }} - - name: "Configure host" - # `--with-pydebug` inferred from configure-build-python - run: python3 Tools/wasm/wasi.py configure-host -- --config-cache - - name: "Make host" - run: python3 Tools/wasm/wasi.py make-host - - name: "Display build info" - run: make --directory "${CROSS_BUILD_WASI}" pythoninfo - - name: "Test" - run: make --directory "${CROSS_BUILD_WASI}" test diff --git a/.github/workflows/reusable-windows-msi.yml b/.github/workflows/reusable-windows-msi.yml deleted file mode 100644 index a50de344bba4da..00000000000000 --- a/.github/workflows/reusable-windows-msi.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Reusable Windows MSI - -on: - workflow_call: - inputs: - arch: - description: CPU architecture - required: true - type: string - -permissions: - contents: read - -env: - FORCE_COLOR: 1 - -jobs: - build: - name: installer for ${{ inputs.arch }} - runs-on: ${{ inputs.arch == 'arm64' && 'windows-11-arm' || 'windows-latest' }} - timeout-minutes: 60 - env: - ARCH: ${{ inputs.arch }} - IncludeFreethreaded: true - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - name: Build CPython installer - run: ./Tools/msi/build.bat --doc -"${ARCH}" - shell: bash diff --git a/.github/workflows/reusable-windows.yml b/.github/workflows/reusable-windows.yml deleted file mode 100644 index 37c802095b0f2f..00000000000000 --- a/.github/workflows/reusable-windows.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: Reusable Windows - -on: - workflow_call: - inputs: - arch: - description: CPU architecture - required: true - type: string - free-threading: - description: Whether to compile CPython in free-threading mode - required: false - type: boolean - default: false - -env: - FORCE_COLOR: 1 - IncludeUwp: >- - true - -jobs: - build: - name: Build and test (${{ inputs.arch }}) - runs-on: ${{ inputs.arch == 'arm64' && 'windows-11-arm' || 'windows-latest' }} - timeout-minutes: 60 - env: - ARCH: ${{ inputs.arch }} - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - name: Register MSVC problem matcher - if: inputs.arch != 'Win32' - run: echo "::add-matcher::.github/problem-matchers/msvc.json" - - name: Build CPython - run: >- - .\\PCbuild\\build.bat - -e -d -v - -p "${ARCH}" - ${{ fromJSON(inputs.free-threading) && '--disable-gil' || '' }} - shell: bash - - name: Display build info - run: .\\python.bat -m test.pythoninfo - - name: Tests - run: >- - .\\PCbuild\\rt.bat - -p "${ARCH}" - -d -q --fast-ci - ${{ fromJSON(inputs.free-threading) && '--disable-gil' || '' }} - shell: bash diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml deleted file mode 100644 index febb2dd823a8fe..00000000000000 --- a/.github/workflows/stale.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Mark stale pull requests - -on: - schedule: - - cron: "0 */6 * * *" - -jobs: - stale: - if: github.repository_owner == 'python' - runs-on: ubuntu-latest - permissions: - pull-requests: write - timeout-minutes: 10 - - steps: - - name: "Check PRs" - uses: actions/stale@v9 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - stale-pr-message: 'This PR is stale because it has been open for 30 days with no activity.' - stale-pr-label: 'stale' - days-before-issue-stale: -1 - days-before-pr-stale: 30 - days-before-close: -1 - ascending: true - operations-per-run: 120 diff --git a/.github/workflows/tail-call.yml b/.github/workflows/tail-call.yml deleted file mode 100644 index 4636372e26c41b..00000000000000 --- a/.github/workflows/tail-call.yml +++ /dev/null @@ -1,140 +0,0 @@ -name: Tail calling interpreter -on: - pull_request: - paths: - - '.github/workflows/tail-call.yml' - - 'Python/bytecodes.c' - - 'Python/ceval.c' - - 'Python/ceval_macros.h' - - 'Python/generated_cases.c.h' - push: - paths: - - '.github/workflows/tail-call.yml' - - 'Python/bytecodes.c' - - 'Python/ceval.c' - - 'Python/ceval_macros.h' - - 'Python/generated_cases.c.h' - workflow_dispatch: - -permissions: - contents: read - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -env: - FORCE_COLOR: 1 - -jobs: - tail-call: - name: ${{ matrix.target }} - runs-on: ${{ matrix.runner }} - timeout-minutes: 90 - strategy: - fail-fast: false - matrix: - target: -# Un-comment as we add support for more platforms for tail-calling interpreters. -# - i686-pc-windows-msvc/msvc - - x86_64-pc-windows-msvc/msvc -# - aarch64-pc-windows-msvc/msvc - - x86_64-apple-darwin/clang - - aarch64-apple-darwin/clang - - x86_64-unknown-linux-gnu/gcc - - aarch64-unknown-linux-gnu/gcc - - free-threading - llvm: - - 20 - include: -# - target: i686-pc-windows-msvc/msvc -# architecture: Win32 -# runner: windows-latest - - target: x86_64-pc-windows-msvc/msvc - architecture: x64 - runner: windows-latest -# - target: aarch64-pc-windows-msvc/msvc -# architecture: ARM64 -# runner: windows-latest - - target: x86_64-apple-darwin/clang - architecture: x86_64 - runner: macos-13 - - target: aarch64-apple-darwin/clang - architecture: aarch64 - runner: macos-14 - - target: x86_64-unknown-linux-gnu/gcc - architecture: x86_64 - runner: ubuntu-24.04 - - target: aarch64-unknown-linux-gnu/gcc - architecture: aarch64 - runner: ubuntu-24.04-arm - - target: free-threading - architecture: x86_64 - runner: ubuntu-24.04 - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - uses: actions/setup-python@v5 - with: - python-version: '3.11' - - - name: Native Windows (debug) - if: runner.os == 'Windows' && matrix.architecture != 'ARM64' - shell: cmd - run: | - choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}.1.0 - set PlatformToolset=clangcl - set LLVMToolsVersion=${{ matrix.llvm }}.1.0 - set LLVMInstallDir=C:\Program Files\LLVM - call ./PCbuild/build.bat --tail-call-interp -d -p ${{ matrix.architecture }} - call ./PCbuild/rt.bat -d -p ${{ matrix.architecture }} -q --multiprocess 0 --timeout 4500 --verbose2 --verbose3 - - # No tests (yet): - - name: Emulated Windows (release) - if: runner.os == 'Windows' && matrix.architecture == 'ARM64' - shell: cmd - run: | - choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}.1.0 - set PlatformToolset=clangcl - set LLVMToolsVersion=${{ matrix.llvm }}.1.0 - set LLVMInstallDir=C:\Program Files\LLVM - ./PCbuild/build.bat --tail-call-interp -p ${{ matrix.architecture }} - - # The `find` line is required as a result of https://github.com/actions/runner-images/issues/9966. - # This is a bug in the macOS runner image where the pre-installed Python is installed in the same - # directory as the Homebrew Python, which causes the build to fail for macos-13. This line removes - # the symlink to the pre-installed Python so that the Homebrew Python is used instead. - # Note: when a new LLVM is released, the homebrew installation directory changes, so the builds will fail. - # We either need to upgrade LLVM or change the directory being pointed to. - - name: Native macOS (release) - if: runner.os == 'macOS' - run: | - brew update - find /usr/local/bin -lname '*/Library/Frameworks/Python.framework/*' -delete - brew install llvm@${{ matrix.llvm }} - export SDKROOT="$(xcrun --show-sdk-path)" - export PATH="/usr/local/opt/llvm/bin:$PATH" - export PATH="/opt/homebrew/opt/llvm/bin:$PATH" - CC=clang-20 ./configure --with-tail-call-interp - make all --jobs 4 - ./python.exe -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3 - - - name: Native Linux (debug) - if: runner.os == 'Linux' && matrix.target != 'free-threading' - run: | - sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }} - export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH" - CC=clang-20 ./configure --with-tail-call-interp --with-pydebug - make all --jobs 4 - ./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3 - - - name: Native Linux with free-threading (release) - if: matrix.target == 'free-threading' - run: | - sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }} - export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH" - CC=clang-20 ./configure --with-tail-call-interp --disable-gil - make all --jobs 4 - ./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3 - diff --git a/.github/workflows/verify-ensurepip-wheels.yml b/.github/workflows/verify-ensurepip-wheels.yml deleted file mode 100644 index 463e7bf3355cc3..00000000000000 --- a/.github/workflows/verify-ensurepip-wheels.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Verify bundled wheels - -on: - workflow_dispatch: - push: - paths: - - 'Lib/ensurepip/_bundled/**' - - '.github/workflows/verify-ensurepip-wheels.yml' - - 'Tools/build/verify_ensurepip_wheels.py' - pull_request: - paths: - - 'Lib/ensurepip/_bundled/**' - - '.github/workflows/verify-ensurepip-wheels.yml' - - 'Tools/build/verify_ensurepip_wheels.py' - -permissions: - contents: read - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - verify: - runs-on: ubuntu-latest - timeout-minutes: 10 - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - uses: actions/setup-python@v5 - with: - python-version: '3' - - name: Compare checksum of bundled wheels to the ones published on PyPI - run: ./Tools/build/verify_ensurepip_wheels.py diff --git a/Tools/build/compute-changes.py b/Tools/build/compute-changes.py index b3be7df2dba6d0..dd521bd1b998ac 100644 --- a/Tools/build/compute-changes.py +++ b/Tools/build/compute-changes.py @@ -59,9 +59,7 @@ def compute_changes() -> None: target_branch, head_branch = git_branches() if target_branch and head_branch: # Getting changed files only makes sense on a pull request - files = get_changed_files( - f"origin/{target_branch}", f"origin/{head_branch}" - ) + files = get_changed_files(target_branch, head_branch) outputs = process_changed_files(files) else: # Otherwise, just run the tests @@ -90,14 +88,14 @@ def compute_changes() -> None: def git_branches() -> tuple[str, str]: - target_branch = os.environ.get("GITHUB_BASE_REF", "") - target_branch = target_branch.removeprefix("refs/heads/") - print(f"target branch: {target_branch!r}") + target_ref = os.environ.get("CCF_TARGET_REF", "") + target_ref = target_ref.removeprefix("refs/heads/") + print(f"target ref: {target_ref!r}") - head_branch = os.environ.get("GITHUB_HEAD_REF", "") - head_branch = head_branch.removeprefix("refs/heads/") - print(f"head branch: {head_branch!r}") - return target_branch, head_branch + head_ref = os.environ.get("CCF_HEAD_REF", "") + head_ref = head_ref.removeprefix("refs/heads/") + print(f"head ref: {head_ref!r}") + return f"origin/{target_ref}", head_ref def get_changed_files( @@ -109,6 +107,11 @@ def get_changed_files( changed_files_result = subprocess.run( args, stdout=subprocess.PIPE, check=True, encoding="utf-8" ) + print() + print() + print(changed_files_result.stdout.strip()) + print() + print() changed_files = changed_files_result.stdout.strip().splitlines() return frozenset(map(Path, filter(None, map(str.strip, changed_files))))