From bce8a760e1db7897ade3541a5727ba7397880e3a Mon Sep 17 00:00:00 2001 From: m0wer Date: Fri, 15 May 2026 05:00:56 +0200 Subject: [PATCH] ci: rewrite workflow for python 3.11-3.13 and libsecp256k1 v0.4/v0.7 Replace the legacy CI configuration with a matrix that exercises both the oldest still-supported libsecp256k1 (v0.4.0) and the v0.7.0 series across Python 3.11, 3.12, and 3.13. Add a CMake-based fallback path for building libsecp256k1 v0.6+, which dropped Autotools. Add a dedicated lint job running ruff and mypy via the same hooks that contributors use locally. Remove the obsolete Travis CI configuration. --- .github/workflows/main.yml | 111 ++++++++++++++++++++++++++----------- .travis.yml | 59 -------------------- 2 files changed, 79 insertions(+), 91 deletions(-) delete mode 100644 .travis.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0b319f15..12abd719 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,47 +1,94 @@ -name: Python-bitcointx +name: python-bitcointx on: push: - branches: [ $default-branch ] + branches: [master, main] pull_request: - branches: [ $default-branch ] + branches: [master, main] workflow_dispatch: +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: - build: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.11" + - name: Install tooling + run: | + python -m pip install --upgrade pip + python -m pip install -e ".[dev]" + - name: Ruff lint + run: ruff check . + - name: Ruff format check + run: ruff format --check . + - name: Mypy + run: mypy + test: + needs: lint runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - os: [ubuntu-latest, macOS-latest] - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] + os: [ubuntu-latest, macos-latest] + python-version: ["3.11", "3.12", "3.13"] + # libsecp256k1 v0.4.0 is the documented reference; v0.7.0 is included + # to ensure our compatibility shim (issue #88) keeps working. + libsecp256k1-version: ["v0.4.0", "v0.7.0"] steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - if [ "$RUNNER_OS" == "Linux" ]; then - sudo apt install libtool build-essential autotools-dev libevent-dev libboost-system-dev libboost-filesystem-dev libboost-test-dev libboost-thread-dev - elif [ "$RUNNER_OS" == "macOS" ]; then - brew install automake libtool boost pkg-config libevent - fi - SECP256K1_VERSION=$(grep -A1 '!LIBSECP256K1_VERSION_MARKER_DO_NOT_MOVE_OR_EDIT!' README.md |tail -n 1|sed -E 's/`(v[0-9\.]+)`/\1/g') - sh -c "git clone https://github.com/bitcoin/secp256k1.git /tmp/libsecp256k1 && cd /tmp/libsecp256k1 && git checkout $SECP256K1_VERSION && ./autogen.sh && ./configure --disable-coverage --disable-benchmark --disable-tests --disable-exhaustive-tests --enable-module-recovery --enable-module-ecdh --enable-module-schnorrsig && make && sudo make install" - sh -c "git clone https://github.com/bitcoin/bitcoin.git /tmp/bitcoin && cd /tmp/bitcoin && git checkout v25.0 && ./autogen.sh && ./configure --without-qtdbus --without-qrencode --without-miniupnpc --disable-tests --disable-wallet --disable-zmq --with-libs --disable-util-cli --disable-util-tx --disable-util-wallet --disable-bench --without-daemon --without-gui --disable-fuzz --disable-ccache --disable-static --with-system-libsecp256k1 && make && sudo make install" - python -m pip install flake8 pytest coverage mypy typing-extensions types-contextvars - - name: Lint with flake8 - shell: bash - run: ./run_flake8.sh - - name: Typecheck with mypy - shell: bash - run: ./run_mypy.sh - - name: Test with pytest - env: - LD_LIBRARY_PATH: /usr/local/lib - run: pytest + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install system build dependencies + run: | + if [ "$RUNNER_OS" = "Linux" ]; then + sudo apt-get update + sudo apt-get install -y libtool build-essential autotools-dev + elif [ "$RUNNER_OS" = "macOS" ]; then + brew install automake libtool pkg-config + fi + + - name: Build libsecp256k1 ${{ matrix.libsecp256k1-version }} + run: | + git clone https://github.com/bitcoin-core/secp256k1.git /tmp/libsecp256k1 + cd /tmp/libsecp256k1 + git checkout ${{ matrix.libsecp256k1-version }} + # v0.6.0+ uses CMake exclusively; older versions use autotools. + if [ -f autogen.sh ]; then + ./autogen.sh + ./configure --disable-coverage --disable-benchmark --disable-tests \ + --disable-exhaustive-tests --enable-module-recovery \ + --enable-module-ecdh --enable-module-schnorrsig + make + sudo make install + else + cmake -B build -DSECP256K1_ENABLE_MODULE_RECOVERY=ON \ + -DSECP256K1_ENABLE_MODULE_ECDH=ON \ + -DSECP256K1_ENABLE_MODULE_SCHNORRSIG=ON \ + -DSECP256K1_BUILD_TESTS=OFF \ + -DSECP256K1_BUILD_BENCHMARK=OFF \ + -DSECP256K1_BUILD_EXHAUSTIVE_TESTS=OFF + cmake --build build + sudo cmake --install build + fi + + - name: Install package + run: | + python -m pip install --upgrade pip + python -m pip install -e ".[dev]" + + - name: Run tests + env: + LD_LIBRARY_PATH: /usr/local/lib + run: pytest -q diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 7512ccd8..00000000 --- a/.travis.yml +++ /dev/null @@ -1,59 +0,0 @@ -language: python - -dist: bionic - -stages: test - -python: - - "3.7" - - "3.8" - - "3.9" - - "3.10" - - "3.11" - - -branches: - only: - - gh-pages - - /.*/ - -jobs: - include: - stage: test - os: osx - osx_image: xcode12 - language: sh - env: - - HOMEBREW_NO_INSTALL_CLEANUP=1 - - HOMEBREW_NO_ANALYTICS=1 - before_cache: rm -f "$HOME/Library/Caches/pip/log/debug.log" - cache: "$HOME/Library/Caches/pip" - addons: - homebrew: - packages: - - python3 - - before_install: - - sh -c 'git clone git://github.com/bitcoin/secp256k1.git libsecp256k1 && cd libsecp256k1 && ./autogen.sh && ./configure --disable-coverage --disable-benchmark --disable-tests --disable-exhaustive-tests && make && sudo make install && cd ..;' - - python3 -m pip install --upgrade virtualenv - - python3 -m pip install coverage - - virtualenv -p python3 --system-site-packages "$HOME/venv" - - source "$HOME/venv/bin/activate" - -env: - - LD_LIBRARY_PATH=/usr/local/lib - -addons: - apt: - packages: - - libsecp256k1-dev - -before_install: - - python3 -m pip install coverage - -install: - # libbitcoinconsensus - - sh -c 'git clone https://github.com/bitcoin/bitcoin.git bitcoin && cd bitcoin && git checkout v0.20.1 && ./autogen.sh && ./configure --without-qtdbus --without-qrencode --without-miniupnpc --disable-tests --disable-wallet --disable-zmq --with-libs --disable-util-cli --disable-util-tx --disable-util-wallet --disable-bench --without-daemon --without-gui --disable-fuzz --disable-ccache --disable-static --with-system-libsecp256k1 && make && sudo make install && cd ..' - -script: - - "coverage run --append --omit='tests/*,*/site-packages/*,*/distutils/*' setup.py test -q"