2022-05-23 00:36:39 +00:00
|
|
|
name: modified_scripts
|
|
|
|
on: [pull_request]
|
|
|
|
jobs:
|
|
|
|
discover_modified_scripts:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
|
|
versions: ${{steps.modified-versions.outputs.versions}}
|
|
|
|
steps:
|
2023-12-12 05:04:41 +00:00
|
|
|
- uses: actions/checkout@v4
|
2022-05-23 00:36:39 +00:00
|
|
|
- run: git fetch origin "$GITHUB_BASE_REF"
|
|
|
|
- shell: bash
|
|
|
|
run: >
|
|
|
|
versions=$(git diff "origin/$GITHUB_BASE_REF" --name-only -z
|
|
|
|
| perl -ne 'BEGIN {$\="\n";$/="\0";} chomp;
|
2022-09-02 23:11:33 +00:00
|
|
|
if (/^plugins\/python-build\/share\/python-build\/(?:([^\/]+)|patches\/([^\/]+)\/.*)$/ and -e $& )
|
2022-05-23 00:36:39 +00:00
|
|
|
{ print $1.$2; }' \
|
|
|
|
| sort -u);
|
2023-04-23 14:37:16 +00:00
|
|
|
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64);
|
|
|
|
echo "versions<<$EOF" >> $GITHUB_ENV;
|
|
|
|
echo "$versions" >> $GITHUB_ENV;
|
|
|
|
echo "$EOF" >> $GITHUB_ENV;
|
2022-05-23 00:36:39 +00:00
|
|
|
- id: modified-versions
|
|
|
|
run: |
|
|
|
|
echo -n "::set-output name=versions::"
|
|
|
|
echo "${{ env.versions }}" | jq -R . | jq -sc .
|
|
|
|
macos_build:
|
|
|
|
needs: discover_modified_scripts
|
|
|
|
if: needs.discover_modified_scripts.outputs.versions != '[""]'
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
python-version: ${{fromJson(needs.discover_modified_scripts.outputs.versions)}}
|
2024-07-01 19:38:06 +00:00
|
|
|
os: ["macos-13", "macos-14"]
|
2022-05-23 00:36:39 +00:00
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
steps:
|
2023-12-12 05:04:41 +00:00
|
|
|
- uses: actions/checkout@v4
|
2022-05-23 00:36:39 +00:00
|
|
|
- run: |
|
2022-12-10 12:48:28 +00:00
|
|
|
#envvars
|
2022-06-08 17:36:10 +00:00
|
|
|
export PYENV_ROOT="$GITHUB_WORKSPACE"
|
|
|
|
echo "PYENV_ROOT=$PYENV_ROOT" >> $GITHUB_ENV
|
2022-05-23 00:36:39 +00:00
|
|
|
echo "$PYENV_ROOT/shims:$PYENV_ROOT/bin" >> $GITHUB_PATH
|
2022-06-05 22:07:46 +00:00
|
|
|
- run: |
|
2022-12-10 12:48:28 +00:00
|
|
|
#prerequisites
|
|
|
|
brew install openssl openssl@1.1 readline sqlite3 xz zlib
|
|
|
|
if [[ "${{ matrix.python-version }}" =~ pypy.*-(src|dev) ]]; then
|
2022-12-10 19:28:31 +00:00
|
|
|
export PYENV_BOOTSTRAP_VERSION=pypy2.7-7
|
|
|
|
echo "PYENV_BOOTSTRAP_VERSION=$PYENV_BOOTSTRAP_VERSION" >> $GITHUB_ENV
|
|
|
|
pyenv install $PYENV_BOOTSTRAP_VERSION
|
2022-12-10 12:48:28 +00:00
|
|
|
fi
|
|
|
|
- run: |
|
|
|
|
#build
|
2024-05-24 17:36:43 +00:00
|
|
|
pyenv --debug install ${{ matrix.python-version }}
|
2022-06-05 22:07:46 +00:00
|
|
|
pyenv global ${{ matrix.python-version }}
|
2022-09-02 23:20:24 +00:00
|
|
|
# Micropython doesn't support --version
|
2022-12-10 12:48:28 +00:00
|
|
|
- run: |
|
|
|
|
#print version
|
2022-09-02 23:20:24 +00:00
|
|
|
if [[ "${{ matrix.python-version }}" == "micropython-"* ]]; then
|
|
|
|
python -c 'import sys; print(sys.version)'
|
|
|
|
else
|
2022-12-10 12:48:28 +00:00
|
|
|
python --version
|
2022-09-02 23:20:24 +00:00
|
|
|
python -m pip --version
|
|
|
|
fi
|
|
|
|
# Micropython doesn't support sys.executable, os.path, older versions even os
|
|
|
|
- env:
|
2022-05-23 00:36:39 +00:00
|
|
|
EXPECTED_PYTHON: ${{ matrix.python-version }}
|
2022-06-05 22:07:46 +00:00
|
|
|
run: |
|
2022-12-10 12:48:28 +00:00
|
|
|
#check
|
2022-09-02 23:20:24 +00:00
|
|
|
if [[ "${{ matrix.python-version }}" == "micropython-"* ]]; then
|
|
|
|
[[ $(pyenv which python) == "${{ env.PYENV_ROOT }}/versions/${{ matrix.python-version }}/bin/python" ]] || exit 1
|
|
|
|
python -c 'import sys; assert sys.implementation.name == "micropython"'
|
|
|
|
else
|
|
|
|
python -c 'if True:
|
|
|
|
import os, sys, os.path
|
|
|
|
correct_dir = os.path.join(
|
|
|
|
os.environ["PYENV_ROOT"],
|
|
|
|
"versions",
|
|
|
|
os.environ["EXPECTED_PYTHON"],
|
|
|
|
"bin")
|
|
|
|
assert os.path.dirname(sys.executable) == correct_dir'
|
|
|
|
fi
|
2022-06-08 17:36:10 +00:00
|
|
|
# bundled executables in some Anaconda releases cause the post-run step to hang in MacOS
|
|
|
|
- run: |
|
|
|
|
pyenv global system
|
|
|
|
rm -f "$(pyenv root)"/shims/*
|
2022-05-23 00:36:39 +00:00
|
|
|
|
|
|
|
ubuntu_build:
|
|
|
|
needs: discover_modified_scripts
|
|
|
|
if: needs.discover_modified_scripts.outputs.versions != '[""]'
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
python-version: ${{fromJson(needs.discover_modified_scripts.outputs.versions)}}
|
2022-09-03 22:40:00 +00:00
|
|
|
os: ["ubuntu-20.04", "ubuntu-22.04"]
|
2022-05-23 00:36:39 +00:00
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
steps:
|
2023-12-12 05:04:41 +00:00
|
|
|
- uses: actions/checkout@v4
|
2022-05-23 00:36:39 +00:00
|
|
|
- run: |
|
2022-12-10 12:48:28 +00:00
|
|
|
#envvars
|
|
|
|
export PYENV_ROOT="$GITHUB_WORKSPACE"
|
|
|
|
echo "PYENV_ROOT=$PYENV_ROOT" >> $GITHUB_ENV
|
|
|
|
echo "$PYENV_ROOT/shims:$PYENV_ROOT/bin" >> $GITHUB_PATH
|
|
|
|
- run: |
|
|
|
|
#prerequisites
|
2022-09-03 22:40:00 +00:00
|
|
|
sudo apt-get update -q; sudo apt-get install -yq make build-essential \
|
2022-05-23 00:36:39 +00:00
|
|
|
libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev \
|
2022-09-03 22:40:00 +00:00
|
|
|
curl llvm libncurses5-dev libncursesw5-dev \
|
|
|
|
xz-utils tk-dev libffi-dev liblzma-dev
|
2022-12-10 12:48:28 +00:00
|
|
|
if [[ "${{ matrix.python-version }}" =~ pypy.*-(src|dev) ]]; then
|
2022-12-10 19:28:31 +00:00
|
|
|
export PYENV_BOOTSTRAP_VERSION=pypy2.7-7
|
|
|
|
echo "PYENV_BOOTSTRAP_VERSION=$PYENV_BOOTSTRAP_VERSION" >> $GITHUB_ENV
|
|
|
|
pyenv install $PYENV_BOOTSTRAP_VERSION
|
2022-12-10 12:48:28 +00:00
|
|
|
fi
|
2022-06-05 22:07:46 +00:00
|
|
|
- run: |
|
2022-12-10 12:48:28 +00:00
|
|
|
#build
|
2022-09-03 18:43:05 +00:00
|
|
|
pyenv install -v ${{ matrix.python-version }}
|
2022-06-05 22:07:46 +00:00
|
|
|
pyenv global ${{ matrix.python-version }}
|
2022-09-02 23:20:24 +00:00
|
|
|
# Micropython doesn't support --version
|
2022-12-10 12:48:28 +00:00
|
|
|
- run: |
|
|
|
|
#print version
|
2022-09-02 23:20:24 +00:00
|
|
|
if [[ "${{ matrix.python-version }}" == "micropython-"* ]]; then
|
|
|
|
python -c 'import sys; print(sys.version)'
|
|
|
|
else
|
2022-12-10 12:48:28 +00:00
|
|
|
python --version
|
2022-09-02 23:20:24 +00:00
|
|
|
python -m pip --version
|
|
|
|
fi
|
|
|
|
# Micropython doesn't support sys.executable, os.path, older versions even os
|
|
|
|
- env:
|
2022-05-23 00:36:39 +00:00
|
|
|
EXPECTED_PYTHON: ${{ matrix.python-version }}
|
2022-06-05 22:07:46 +00:00
|
|
|
run: |
|
2022-12-10 12:48:28 +00:00
|
|
|
#check
|
2022-09-02 23:20:24 +00:00
|
|
|
if [[ "${{ matrix.python-version }}" == "micropython-"* ]]; then
|
|
|
|
[[ $(pyenv which python) == "${{ env.PYENV_ROOT }}/versions/${{ matrix.python-version }}/bin/python" ]] || exit 1
|
|
|
|
python -c 'import sys; assert sys.implementation.name == "micropython"'
|
|
|
|
else
|
|
|
|
python -c 'if True:
|
|
|
|
import os, sys, os.path
|
|
|
|
correct_dir = os.path.join(
|
|
|
|
os.environ["PYENV_ROOT"],
|
|
|
|
"versions",
|
|
|
|
os.environ["EXPECTED_PYTHON"],
|
|
|
|
"bin")
|
|
|
|
assert os.path.dirname(sys.executable) == correct_dir'
|
|
|
|
fi
|