Fix pex.pex_bootstrapper.bootstrap_pex_env
leak. (#2184)
#1998
This file contains 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: CI | |
on: [push, pull_request] | |
defaults: | |
run: | |
shell: bash | |
env: | |
_PEX_TEST_PYENV_ROOT: .pyenv_test | |
# We use this to skip exposing same-versioned Pythons present on Linux hosts. These otherwise can | |
# collide when attempting to load libpython<major>.<minor><flags>.so and lead to mysterious errors | |
# importing builtins like `fcntl` as outlined in https://github.com/pantsbuild/pex/issues/1391. | |
_PEX_TEST_PYENV_VERSIONS: "2.7 3.7 3.10" | |
concurrency: | |
group: CI-${{ github.ref }} | |
# Queue on all branches and tags, but only cancel overlapping PR burns. | |
cancel-in-progress: ${{ github.ref != 'refs/heads/main' || !startsWith(github.ref, 'refs/tags/') }} | |
jobs: | |
org-check: | |
name: Check GitHub Organization | |
if: github.repository_owner == 'pantsbuild' | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Noop | |
run: "true" | |
checks: | |
name: TOXENV=format-check,typecheck,vendor-check,package -- --additional-format sdist --additional-format wheel | |
needs: org-check | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout Pex | |
uses: actions/checkout@v3 | |
with: | |
# We need branches and tags since package leans on `git describe`. Passing 0 gets us | |
# complete history. | |
fetch-depth: 0 | |
- name: Setup Python 3.8 | |
uses: actions/setup-python@v4 | |
with: | |
# We need to keep Python 3.8 for consistent vendoring with tox. | |
python-version: "3.8" | |
- name: Check Formatting, Types, Vendoring and Packaging | |
uses: pantsbuild/actions/run-tox@e63d2d0e3c339bdffbe5e51e7c39550e3bc527bb | |
with: | |
tox-env: format-check,typecheck,vendor-check,package -- --additional-format sdist --additional-format wheel | |
cpython-unit-tests: | |
name: (${{ matrix.os }}) Pip ${{ matrix.pip-version }} TOXENV=py${{ matrix.python-version[0] }}${{ matrix.python-version[1] }} | |
needs: org-check | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- os: macos-12 | |
python-version: [ 3, 11 ] | |
pip-version: 20 | |
tox-env-python: python | |
- os: ubuntu-22.04 | |
python-version: [ 3, 11 ] | |
pip-version: 20 | |
tox-env-python: python | |
- os: ubuntu-22.04 | |
python-version: [ 3, 11 ] | |
pip-version: 22_3_1 | |
tox-env-python: python | |
- os: ubuntu-22.04 | |
python-version: [ 3, 11 ] | |
pip-version: 23_1_2 | |
tox-env-python: python | |
- os: macos-12 | |
python-version: [ 3, 12, "0-beta.4" ] | |
pip-version: 23_2 | |
tox-env-python: python3.11 | |
- os: ubuntu-22.04 | |
python-version: [ 3, 12, "0-beta.4" ] | |
pip-version: 23_2 | |
tox-env-python: python3.11 | |
steps: | |
- name: Calculate Pythons to Expose | |
id: calculate-pythons-to-expose | |
run: | | |
skip="" | |
if [[ "$(uname -s)" == "Linux" ]]; then | |
skip="${{ env._PEX_TEST_PYENV_VERSIONS }}" | |
fi | |
echo "skip=${skip}" >> $GITHUB_OUTPUT | |
- name: Checkout Pex | |
uses: actions/checkout@v3 | |
- name: Setup Python ${{ join(matrix.python-version, '.') }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "${{ join(matrix.python-version, '.') }}" | |
- name: Expose Pythons | |
uses: pantsbuild/actions/expose-pythons@e63d2d0e3c339bdffbe5e51e7c39550e3bc527bb | |
with: | |
skip: "${{ steps.calculate-pythons-to-expose.outputs.skip }}" | |
- name: Cache Pyenv Interpreters | |
uses: actions/cache@v3 | |
with: | |
path: ${{ env._PEX_TEST_PYENV_ROOT }} | |
key: ${{ matrix.os }}-${{ runner.arch }}-pyenv-root-v1 | |
- name: Run Unit Tests | |
uses: pantsbuild/actions/run-tox@addae8ed8cce2b0a359f447d1bb2ec69ff18f9ca | |
with: | |
python: ${{ matrix.tox-env-python }} | |
tox-env: py${{ matrix.python-version[0] }}${{ matrix.python-version[1] }}-pip${{ matrix.pip-version }} | |
cpython-unit-tests-legacy: | |
name: (${{ matrix.os }}) Pip ${{ matrix.pip-version }} TOXENV=py${{ matrix.python-version[0] }}${{ matrix.python-version[1] }} | |
needs: org-check | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- os: macos-12 | |
python-version: [ 2, 7, 18 ] | |
pip-version: 20 | |
- os: ubuntu-22.04 | |
python-version: [ 2, 7, 18 ] | |
pip-version: 20 | |
# Ubuntu 20.04 is required to avoid inscrutable errors with Python 3.5 trying to use | |
# python3.10 libpython.so. | |
- os: ubuntu-20.04 | |
python-version: [ 3, 5, 10 ] | |
pip-version: 20 | |
steps: | |
- name: Calculate Pythons to Expose | |
id: calculate-pythons-to-expose | |
run: | | |
skip="" | |
if [[ "$(uname -s)" == "Linux" ]]; then | |
skip="${{ env._PEX_TEST_PYENV_VERSIONS }}" | |
fi | |
echo "skip=${skip}" >> $GITHUB_OUTPUT | |
- name: Checkout Pex | |
uses: actions/checkout@v3 | |
- name: Setup Python ${{ join(matrix.python-version, '.') }} | |
uses: pantsbuild/actions/pyenv@1356087bfd1be04670c2ffde4ba94a9c6898ecd7 | |
with: | |
python-version: "${{ join(matrix.python-version, '.') }}" | |
- name: Expose Pythons | |
uses: pantsbuild/actions/expose-pythons@e63d2d0e3c339bdffbe5e51e7c39550e3bc527bb | |
with: | |
skip: "${{ steps.calculate-pythons-to-expose.outputs.skip }}" | |
- name: Cache Pyenv Interpreters | |
uses: actions/cache@v3 | |
with: | |
path: ${{ env._PEX_TEST_PYENV_ROOT }} | |
key: ${{ matrix.os }}-${{ runner.arch }}-pyenv-root-v1 | |
- name: Run Unit Tests | |
run: | | |
pip install -U tox | |
tox -e py${{ matrix.python-version[0] }}${{ matrix.python-version[1] }}-pip${{ matrix.pip-version }} | |
pypy-unit-tests: | |
name: (PyPy ${{ join(matrix.pypy-version, '.') }}) Pip ${{ matrix.pip-version }} TOXENV=pypy${{ join(matrix.pypy-version, '') }} | |
needs: org-check | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
# N.B.: We need 20.04 for PyPy 2.7 tool cache support. | |
- os: ubuntu-20.04 | |
pypy-version: [ 2, 7 ] | |
pip-version: 20 | |
- os: ubuntu-22.04 | |
pypy-version: [ 3, 9 ] | |
pip-version: 20 | |
- os: ubuntu-22.04 | |
pypy-version: [ 3, 9 ] | |
pip-version: 22_3_1 | |
- os: ubuntu-22.04 | |
pypy-version: [ 3, 9 ] | |
pip-version: 23_1_2 | |
steps: | |
- name: Calculate Pythons to Expose | |
id: calculate-pythons-to-expose | |
run: | | |
skip="" | |
if [[ "$(uname -s)" == "Linux" ]]; then | |
skip="${{ env._PEX_TEST_PYENV_VERSIONS }}" | |
fi | |
echo "skip=${skip}" >> $GITHUB_OUTPUT | |
- name: Checkout Pex | |
uses: actions/checkout@v3 | |
- name: Setup PyPy ${{ join(matrix.pypy-version, '.') }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "pypy-${{ join(matrix.pypy-version, '.') }}" | |
- name: Expose Pythons | |
uses: pantsbuild/actions/expose-pythons@e63d2d0e3c339bdffbe5e51e7c39550e3bc527bb | |
with: | |
skip: "${{ steps.calculate-pythons-to-expose.outputs.skip }}" | |
- name: Cache Pyenv Interpreters | |
uses: actions/cache@v3 | |
with: | |
path: ${{ env._PEX_TEST_PYENV_ROOT }} | |
key: ${{ matrix.os }}-${{ runner.arch }}-pyenv-root-v1 | |
- name: Run Unit Tests | |
uses: pantsbuild/actions/run-tox@e63d2d0e3c339bdffbe5e51e7c39550e3bc527bb | |
with: | |
tox-env: pypy${{ join(matrix.pypy-version, '') }}-pip${{ matrix.pip-version }} | |
cpython-integration-tests: | |
name: (${{ matrix.os }}) Pip ${{ matrix.pip-version }} TOXENV=py${{ matrix.python-version[0] }}${{ matrix.python-version[1] }}-integration | |
needs: org-check | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- os: macos-12 | |
python-version: [ 3, 11 ] | |
pip-version: 20 | |
tox-env-python: python | |
- os: ubuntu-22.04 | |
python-version: [ 3, 11 ] | |
pip-version: 20 | |
tox-env-python: python | |
- os: ubuntu-22.04 | |
python-version: [ 3, 11 ] | |
pip-version: 22_3_1 | |
tox-env-python: python | |
- os: ubuntu-22.04 | |
python-version: [ 3, 11 ] | |
pip-version: 23_1_2 | |
tox-env-python: python | |
- os: macos-12 | |
python-version: [ 3, 12, "0-beta.4" ] | |
pip-version: 23_2 | |
tox-env-python: python3.11 | |
- os: ubuntu-22.04 | |
python-version: [ 3, 12, "0-beta.4" ] | |
pip-version: 23_2 | |
tox-env-python: python3.11 | |
steps: | |
- name: Calculate Pythons to Expose | |
id: calculate-pythons-to-expose | |
run: | | |
skip="" | |
if [[ "$(uname -s)" == "Linux" ]]; then | |
skip="${{ env._PEX_TEST_PYENV_VERSIONS }}" | |
fi | |
echo "skip=${skip}" >> $GITHUB_OUTPUT | |
- name: Checkout Pex | |
uses: actions/checkout@v3 | |
with: | |
# We need branches and tags for some ITs. | |
fetch-depth: 0 | |
- name: Setup Python ${{ join(matrix.python-version, '.') }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "${{ join(matrix.python-version, '.') }}" | |
- name: Expose Pythons | |
uses: pantsbuild/actions/expose-pythons@e63d2d0e3c339bdffbe5e51e7c39550e3bc527bb | |
with: | |
skip: "${{ steps.calculate-pythons-to-expose.outputs.skip }}" | |
- name: Cache Pyenv Interpreters | |
uses: actions/cache@v3 | |
with: | |
path: ${{ env._PEX_TEST_PYENV_ROOT }} | |
key: ${{ matrix.os }}-${{ runner.arch }}-pyenv-root-v1 | |
- name: Setup SSH Agent | |
uses: webfactory/[email protected] | |
env: | |
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | |
if: env.SSH_PRIVATE_KEY != '' | |
with: | |
ssh-private-key: ${{ env.SSH_PRIVATE_KEY }} | |
- name: Run Integration Tests | |
uses: pantsbuild/actions/run-tox@addae8ed8cce2b0a359f447d1bb2ec69ff18f9ca | |
with: | |
python: ${{ matrix.tox-env-python }} | |
tox-env: py${{ matrix.python-version[0] }}${{ matrix.python-version[1] }}-pip${{ matrix.pip-version }}-integration | |
cpython-integration-tests-legacy: | |
name: (${{ matrix.os }}) Pip ${{ matrix.pip-version }} TOXENV=py${{ matrix.python-version[0] }}${{ matrix.python-version[1] }}-integration | |
needs: org-check | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- os: macos-12 | |
python-version: [ 2, 7, 18 ] | |
pip-version: 20 | |
- os: ubuntu-22.04 | |
python-version: [ 2, 7, 18 ] | |
pip-version: 20 | |
- os: ubuntu-22.04 | |
python-version: [ 3, 7, 17 ] | |
pip-version: 22_3_1 | |
- os: ubuntu-22.04 | |
python-version: [ 3, 7, 17 ] | |
pip-version: 23_1_2 | |
steps: | |
- name: Calculate Pythons to Expose | |
id: calculate-pythons-to-expose | |
run: | | |
skip="" | |
if [[ "$(uname -s)" == "Linux" ]]; then | |
skip="${{ env._PEX_TEST_PYENV_VERSIONS }}" | |
fi | |
echo "skip=${skip}" >> $GITHUB_OUTPUT | |
- name: Checkout Pex | |
uses: actions/checkout@v3 | |
with: | |
# We need branches and tags for some ITs. | |
fetch-depth: 0 | |
- name: Setup Python ${{ join(matrix.python-version, '.') }} | |
uses: pantsbuild/actions/pyenv@1356087bfd1be04670c2ffde4ba94a9c6898ecd7 | |
with: | |
python-version: "${{ join(matrix.python-version, '.') }}" | |
- name: Expose Pythons | |
uses: pantsbuild/actions/expose-pythons@e63d2d0e3c339bdffbe5e51e7c39550e3bc527bb | |
with: | |
skip: "${{ steps.calculate-pythons-to-expose.outputs.skip }}" | |
- name: Cache Pyenv Interpreters | |
uses: actions/cache@v3 | |
with: | |
path: ${{ env._PEX_TEST_PYENV_ROOT }} | |
key: ${{ matrix.os }}-${{ runner.arch }}-pyenv-root-v1 | |
- name: Setup SSH Agent | |
uses: webfactory/[email protected] | |
env: | |
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | |
if: env.SSH_PRIVATE_KEY != '' | |
with: | |
ssh-private-key: ${{ env.SSH_PRIVATE_KEY }} | |
- name: Run Integration Tests | |
run: | | |
pip install -U tox | |
tox -e py${{ matrix.python-version[0] }}${{ matrix.python-version[1] }}-pip${{ matrix.pip-version }}-integration | |
pypy-integration-tests: | |
name: (PyPy ${{ join(matrix.pypy-version, '.') }}) Pip ${{ matrix.pip-version }} TOXENV=pypy${{ join(matrix.pypy-version, '') }}-integration | |
needs: org-check | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
# N.B.: We need 20.04 for PyPy 2.7 tool cache support. | |
- os: ubuntu-20.04 | |
pypy-version: [ 2, 7 ] | |
pip-version: 20 | |
- os: ubuntu-22.04 | |
pypy-version: [ 3, 9 ] | |
pip-version: 20 | |
- os: ubuntu-22.04 | |
pypy-version: [ 3, 9 ] | |
pip-version: 22_3_1 | |
- os: ubuntu-22.04 | |
pypy-version: [ 3, 9 ] | |
pip-version: 23_1_2 | |
steps: | |
- name: Calculate Pythons to Expose | |
id: calculate-pythons-to-expose | |
run: | | |
skip="" | |
if [[ "$(uname -s)" == "Linux" ]]; then | |
skip="${{ env._PEX_TEST_PYENV_VERSIONS }}" | |
fi | |
echo "skip=${skip}" >> $GITHUB_OUTPUT | |
- name: Checkout Pex | |
uses: actions/checkout@v3 | |
with: | |
# We need branches and tags for some ITs. | |
fetch-depth: 0 | |
- name: Setup PyPy ${{ join(matrix.pypy-version, '.') }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "pypy-${{ join(matrix.pypy-version, '.') }}" | |
- name: Expose Pythons | |
uses: pantsbuild/actions/expose-pythons@e63d2d0e3c339bdffbe5e51e7c39550e3bc527bb | |
with: | |
skip: "${{ steps.calculate-pythons-to-expose.outputs.skip }}" | |
- name: Install Packages | |
run: | | |
# This is needed for `test_requirement_file_from_url` for building `lxml`. | |
sudo apt install --yes libxslt-dev | |
- name: Cache Pyenv Interpreters | |
uses: actions/cache@v3 | |
with: | |
path: ${{ env._PEX_TEST_PYENV_ROOT }} | |
key: ${{ matrix.os }}-${{ runner.arch }}-pyenv-root-v1 | |
- name: Setup SSH Agent | |
uses: webfactory/[email protected] | |
env: | |
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | |
if: env.SSH_PRIVATE_KEY != '' | |
with: | |
ssh-private-key: ${{ env.SSH_PRIVATE_KEY }} | |
- name: Run Integration Tests | |
uses: pantsbuild/actions/run-tox@e63d2d0e3c339bdffbe5e51e7c39550e3bc527bb | |
with: | |
tox-env: pypy${{ join(matrix.pypy-version, '') }}-pip${{ matrix.pip-version }}-integration | |
final-status: | |
name: Gather Final Status | |
needs: | |
- checks | |
- cpython-unit-tests | |
- cpython-unit-tests-legacy | |
- pypy-unit-tests | |
- cpython-integration-tests | |
- cpython-integration-tests-legacy | |
- pypy-integration-tests | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Check Non-Success | |
if: | | |
contains(needs.*.result, 'cancelled') || | |
contains(needs.*.result, 'failure') || | |
contains(needs.*.result, 'skipped') | |
run: "false" | |
- name: Success | |
run: "true" |