Skip to content

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

Use a data-only image for cache in CI.

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

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: tox -e format-check,typecheck,vendor-check,package
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
# N.B.: The name of this job key (linux-tests) is depended on by scrips/build_cache_image.py. In
# particular, the tox-env matrix list is used to ensure the cache covers all Linux CI jobs.
linux-tests:
name: ./dtox.sh -e ${{ matrix.tox-env }}
needs: org-check
runs-on: ubuntu-22.04
strategy:
matrix:
tox-env:
- py27-pip20
- py35-pip20
- py311-pip20
- py311-pip22_3_1
- py311-pip23_1_2
- py312-pip23_2
- pypy310-pip20
- pypy310-pip22_3_1
- pypy310-pip23_1_2
- py27-pip20-integration
- py37-pip22_3_1-integration
- py37-pip23_1_2-integration
- py311-pip20-integration
- py311-pip22_3_1-integration
- py311-pip23_1_2-integration
- py312-pip23_2-integration
- pypy310-pip20-integration
- pypy310-pip22_3_1-integration
- pypy310-pip23_1_2-integration
steps:
- name: Checkout Pex
uses: actions/checkout@v3
with:
# We need branches and tags for some ITs.
fetch-depth: 0
# Some ITs need this for VCS URLs of the form git+ssh://[email protected]/...
- 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 Unit Tests
run: |
BASE_MODE=pull CACHE_MODE=pull ./dtox.sh -e ${{ matrix.tox-env }} -- ${{ env._PEX_TEST_POS_ARGS }}
mac-tests:
name: tox -e ${{ matrix.tox-env }}
needs: org-check
runs-on: macos-12
strategy:
matrix:
include:
- python-version: [ 3, 11 ]
tox-env: py311-pip20
tox-env-python: python
- python-version: [ 3, 11 ]
tox-env: py311-pip20-integration
tox-env-python: python
- python-version: [ 3, 12, "0-rc.1" ]
tox-env: py312-pip23_2
tox-env-python: python3.11
- python-version: [ 3, 12, "0-rc.1" ]
tox-env: py312-pip23_2-integration
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
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: macos-12-${{ 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: macos-12-${{ runner.arch }}-${{ matrix.tox-env }}-pex-test-dev-root-devpi-v1-${{ github.run_id }}
restore-keys: macos-12-${{ runner.arch }}-${{ matrix.tox-env }}-pex-test-dev-root-devpi-v1
# Some ITs need this for VCS URLs of the form git+ssh://[email protected]/...
- 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: ${{ matrix.tox-env }} -- ${{ env._PEX_TEST_POS_ARGS }}
final-status:
name: Gather Final Status
needs:
- checks
- linux-tests
- mac-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"