diff --git a/.github/actions/build-python/action.yml b/.github/actions/build-python/action.yml new file mode 100644 index 00000000..fa310e81 --- /dev/null +++ b/.github/actions/build-python/action.yml @@ -0,0 +1,46 @@ +name: Build a Python version +description: > + Install python-build's system dependencies for the current runner's OS, build + and check the requested version. +inputs: + python-version: + description: A version as accepted by `pyenv install`. + required: true +runs: + using: composite + steps: + # The two OSes differ only in this step. + - if: runner.os == 'macOS' + shell: bash + run: | + #prerequisites + brew install openssl readline sqlite3 xz tcl-tk@8 libb2 zstd + - if: runner.os == 'Linux' + shell: bash + run: | + #prerequisites + sudo apt-get update -q; sudo apt install -yq make build-essential libssl-dev zlib1g-dev \ + libbz2-dev libreadline-dev libsqlite3-dev curl \ + libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev + - shell: bash + run: | + #envvars + export PYENV_ROOT="$GITHUB_WORKSPACE" + echo "PYENV_ROOT=$PYENV_ROOT" >> $GITHUB_ENV + echo "$PYENV_ROOT/shims:$PYENV_ROOT/bin" >> $GITHUB_PATH + - shell: bash + run: | + #build + pyenv --debug install ${{ inputs.python-version }} && rc=$? || rc=$? + if [[ $rc -ne 0 ]]; then echo config.log:; cat "${TMPDIR:-/tmp}"/python-build*/*/config.log; false; fi + pyenv global ${{ inputs.python-version }} + pyenv rehash + - shell: bash + run: | + #print version + python --version + python -m pip --version + - shell: python # Prove that actual Python == expected Python + env: + EXPECTED_PYTHON: ${{ inputs.python-version }} + run: import os, sys ; assert sys.version.startswith(os.getenv("EXPECTED_PYTHON")) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..3fc2e674 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,62 @@ +name: build +on: + push: + branches: [master] + pull_request: {} + +permissions: + contents: read + +jobs: + discover_build_logic_change: + if: github.event_name == 'pull_request' + runs-on: ubuntu-slim + env: + FULL_OS_MATRIX: '[ + "macos-14", + "macos-15", + "macos-15-intel", + "macos-26", + "macos-26-intel", + "ubuntu-22.04", + "ubuntu-22.04-arm", + "ubuntu-24.04", + "ubuntu-24.04-arm" + ]' + outputs: + os: ${{ steps.detect.outputs.os }} + steps: + - uses: actions/checkout@v7 + - run: git fetch origin "$GITHUB_BASE_REF" + - id: detect + shell: bash + run: | + if [[ -n $(git diff --name-only "origin/$GITHUB_BASE_REF" -- \ + plugins/python-build/bin/python-build \ + .github/actions/build-python/action.yml \ + .github/workflows/build.yml) ]] + then + printf "%s\n" "os<> "$GITHUB_OUTPUT" + fi + + build: + needs: discover_build_logic_change + # Run when the detection job succeeded *or was skipped* -- but not failed + if: ${{ !cancelled() && !failure() }} + strategy: + fail-fast: false + matrix: + os: ${{ fromJson(needs.discover_build_logic_change.outputs.os || '["macos-latest","ubuntu-latest"]') }} + python-version: + - "3.10" + - "3.11" + - "3.12" + - "3.13" + - "3.14" + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v7 + - uses: ./.github/actions/build-python + with: + python-version: ${{ matrix.python-version }} + diff --git a/.github/workflows/macos_build.yml b/.github/workflows/macos_build.yml deleted file mode 100644 index b30511ac..00000000 --- a/.github/workflows/macos_build.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: macos_build -on: - push: - branches: [master] - pull_request: {} - -permissions: - contents: read # to fetch code (actions/checkout) - -jobs: - macos_build: - strategy: - fail-fast: false - matrix: - python-version: - - "3.10" - - "3.11" - - "3.12" - - "3.13" - - "3.14" - runs-on: macos-latest - steps: - - uses: actions/checkout@v7 - - run: | - brew install openssl readline sqlite3 xz tcl-tk@8 libb2 zstd - - run: | - #envvars - export PYENV_ROOT="$GITHUB_WORKSPACE" - echo "PYENV_ROOT=$PYENV_ROOT" >> $GITHUB_ENV - echo "$PYENV_ROOT/shims:$PYENV_ROOT/bin" >> $GITHUB_PATH - - run: | - #build - pyenv --debug install ${{ matrix.python-version }} && rc=$? || rc=$? - if [[ $rc -ne 0 ]]; then echo config.log:; cat $TMPDIR/python-build*/*/config.log; false; fi - pyenv global ${{ matrix.python-version }} - - run: | - #print version - python --version - python -m pip --version - - shell: python # Prove that actual Python == expected Python - env: - EXPECTED_PYTHON: ${{ matrix.python-version }} - run: import os, sys ; assert sys.version.startswith(os.getenv("EXPECTED_PYTHON")) diff --git a/.github/workflows/ubuntu_build.yml b/.github/workflows/ubuntu_build.yml deleted file mode 100644 index 697f4bd7..00000000 --- a/.github/workflows/ubuntu_build.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: ubuntu_build -on: - push: - branches: [master] - pull_request: {} - -permissions: - contents: read # to fetch code (actions/checkout) - -jobs: - ubuntu_build: - strategy: - fail-fast: false - matrix: - python-version: - - "3.10" - - "3.11" - - "3.12" - - "3.13" - - "3.14" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v7 - - run: | - sudo apt-get update -q; sudo apt install -yq make build-essential libssl-dev zlib1g-dev \ - libbz2-dev libreadline-dev libsqlite3-dev curl \ - libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev - # https://github.com/pyenv/pyenv#installation - - run: pwd - - env: - PYENV_ROOT: /home/runner/work/pyenv/pyenv - run: | - echo $PYENV_ROOT - echo "$PYENV_ROOT/shims:$PYENV_ROOT/bin" >> $GITHUB_PATH - bin/pyenv --debug install ${{ matrix.python-version }} - bin/pyenv global ${{ matrix.python-version }} - bin/pyenv rehash - - run: python --version - - run: python -m pip --version - - shell: python # Prove that actual Python == expected Python - env: - EXPECTED_PYTHON: ${{ matrix.python-version }} - run: import os, sys ; assert sys.version.startswith(os.getenv("EXPECTED_PYTHON"))