Browse Source

switch to GitHub Actions (#76)

* .

* Update main.yml

* Update main.yml

* Update main.yml

* .

* Update ci.yml

* Update ci.yml

* Update ci.yml

* Update ci.yml

* Update ci.yml

* .

* Update ci.yml

* Update tox.ini

* .

* update perms of .github/scripts/install_deps.sh

* Update install_deps.sh

* Update tox.ini

* .

* .

* set executable of .github/scripts/*

* .

* set executable of .github/scripts/*

* .

* set executable of .github/scripts/*

* Update build.sh

* .

* .

* Update build.sh

* Update ci.yml

* .
master
Ofek Lev 3 years ago
committed by GitHub
parent
commit
c01dc7c99a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      .flake8
  2. 19
      .github/scripts/build-linux-wheels.sh
  3. 0
      .github/scripts/build-windows-wheels.sh
  4. 45
      .github/scripts/build.sh
  5. 21
      .github/scripts/install-system-deps.sh
  6. 9
      .github/scripts/prepare-windows-build.sh
  7. 143
      .github/workflows/ci.yml
  8. 34
      .github/workflows/main.yml
  9. 104
      .travis.yml
  10. 51
      .travis/deploy.sh
  11. 81
      .travis/install.sh
  12. 11
      .travis/prepare_windows_build.sh
  13. 14
      .travis/upload_coverage.sh
  14. 40
      release.py
  15. 39
      tox.ini

7
.flake8

@ -0,0 +1,7 @@
# TODO: move this to pyproject.toml when supported: https://gitlab.com/pycqa/flake8/-/issues/428
[flake8]
select = B,C,E,F,W,B001,B003,B006,B007,B301,B305,B306,B902,Q000,Q001,Q002,Q003
ignore = E203,E722,W503
exclude = .tox,build
max-line-length = 120

19
.travis/build-linux-wheels.sh → .github/scripts/build-linux-wheels.sh

@ -3,7 +3,7 @@
set -e
set -x
# Install a system package required by our library
# Install system packages required by our library
yum install -y pkg-config libffi libffi-devel
# Use updated GMP
@ -11,17 +11,20 @@ curl -O https://ftp.gnu.org/gnu/gmp/gmp-6.1.2.tar.bz2 && tar -xjpf gmp-*.tar.bz2
mkdir out
# PyPy
if [[ "$PLAT" == "manylinux2010_x86_64" ]]; then
mkdir /opt/python/pypy3
curl -LO https://bitbucket.org/squeaky/portable-pypy/downloads/pypy3.6-7.1.1-beta-linux_x86_64-portable.tar.bz2
tar -xjpf pypy3.6-7.1.1-beta-linux_x86_64-portable.tar.bz2 -C /opt/python/pypy3 --strip-components=1
curl -sSL https://raw.githubusercontent.com/pypa/get-pip/master/get-pip.py | /opt/python/pypy3/bin/pypy
python_version="$PYTHON_VERSION"
if [[ "$python_version" =~ "pypy" ]]; then
python_version="pypy_73"
else
python_version=${python_version/./}
python_version="cp$python_version"
fi
echo "Looking for Python version pattern: $python_version"
# Compile wheels
for PYBIN in /opt/python/*/bin; do
if [[ ${PYBIN} =~ (cp27|cp36|cp37|cp38|cp39|pypy) ]]; then
if [[ ${PYBIN} =~ $python_version ]]; then
${PYBIN}/pip wheel /io/ -w wheelhouse/
fi
done

0
.travis/build_windows_wheels.sh → .github/scripts/build-windows-wheels.sh

45
.github/scripts/build.sh

@ -0,0 +1,45 @@
#!/bin/bash
set -e
set -x
mkdir dist
if [[ "$OS_NAME" =~ "ubuntu-" ]]; then
if [[ "$PYTHON_VERSION" =~ "pypy" ]]; then
docker run --rm -e PYTHON_VERSION="$PYTHON_VERSION" -e PLAT="manylinux2010_x86_64" -e BUILD_GMP_CPU="amd64" -v $(pwd):/io pypywheels/manylinux2010-pypy_x86_64 /io/.github/scripts/build-linux-wheels.sh
else
docker run --rm -e PYTHON_VERSION="$PYTHON_VERSION" -e PLAT="manylinux2010_x86_64" -e BUILD_GMP_CPU="amd64" -v $(pwd):/io quay.io/pypa/manylinux2010_x86_64 /io/.github/scripts/build-linux-wheels.sh
docker run --rm -e PYTHON_VERSION="$PYTHON_VERSION" -e PLAT="manylinux1_x86_64" -e BUILD_GMP_CPU="amd64" -v $(pwd):/io quay.io/pypa/manylinux1_x86_64 /io/.github/scripts/build-linux-wheels.sh
linux32 docker run --rm -e PYTHON_VERSION="$PYTHON_VERSION" -e PLAT="manylinux1_i686" -e BUILD_GMP_CPU="i686" -v $(pwd):/io quay.io/pypa/manylinux1_i686 /io/.github/scripts/build-linux-wheels.sh
if [[ "$PYTHON_VERSION" == "$PYTHON_VERSION_BUILD_EXTRA" ]]; then
# Build the source distribution
python setup.py sdist
# Build the wheels for Windows
.github/scripts/build-windows-wheels.sh
fi
fi
else
# Make sure we can build and "fix" the wheel.
python -m pip install delocate wheel
# Create directories for the built and fixed wheels.
mkdir dist_wheels/ fixed_wheels/
# Build the wheel for the local OS.
python -m pip wheel . --wheel-dir dist_wheels/
# Make the wheel relocatable to another OS.
delocate-wheel \
--check-archs \
--wheel-dir fixed_wheels/ \
--verbose \
dist_wheels/coincurve*.whl
# Move the fixed wheel into dist/.
mv fixed_wheels/coincurve*.whl dist/
# Clean up build directories.
rm -fr dist_wheels/ fixed_wheels/
fi
ls -l dist
set +x +e

21
.github/scripts/install-system-deps.sh

@ -0,0 +1,21 @@
#!/bin/bash
set -e
set -x
if [[ "$OS_NAME" =~ "macos-" ]]; then
# update brew
brew update || brew update
# Update openssl if necessary
brew outdated openssl || brew upgrade openssl
# Install packages needed to build lib-secp256k1
for pkg in automake libtool pkg-config libffi; do
brew list $pkg > /dev/null || brew install $pkg
brew outdated --quiet $pkg || brew upgrade $pkg
done
fi
set +x +e

9
.github/scripts/prepare-windows-build.sh

@ -0,0 +1,9 @@
#!/bin/bash
mkdir .hidden
cp * .hidden -R
mkdir .hidden/dist
mv .hidden/coincurve/_windows_libsecp256k1.py .hidden/coincurve/_libsecp256k1.py
mv .hidden ../clean
sudo apt-get install -y mingw-w64
sudo apt-get -f install

143
.github/workflows/ci.yml

@ -0,0 +1,143 @@
name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master
env:
LD_LIBRARY_PATH: ./libsecp256k1_ext/.libs
DYLD_FALLBACK_LIBRARY_PATH: ./libsecp256k1_ext/.libs
LIB_DIR: ./libsecp256k1_ext/.libs
INCLUDE_DIR: ./libsecp256k1_ext/include
jobs:
test:
name: "Test ${{ !startsWith(matrix.python-version, 'pypy') && 'Python ' || '' }}${{ startsWith(matrix.python-version, 'pypy') && 'PyPy' || matrix.python-version }} on ${{ startsWith(matrix.os, 'ubuntu-') && 'Ubuntu' || 'macOS' }}"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-18.04, macos-10.15]
python-version: ['2.7', '3.6', '3.7', '3.8', '3.9']
include:
- os: ubuntu-18.04
python-version: pypy3
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Upgrade Python packaging tools
run: pip install --upgrade pip setuptools wheel
- name: Show runner information
run: |
python --version
pip --version
- name: Install system dependencies
run: ./.github/scripts/install-system-deps.sh
- name: Install build dependencies
run: python -m pip install --upgrade cffi
- name: Install test dependencies
run: python -m pip install --upgrade tox codecov
- name: Run tests
run: tox -e ${PYTHON_VERSION},bench
# - name: Lint
# if: startsWith(matrix.os, 'ubuntu-') && matrix.python-version == '3.9' && always()
# run: tox -e lint
- name: Upload coverage
run: codecov -X gcov
build:
name: "Build ${{ !startsWith(matrix.python-version, 'pypy') && 'Python ' || '' }}${{ startsWith(matrix.python-version, 'pypy') && 'PyPy' || matrix.python-version }} ${{ startsWith(matrix.os, 'ubuntu-') && 'manylinux' || 'on' }} ${{ startsWith(matrix.os, 'ubuntu-') && 'wheels' || 'macOS' }}"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-18.04, macos-10.15]
python-version: ['2.7', '3.6', '3.7', '3.8', '3.9']
include:
- os: ubuntu-18.04
python-version: pypy3
env:
PYTHON_VERSION: ${{ matrix.python-version }}
OS_NAME: ${{ matrix.os }}
PYTHON_VERSION_BUILD_EXTRA: '3.9'
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
if: startsWith(matrix.os, 'macos-') || matrix.python-version == env.PYTHON_VERSION_BUILD_EXTRA
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Upgrade Python packaging tools
if: startsWith(matrix.os, 'macos-') || matrix.python-version == env.PYTHON_VERSION_BUILD_EXTRA
run: pip install --upgrade pip setuptools wheel
- name: Show runner information
if: startsWith(matrix.os, 'macos-') || matrix.python-version == env.PYTHON_VERSION_BUILD_EXTRA
run: |
python --version
pip --version
- name: Install system dependencies
run: ./.github/scripts/install-system-deps.sh
- name: Install build dependencies
if: startsWith(matrix.os, 'macos-') || matrix.python-version == env.PYTHON_VERSION_BUILD_EXTRA
run: python -m pip install --upgrade cffi
- name: Prepare for cross-platform Windows build
if: startsWith(matrix.os, 'ubuntu-') && matrix.python-version == env.PYTHON_VERSION_BUILD_EXTRA
run: ./.github/scripts/prepare-windows-build.sh
- name: Build package
run: ./.github/scripts/build.sh
- uses: actions/upload-artifact@v2
if: always()
with:
name: artifacts
path: dist/*
publish:
name: Publish release
runs-on: ubuntu-latest
needs:
- build
# Only publish tags
if: github.event_name == 'push' && github.event.ref_type == 'tag'
steps:
- uses: actions/download-artifact@v2
with:
name: artifacts
path: dist
- name: Push build artifacts to PyPI
uses: pypa/gh-action-pypi-publish@v1.4.1
with:
skip_existing: true
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}

34
.github/workflows/main.yml

@ -1,34 +0,0 @@
name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: [2.7, 3.6, 3.7, 3.8, 3.9]
os: [ubuntu-18.04, macos-10.15]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Upgrade Python packaging tools
run: pip install --upgrade pip setuptools wheel
- name: Show runner information
run: |
python --version
pip --version

104
.travis.yml

@ -1,104 +0,0 @@
sudo: true
dist: xenial
language: python
cache:
directories:
- $HOME/.cache/pip
# Only build master, release branches, and version tags (which are considered
# branches by Travis, see https://github.com/travis-ci/travis-ci/issues/8518)
branches:
only:
- master
- /^release.+$/
- /^[0-9]+\.[0-9]+\.[0-9]+.*$/
env:
global:
- LD_LIBRARY_PATH=./libsecp256k1_ext/.libs
- DYLD_FALLBACK_LIBRARY_PATH=./libsecp256k1_ext/.libs
- LIB_DIR=./libsecp256k1_ext/.libs
- INCLUDE_DIR=./libsecp256k1_ext/include
- PYPI_USERNAME=Ofekmeister
addons:
apt:
packages:
- autoconf
- automake
- git
- libffi-dev
- libgmp-dev
- libtool
- pkg-config
matrix:
include:
- python: 3.6
env: TOXENV=style BUILD_LINUX_WHEELS=1
services: docker
- python: 2.7
env: TOXENV=py27,bench
- python: 3.6
env: TOXENV=py36,bench
- python: 3.7
env: TOXENV=py37,bench
- python: 3.8
env: TOXENV=py38,bench
- python: 3.9
env: TOXENV=py39,bench
- python: pypy3
env: TOXENV=pypy3k,bench
- os: osx
language: generic
python: 2.7
osx_image: xcode10.1
env: TOXENV=py27,bench TRAVIS_PYTHON_VERSION=2.7
- os: osx
language: generic
python: 3.6
osx_image: xcode10.1
env: TOXENV=py36,bench TRAVIS_PYTHON_VERSION=3.6 NEED_SSL_FIX=true
- os: osx
language: generic
python: 3.7
osx_image: xcode10.1
env: TOXENV=py37,bench TRAVIS_PYTHON_VERSION=3.7
- os: osx
language: generic
python: 3.8
osx_image: xcode10.1
env: TOXENV=py38,bench TRAVIS_PYTHON_VERSION=3.8
- os: osx
language: generic
python: 3.9
osx_image: xcode10.1
env: TOXENV=py39,bench TRAVIS_PYTHON_VERSION=3.9
before_install:
- chmod +x .travis/build-linux-wheels.sh
- chmod +x .travis/build_windows_wheels.sh
- chmod +x .travis/deploy.sh
- chmod +x .travis/prepare_windows_build.sh
- chmod +x .travis/upload_coverage.sh
install:
- .travis/prepare_windows_build.sh
- source .travis/install.sh
script:
# Reuse test environments for benchmarks
- export TESTENV=$(python -c "import os;print(os.getenv('TOXENV', 'bench').split(',')[0])")
- tox
after_success:
- .travis/upload_coverage.sh
deploy:
- provider: script
skip_cleanup: true
script: .travis/deploy.sh
on:
repo: ofek/coincurve
tags: true

51
.travis/deploy.sh

@ -1,51 +0,0 @@
#!/bin/bash
set -e -x
echo "deploy"
python setup.py install
# remove any left over files from previous steps
rm -rf build dist
mkdir dist
python setup.py sdist
if [[ "$TRAVIS_OS_NAME" == "linux" && ${BUILD_LINUX_WHEELS} -eq 1 ]]; then
docker run --rm -e PLAT="manylinux2010_x86_64" -e BUILD_GMP_CPU="amd64" -v $(pwd):/io quay.io/pypa/manylinux2010_x86_64 /io/.travis/build-linux-wheels.sh
docker run --rm -e PLAT="manylinux1_x86_64" -e BUILD_GMP_CPU="amd64" -v $(pwd):/io quay.io/pypa/manylinux1_x86_64 /io/.travis/build-linux-wheels.sh
linux32 docker run --rm -e PLAT="manylinux1_i686" -e BUILD_GMP_CPU="i686" -v $(pwd):/io quay.io/pypa/manylinux1_i686 /io/.travis/build-linux-wheels.sh
.travis/build_windows_wheels.sh
else
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
# Make sure we can build and "fix" the wheel.
python -m pip install delocate wheel
# Create directories for the built and fixed wheels.
mkdir dist_wheels/ fixed_wheels/
# Build the wheel for the local OS.
python -m pip wheel . --wheel-dir dist_wheels/
# Make the wheel relocatable to another OS.
delocate-wheel \
--check-archs \
--wheel-dir fixed_wheels/ \
--verbose \
dist_wheels/coincurve*.whl
# Move the fixed wheel into dist/.
[ -d dist/ ] || mkdir dist/
mv fixed_wheels/coincurve*.whl dist/
# Clean up build directories.
rm -fr dist_wheels/ fixed_wheels/
fi
fi
ls -l dist
python -m pip install twine
# Ignore non-existing files in globs
shopt -s nullglob
twine upload --skip-existing dist/coincurve*.{whl,gz} -u "${PYPI_USERNAME}"
set +e +x

81
.travis/install.sh

@ -1,81 +0,0 @@
#!/bin/bash
set -e
set -x
# On osx we need to bring our own Python.
# See: https://github.com/travis-ci/travis-ci/issues/2312
if [[ $TRAVIS_OS_NAME == "osx" ]]; then
# We use the official python.org installers to make sure our wheels are
# going to be as widely compatible as possible
PYTHON_PKG_27="https://www.python.org/ftp/python/2.7.16/python-2.7.16-macosx10.9.pkg"
PYTHON_PKG_36="https://www.python.org/ftp/python/3.6.8/python-3.6.8-macosx10.9.pkg"
PYTHON_PKG_37="https://www.python.org/ftp/python/3.7.3/python-3.7.3-macosx10.9.pkg"
PYTHON_PKG_38="https://www.python.org/ftp/python/3.8.0/python-3.8.0-macosx10.9.pkg"
PYTHON_PKG_39="https://www.python.org/ftp/python/3.9.0/python-3.9.0-macosx10.9.pkg"
GET_PIP="https://bootstrap.pypa.io/get-pip.py"
# update brew
brew update || brew update
# Update openssl if necessary
brew outdated openssl || brew upgrade openssl
# Install packages needed to build lib-secp256k1
for pkg in automake libtool pkg-config libffi; do
brew list $pkg > /dev/null || brew install $pkg
brew outdated --quiet $pkg || brew upgrade $pkg
done
mkdir -p ~/.cache/python-dl
builtin pushd ~/.cache/python-dl
ls -l
py_pkg=PYTHON_PKG_${TRAVIS_PYTHON_VERSION//./}
py_pkg=${!py_pkg}
installer_pkg=$(basename ${py_pkg})
# The package might have been cached from a previous run
if [[ ! -f ${installer_pkg} ]]; then
curl -LO ${py_pkg}
fi
sudo installer -pkg ${installer_pkg} -target /
builtin popd
case "${TRAVIS_PYTHON_VERSION}" in
2.7)
python=/Library/Frameworks/Python.framework/Versions/${TRAVIS_PYTHON_VERSION}/bin/python
virtualenv=virtualenv
;;
3.6|3.7|3.8|3.9)
python=/Library/Frameworks/Python.framework/Versions/${TRAVIS_PYTHON_VERSION}/bin/python3
virtualenv=venv
;;
esac
if [[ "${TRAVIS_PYTHON_VERSION}" == "2.7" ]]; then
builtin pushd ~
curl -LO ${GET_PIP}
${python} get-pip.py
${python} -m pip install --user virtualenv
builtin popd
fi
# https://bugs.python.org/issue28150
if [[ "${NEED_SSL_FIX}" == "true" ]]; then
"/Applications/Python ${TRAVIS_PYTHON_VERSION}/Install Certificates.command"
fi
mkdir ~/virtualenv
${python} -m ${virtualenv} ~/virtualenv/python${TRAVIS_PYTHON_VERSION}
source ~/virtualenv/python${TRAVIS_PYTHON_VERSION}/bin/activate
fi
# Install necessary packages
python -m pip install -U cffi tox codecov
set +x +e

11
.travis/prepare_windows_build.sh

@ -1,11 +0,0 @@
#!/bin/bash
if [[ "$TRAVIS_OS_NAME" == "linux" && ${BUILD_LINUX_WHEELS} -eq 1 ]]; then
mkdir .hidden
cp * .hidden -R
mkdir .hidden/dist
mv .hidden/coincurve/_windows_libsecp256k1.py .hidden/coincurve/_libsecp256k1.py
mv .hidden ../clean
sudo apt-get install -y mingw-w64
sudo apt-get -f install
fi

14
.travis/upload_coverage.sh

@ -1,14 +0,0 @@
#!/bin/bash
set -e
set -x
if [ -n "${TOXENV}" ]; then
case "${TOXENV}" in
style);;
^bench$);;
*)
codecov -X gcov
;;
esac
fi

40
release.py

@ -1,40 +0,0 @@
import os
import subprocess
import sys
import appdirs
def main():
here = os.path.dirname(os.path.abspath(__file__))
os.chdir(here)
version = sys.argv[-1]
delete = not not sys.argv[-2] == '-d'
delete_only = not not sys.argv[-2] == '--d'
try:
subprocess.call('git -h')
git_path = 'git'
except:
git_path = None
if git_path is None:
raise OSError('Unable to find git executable.')
cmds = ['{0} tag -a {1} -m "Version {1}"'.format(git_path, version), '{} push origin {}'.format(git_path, version)]
delete_cmd = '{} tag -d {}'.format(git_path, version)
if delete:
cmds.insert(0, delete_cmd)
elif delete_only:
cmds = [delete_cmd]
for cmd in cmds:
subprocess.call(cmd)
print(cmds)
if __name__ == '__main__':
main()

39
tox.ini

@ -1,10 +1,15 @@
[tox]
skip_missing_interpreters = true
envlist =
py{27,36,37,38,39},
pypy3k,
bench,
style
2.7
3.6
3.7
3.8
3.9
pypy3
bench
lint
fmt
[testenv]
passenv = *
@ -19,13 +24,31 @@ commands =
[testenv:bench]
skip_install = true
envdir = {toxworkdir}/{env:TESTENV:bench}
envdir = {toxworkdir}/{env:PYTHON_VERSION:bench}
commands =
python -c "import shutil; shutil.move('coincurve', '_coincurve')"
pytest -v --benchmark-only --benchmark-sort=name --benchmark-cprofile=tottime
python -c "import shutil; shutil.move('_coincurve', 'coincurve')"
[testenv:style]
[testenv:lint]
envdir = {toxworkdir}/lint
skip_install = true
deps = black
commands = black --check --diff .
deps =
flake8>=3.8.2
flake8-bugbear>=20.1.4
flake8-quotes>=3.2.0
black>=19.10b0
isort[pyproject]>=5
commands =
flake8 .
black --check --diff .
isort --check-only --diff .
[testenv:fmt]
envdir = {[testenv:lint]envdir}
skip_install = true
deps = {[testenv:lint]deps}
commands =
isort .
black .
{[testenv:lint]commands}

Loading…
Cancel
Save