Merge pull request #65 from SVF-tools/copilot/fix-execute-notebooks-j… #288
This file contains hidden or 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: svf-python-build | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| triggered_by: | |
| description: 'Repository that triggered this workflow' | |
| required: false | |
| default: 'manual' | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| calculate-version: | |
| name: Calculate Next Version | |
| runs-on: ubuntu-latest | |
| outputs: | |
| next_version: ${{ steps.get_next_version.outputs.next_version }} | |
| steps: | |
| - name: Install jq | |
| run: sudo apt-get update && sudo apt-get install -y jq | |
| - name: Get next version from PyPI | |
| id: get_next_version | |
| run: | | |
| PACKAGE="pysvf" | |
| INDEX_URL="https://pypi.org/pypi/$PACKAGE/json" | |
| echo "Querying $INDEX_URL ..." | |
| VERSIONS=$(curl -s "$INDEX_URL" | jq -r '.releases | keys[]' | grep -E '^1\.0\.0\.[0-9]+$' || true) | |
| if [ -z "$VERSIONS" ]; then | |
| NEXT_VERSION="1.0.0.0" | |
| else | |
| LAST_VERSION=$(echo "$VERSIONS" | sort -V | tail -n 1) | |
| echo "Last version: $LAST_VERSION" | |
| NEXT_VERSION=$(echo "$LAST_VERSION" | awk -F. '{$NF+=1; print $1 "." $2 "." $3 "." $4}') | |
| fi | |
| echo "Next version: $NEXT_VERSION" | |
| echo "next_version=$NEXT_VERSION" >> $GITHUB_OUTPUT | |
| stubtest: | |
| needs: calculate-version | |
| runs-on: ubuntu-24.04 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ['3.9'] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Install system dependencies | |
| run: | | |
| # Avoid ppa:ubuntu-toolchain-r/test — Launchpad's PPA infrastructure | |
| # has been intermittently unreachable from CI runners (HTTP 504 from | |
| # add-apt-repository), and ubuntu-24.04's default gcc-13 is sufficient. | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| cmake gcc g++ nodejs doxygen graphviz lcov libncurses5-dev libtinfo6 libzstd-dev \ | |
| python3 python3-pip python3-venv patchelf | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '16' | |
| - name: Install svf-lib and set environment variables | |
| run: | | |
| npm install svf-lib | |
| echo "SVF_DIR=$PWD/node_modules/svf-lib/SVF-linux-x86_64" >> $GITHUB_ENV | |
| echo "LLVM_DIR=$PWD/node_modules/llvm-21.1.0.obj" >> $GITHUB_ENV | |
| echo "Z3_DIR=$PWD/node_modules/z3.obj" >> $GITHUB_ENV | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install Python dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install build wheel setuptools mypy typing-extensions pybind11 | |
| - name: Get system architecture | |
| id: get_arch | |
| run: | | |
| ARCH=$(uname -m) | |
| echo "ARCH=$ARCH" >> $GITHUB_ENV | |
| echo "arch=$ARCH" >> $GITHUB_OUTPUT | |
| - name: Clone and Build SVF-Python for stubtest | |
| run: | | |
| git clone https://github.com/SVF-tools/SVF-Python.git | |
| cd SVF-Python | |
| rm -rf build dist pysvf.egg-info | |
| export PYBIND11_DIR=$(python3 -m pybind11 --cmakedir) | |
| export CMAKE_BUILD_TYPE=Release | |
| sed -i.bak "s/version=.*,/version='0.0.0.dev0',/" setup.py | |
| SVF_DIR=${SVF_DIR} LLVM_DIR=${LLVM_DIR} Z3_DIR=${Z3_DIR} PYBIND11_DIR=${PYBIND11_DIR} \ | |
| python3 -m build --wheel | |
| pip install dist/*.whl | |
| - name: Run stubtest | |
| run: | | |
| cd SVF-Python | |
| MYPYPATH=./pysvf stubtest pysvf --allowlist ../stubtest_allowlist.txt | |
| build: | |
| needs: [calculate-version, stubtest] | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-22.04, macos-14, ubuntu-22.04-arm] | |
| python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: macOS Setup | |
| if: runner.os == 'macOS' | |
| uses: maxim-lobanov/setup-xcode@v1 | |
| with: | |
| xcode-version: '15.3.0' | |
| - name: macOS Workaround | |
| if: runner.os == 'macOS' | |
| run: | | |
| ln -sfn /Applications/Xcode_15.3.0.app /Applications/Xcode.app | |
| - name: Linux Setup | |
| if: runner.os == 'Linux' | |
| run: | | |
| # Avoid ppa:ubuntu-toolchain-r/test — Launchpad's PPA infrastructure | |
| # has been intermittently unreachable from CI runners (HTTP 504 from | |
| # add-apt-repository), and ubuntu-24.04's default gcc-13 is sufficient. | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| cmake gcc g++ nodejs doxygen graphviz lcov libncurses5-dev libtinfo6 libzstd-dev \ | |
| python3 python3-pip python3-venv patchelf | |
| - name: Install svf-lib and set environment variables | |
| run: | | |
| npm install svf-lib | |
| if [[ "$RUNNER_OS" == "Linux" ]]; then | |
| if [[ "$(uname -m)" == "x86_64" ]]; then | |
| echo "SVF_DIR=$PWD/node_modules/svf-lib/SVF-linux-x86_64" >> $GITHUB_ENV | |
| elif [[ "$(uname -m)" == "aarch64" ]]; then | |
| echo "SVF_DIR=$PWD/node_modules/svf-lib/SVF-linux-aarch64" >> $GITHUB_ENV | |
| fi | |
| elif [[ "$RUNNER_OS" == "macOS" ]]; then | |
| echo "SVF_DIR=$PWD/node_modules/svf-lib/SVF-osx" >> $GITHUB_ENV | |
| fi | |
| echo "LLVM_DIR=$PWD/node_modules/llvm-21.1.0.obj" >> $GITHUB_ENV | |
| echo "Z3_DIR=$PWD/node_modules/z3.obj" >> $GITHUB_ENV | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install Python dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install build wheel twine pybind11 auditwheel setuptools | |
| - name: Get system architecture | |
| id: get_arch | |
| run: | | |
| ARCH=$(uname -m) | |
| echo "ARCH=$ARCH" >> $GITHUB_ENV | |
| echo "arch=$ARCH" >> $GITHUB_OUTPUT | |
| - name: Clone and Build SVF-Python | |
| run: | | |
| git clone https://github.com/SVF-tools/SVF-Python.git | |
| cd SVF-Python | |
| rm -rf build dist pysvf.egg-info | |
| export PYBIND11_DIR=$(python3 -m pybind11 --cmakedir) | |
| export CMAKE_BUILD_TYPE=Release | |
| echo "Building with version: ${{ needs.calculate-version.outputs.next_version }}" | |
| sed -i.bak "s/version=.*,/version='${{ needs.calculate-version.outputs.next_version }}',/" setup.py | |
| PYTHON_EXEC=${PYTHON_EXEC:-python3} | |
| if [[ "$(uname)" == "Darwin" ]]; then | |
| SVF_DIR=${SVF_DIR} LLVM_DIR=${LLVM_DIR} Z3_DIR=${Z3_DIR} PYBIND11_DIR=${PYBIND11_DIR} \ | |
| ${PYTHON_EXEC} setup.py bdist_wheel --plat-name macosx-11.0-arm64 | |
| else | |
| SVF_DIR=${SVF_DIR} LLVM_DIR=${LLVM_DIR} Z3_DIR=${Z3_DIR} PYBIND11_DIR=${PYBIND11_DIR} \ | |
| ${PYTHON_EXEC} setup.py bdist_wheel --plat-name manylinux2014_$(uname -m) | |
| fi | |
| echo "Built wheel files:" | |
| ls -lh dist/ | |
| - name: Publish to PyPI | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
| run: | | |
| cd SVF-Python | |
| twine upload dist/* --verbose | |
| - name: Upload Python wheels | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: python-wheels-${{ needs.calculate-version.outputs.next_version }}-${{ runner.os }}-${{ steps.get_arch.outputs.arch }}-py${{ matrix.python-version }} | |
| path: SVF-Python/dist/ |