Skip to content

Use a data-only image for cache in CI. #2150

Use a data-only image for cache in CI.

Use a data-only image for cache in CI. #2150

Workflow file for this run

name: CI
on: [push, pull_request]
defaults:
run:
shell: bash
env:
_PEX_TEST_DEV_ROOT: ${{ github.workspace }}/.pex_dev
_PEX_TEST_POS_ARGS: "--color --devpi --devpi-timeout 15.0 --shutdown-devpi -vvs"
# 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@b16b9cf47cd566acfe217b1dafc5b452e27e6fd7
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-rc.1" ]
# pip-version: 23_2
# tox-env-python: python3.11
- os: ubuntu-22.04
python-version: [ 3, 12, "0-rc.1" ]
pip-version: 23_2
tox-env-python: python3.11
env:
_TOX_ENV: py${{ matrix.python-version[0] }}${{ matrix.python-version[1] }}-pip${{ matrix.pip-version }}
steps:
- name: Prepare Caches
run: |
# Populate the local pex-caches volume from the image.
# N.B.:This trick requires an empty local named volume.
docker volume rm --force pex-caches
docker volume create pex-caches
docker run --rm \
-v pex-caches:/development/pex_dev \
ghcr.io/pantsbuild/pex/cache-all:latest || true
- name: Checkout Pex
uses: actions/checkout@v3
- name: Run Unit Tests
run: |
docker run --rm -it \
-v "${PWD}":/devlopment/pex \
-v pex-caches:/development/pex_dev \
ghcr.io/pantsbuild/pex/base:latest -e ${{ env._TOX_ENV }} -- ${{ env._PEX_TEST_POS_ARGS }}
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
env:
_TOX_ENV: py${{ matrix.python-version[0] }}${{ matrix.python-version[1] }}-pip${{ matrix.pip-version }}
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:
path: repo
- 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_DEV_ROOT }}/pyenv
key: ${{ matrix.os }}-${{ runner.arch }}-pex-test-dev-root-pyenv-v1
- name: Cache Devpi Server
uses: actions/cache@v3
with:
path: ${{ env._PEX_TEST_DEV_ROOT }}/devpi
# We're using a key suffix / restore-keys prefix trick here to get an updatable cache.
# See: https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache
key: ${{ matrix.os }}-${{ runner.arch }}-${{ env._TOX_ENV }}-pex-test-dev-root-devpi-v1-${{ github.run_id }}
restore-keys: ${{ matrix.os }}-${{ runner.arch }}-${{ env._TOX_ENV }}-pex-test-dev-root-devpi-v1
- name: Run Unit Tests
run: |
pip install -U tox
tox -c repo/tox.ini -e ${{ env._TOX_ENV }} -- ${{ env._PEX_TEST_POS_ARGS }}
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
env:
_TOX_ENV: pypy${{ join(matrix.pypy-version, '') }}-pip${{ matrix.pip-version }}
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:
path: repo
- 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_DEV_ROOT }}/pyenv
key: ${{ matrix.os }}-${{ runner.arch }}-pex-test-dev-root-pyenv-v1
- name: Cache Devpi Server
uses: actions/cache@v3
with:
path: ${{ env._PEX_TEST_DEV_ROOT }}/devpi
# We're using a key suffix / restore-keys prefix trick here to get an updatable cache.
# See: https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache
key: ${{ matrix.os }}-${{ runner.arch }}-${{ env._TOX_ENV }}-pex-test-dev-root-devpi-v1-${{ github.run_id }}
restore-keys: ${{ matrix.os }}-${{ runner.arch }}-${{ env._TOX_ENV }}-pex-test-dev-root-devpi-v1
- name: Run Unit Tests
uses: pantsbuild/actions/run-tox@b16b9cf47cd566acfe217b1dafc5b452e27e6fd7
with:
path: repo/tox.ini
tox-env: ${{ env._TOX_ENV }} -- ${{ env._PEX_TEST_POS_ARGS }}
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-rc.1" ]
pip-version: 23_2
tox-env-python: python3.11
- os: ubuntu-22.04
python-version: [ 3, 12, "0-rc.1" ]
pip-version: 23_2
tox-env-python: python3.11
env:
_TOX_ENV: py${{ matrix.python-version[0] }}${{ matrix.python-version[1] }}-pip${{ matrix.pip-version }}-integration
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
path: repo
- 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_DEV_ROOT }}/pyenv
key: ${{ matrix.os }}-${{ runner.arch }}-pex-test-dev-root-pyenv-v1
- name: Cache Devpi Server
uses: actions/cache@v3
with:
path: ${{ env._PEX_TEST_DEV_ROOT }}/devpi
# We're using a key suffix / restore-keys prefix trick here to get an updatable cache.
# See: https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache
key: ${{ matrix.os }}-${{ runner.arch }}-${{ env._TOX_ENV }}-pex-test-dev-root-devpi-v1-${{ github.run_id }}
restore-keys: ${{ matrix.os }}-${{ runner.arch }}-${{ env._TOX_ENV }}-pex-test-dev-root-devpi-v1i Cache
- 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@b16b9cf47cd566acfe217b1dafc5b452e27e6fd7
with:
path: repo/tox.ini
python: ${{ matrix.tox-env-python }}
tox-env: ${{ env._TOX_ENV }} -- ${{ env._PEX_TEST_POS_ARGS }}
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
env:
_TOX_ENV: py${{ matrix.python-version[0] }}${{ matrix.python-version[1] }}-pip${{ matrix.pip-version }}-integration
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
path: repo
- 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_DEV_ROOT }}/pyenv
key: ${{ matrix.os }}-${{ runner.arch }}-pex-test-dev-root-pyenv-v1
- name: Cache Devpi Server
uses: actions/cache@v3
with:
path: ${{ env._PEX_TEST_DEV_ROOT }}/devpi
# We're using a key suffix / restore-keys prefix trick here to get an updatable cache.
# See: https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache
key: ${{ matrix.os }}-${{ runner.arch }}-${{ env._TOX_ENV }}-pex-test-dev-root-devpi-v1-${{ github.run_id }}
restore-keys: ${{ matrix.os }}-${{ runner.arch }}-${{ env._TOX_ENV }}-pex-test-dev-root-devpi-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 -c repo/tox.ini -e ${{ env._TOX_ENV }} -- ${{ env._PEX_TEST_POS_ARGS }}
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
env:
_TOX_ENV: pypy${{ join(matrix.pypy-version, '') }}-pip${{ matrix.pip-version }}-integration
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
path: repo
- 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_DEV_ROOT }}/pyenv
key: ${{ matrix.os }}-${{ runner.arch }}-pex-test-dev-root-pyenv-v1
- name: Cache Devpi Server
uses: actions/cache@v3
with:
path: ${{ env._PEX_TEST_DEV_ROOT }}/devpi
# We're using a key suffix / restore-keys prefix trick here to get an updatable cache.
# See: https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache
key: ${{ matrix.os }}-${{ runner.arch }}-${{ env._TOX_ENV }}-pex-test-dev-root-devpi-v1-${{ github.run_id }}
restore-keys: ${{ matrix.os }}-${{ runner.arch }}-${{ env._TOX_ENV }}-pex-test-dev-root-devpi-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@b16b9cf47cd566acfe217b1dafc5b452e27e6fd7
with:
path: repo/tox.ini
tox-env: ${{ env._TOX_ENV }} -- ${{ env._PEX_TEST_POS_ARGS }}
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"