Skip to content

Commit 279128e

Browse files
committed
Fix travis, macOS workflow use build.sh
1 parent 4cbc1ab commit 279128e

7 files changed

Lines changed: 142 additions & 163 deletions

File tree

.github/workflows/linux.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ jobs:
2929
- name: Linux
3030
if: runner.os == 'Linux'
3131
run: |
32-
LIBSSH2_VERSION=1.9.0 LIBGIT2_VERSION=1.1.0 /bin/sh ci.sh
32+
LIBSSH2_VERSION=1.9.0 LIBGIT2_VERSION=1.1.0 /bin/sh build.sh test
3333
3434
- name: macOS
3535
if: runner.os == 'macOS'
3636
run: |
3737
export OPENSSL_PREFIX=`brew --prefix openssl@1.1`
3838
export LIBSSH2_PREFIX=`brew --prefix libssh2`
3939
export LIBGIT2_VERSION=1.1.0
40-
/bin/sh ci.sh
40+
/bin/sh build.sh test

.github/workflows/macos.yml

Lines changed: 18 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ on:
55
branches:
66
- master
77

8+
env:
9+
LIBGIT2_VERSION: 1.1.0
10+
MACOSX_DEPLOYMENT_TARGET: "10.9"
11+
812
jobs:
913
build:
10-
name: py-${{ matrix.py.ver }} libgit2-${{ matrix.libgit2}}
14+
name: py-${{ matrix.py.ver }}
1115
runs-on: macos-latest
1216
strategy:
1317
fail-fast: false
@@ -22,105 +26,41 @@ jobs:
2226
release: '3.8.7'
2327
- ver: '3.9'
2428
release: '3.9.1'
25-
env:
26-
HOMEBREW_CACHE: ${{ github.workspace }}/.cache/brew
27-
CCACHE_DIR: ${{ github.workspace }}/.cache/ccache
28-
CCACHE_COMPRESS: 1
29-
PIP_CACHE_DIR: ${{ github.workspace }}/.cache/pip
30-
MACOSX_DEPLOYMENT_TARGET: "10.9"
3129
steps:
32-
- name: checkout pygit2
33-
uses: actions/checkout@v2
34-
with:
35-
path: pygit2
36-
37-
- name: checkout libgit2
30+
- name: Checkout pygit2
3831
uses: actions/checkout@v2
39-
with:
40-
repository: libgit2/libgit2
41-
path: libgit2
42-
ref: ${{ matrix.libgit2 }}
43-
44-
- id: cache
45-
uses: actions/cache@v1.1.0
46-
with:
47-
path: .cache
48-
key: cache-libgit2.${{ matrix.libgit2 }}-py.${{ matrix.py.release }}
49-
restore-keys: |
50-
cache-
5132

52-
- name: setup python
33+
- name: Setup python
5334
run: |
54-
mkdir -p .cache/python/ .cache/pip/
5535
PKG="python-${{ matrix.py.release }}-macosx10.9.pkg"
5636
URL="https://www.python.org/ftp/python/${{ matrix.py.release }}/$PKG"
57-
wget --no-verbose -P .cache/python -N "$URL"
58-
sudo installer -pkg ".cache/python/$PKG" -target /
37+
wget --no-verbose -N "$URL"
38+
sudo installer -pkg $PKG -target /
5939
export PATH=/Library/Frameworks/Python.framework/Versions/${{ matrix.py.ver }}/bin:$PATH
6040
echo "/Library/Frameworks/Python.framework/Versions/${{ matrix.py.ver }}/bin" >> $GITHUB_PATH
6141
which python3
6242
python3 -VV
6343
test "$(python3 -V)" = "Python ${{ matrix.py.release }}"
6444
65-
- name: setup
45+
- name: Build
6646
run: |
67-
mkdir -p .cache/brew/ .cache/ccache/
68-
brew install ccache
69-
python3 -m venv venv/
70-
export PATH="${{ github.workspace }}/venv/bin:/usr/local/opt/ccache/libexec:$PATH"
71-
echo "/usr/local/opt/ccache/libexec" >> $GITHUB_PATH
72-
echo "${{ github.workspace }}/venv/bin" >> $GITHUB_PATH
73-
venv/bin/pip3 install delocate pytest
74-
75-
- name: build libgit2
76-
id: libgit2
77-
working-directory: libgit2
78-
env:
79-
PKG_CONFIG_PATH: /dev/null
80-
run: |
81-
mkdir env/
82-
cmake . \
83-
-DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/libgit2/env \
84-
-DBUILD_EXAMPLES=NO \
85-
-DBUILD_CLAR=NO \
86-
-DUSE_SSH=NO
87-
cmake --build . --target install
88-
otool -L "${{ github.workspace }}/libgit2/env/lib/libgit2.dylib"
89-
VERSION=$(PKG_CONFIG_PATH=$(pwd) pkg-config --modversion libgit2)
90-
echo "::set-output name=version::$VERSION"
91-
92-
- name: build pygit2
93-
id: pygit2
94-
working-directory: pygit2
95-
env:
96-
LIBGIT2: "${{ github.workspace }}/libgit2/env"
97-
LDFLAGS: "-Wl,-rpath,'${{ github.workspace }}/libgit2/env/lib'"
98-
run: |
99-
python3 setup.py bdist_wheel
47+
/bin/sh build.sh wheel
48+
pip3 install delocate
10049
delocate-listdeps dist/pygit2-*macosx*.whl
10150
delocate-wheel -v -w dist/fixed-wheels/ dist/pygit2-*macosx*.whl
10251
WHEEL=$(basename dist/fixed-wheels/*.whl)
10352
echo "::set-output name=wheel::$WHEEL"
10453
delocate-listdeps dist/fixed-wheels/$WHEEL
10554
106-
- name: pygit2 tests
107-
working-directory: pygit2
55+
- name: Tests
10856
run: |
57+
pip3 install pytest
10958
mv pygit2 pygit2~
110-
mv ../libgit2/env ../libgit2/env~
11159
pip3 install dist/fixed-wheels/pygit2-*.whl
112-
mkdir -p testresults/
113-
pytest -v test/ --junitxml=testresults/testresults.xml
114-
115-
- name: save test results
116-
uses: actions/upload-artifact@v1
117-
if: always()
118-
with:
119-
name: "test-results-py_${{ matrix.py.ver }}-libgit2_${{ steps.libgit2.outputs.version }}"
120-
path: pygit2/testresults/
60+
pytest
12161
122-
- name: save wheel
62+
- name: Save wheel
12363
uses: actions/upload-artifact@v1
12464
with:
125-
name: "macOS-wheel-py_${{ matrix.py.ver }}-libgit2_${{ steps.libgit2.outputs.version }}"
126-
path: pygit2/dist/fixed-wheels/
65+
name: "macOS-wheel-py_${{ matrix.py.ver }}-libgit2_${{ env.LIBGIT2_VERSION }}"
66+
path: dist/fixed-wheels/

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ before_install:
7272
- sudo apt-get -y install cmake
7373

7474
script:
75-
- /bin/sh ci.sh
75+
- LIBSSH2_VERSION=1.9.0 LIBGIT2_VERSION=1.1.0 /bin/sh build.sh test
7676

7777
stages:
7878
- test

README.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ Supports Python 3.6+ and PyPy3 7.3+
88
.. image:: https://github.com/libgit2/pygit2/workflows/Linux/badge.svg
99
:target: https://github.com/libgit2/pygit2/actions?query=workflow%3ALinux
1010

11-
.. image:: https://github.com/libgit2/pygit2/workflows/macOS/badge.svg
12-
:target: https://github.com/libgit2/pygit2/actions?query=workflow%3AmacOS
13-
1411
.. image:: https://ci.appveyor.com/api/projects/status/edmwc0dctk5nacx0/branch/master?svg=true
1512
:target: https://ci.appveyor.com/project/jdavid/pygit2/branch/master
1613

build.sh

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
#!/bin/sh
2+
3+
#
4+
# Synopsis:
5+
#
6+
# sh build.sh - Build inplace
7+
# sh build.sh test - Build inplace, and run the tests
8+
# sh build.sh wheel - Build a wheel, install, and run the tests
9+
#
10+
# Environment variables:
11+
#
12+
# LIBSSH2_OPENSSL - Where to find openssl
13+
# LIBSSH2_PREFIX - Where to find libssh2
14+
# LIBSSH2_VERSION=<Version> - Build the given version of libssh2
15+
# LIBGIT2_VERSION=<Versoin> - Build the given version of libgit2
16+
#
17+
# Either use LIBSSH2_PREFIX, or LIBSSH2_VERSION, or none (if libssh2 is already
18+
# in the path, or if you don't want to use it).
19+
#
20+
# Examples.
21+
#
22+
# Build inplace, libgit2 must be available in the path:
23+
#
24+
# sh build.sh
25+
#
26+
# Build libgit2 1.1.0 (will use libssh2 if available), then build pygit2
27+
# inplace:
28+
#
29+
# LIBGIT2_VERSION=1.1.0 sh build.sh
30+
#
31+
# Build libssh2 1.9.0 and libgit2 1.1.0, then build pygit2 inplace:
32+
#
33+
# LIBSSH2_VERSION=1.9.0 LIBGIT2_VERSION=1.1.0 sh build.sh
34+
#
35+
# Tell where libssh2 is installed, build libgit2 1.1.0, then build pygit2
36+
# inplace:
37+
#
38+
# LIBSSH2_PREFIX=/usr/local LIBGIT2_VERSION=1.1.0 sh build.sh
39+
#
40+
# Build inplace and run the tests:
41+
#
42+
# sh build.sh test
43+
#
44+
# Build a wheel:
45+
#
46+
# sh build.sh wheel
47+
#
48+
49+
set -x # Print every command and variable
50+
set -e # Exit script on any command failure
51+
52+
# Arguments
53+
WHAT=${1:-inplace}
54+
55+
# Variables
56+
PYTHON=${PYTHON:-python3}
57+
PYTHON_VERSION=$($PYTHON -c "import platform; print(f'{platform.python_implementation()}-{platform.python_version()}')")
58+
PREFIX="${PREFIX:-$(pwd)/ci/$PYTHON_VERSION}"
59+
export LDFLAGS="-Wl,-rpath,$PREFIX/lib"
60+
61+
# Linux or macOS
62+
case "$(uname -s)" in
63+
Darwin*)
64+
LDD="otool -L"
65+
SOEXT="dylib"
66+
;;
67+
*) # LINUX
68+
LDD="ldd"
69+
SOEXT="so"
70+
;;
71+
esac
72+
73+
# Create a virtual environment
74+
$PYTHON -m venv $PREFIX
75+
cd ci
76+
77+
# Install libssh2
78+
if [ -n "$LIBSSH2_VERSION" ]; then
79+
FILENAME=libssh2-$LIBSSH2_VERSION
80+
wget https://www.libssh2.org/download/$FILENAME.tar.gz -N
81+
tar xf $FILENAME.tar.gz
82+
cd $FILENAME
83+
./configure --prefix=$PREFIX --disable-static
84+
make
85+
make install
86+
cd ..
87+
$LDD $PREFIX/lib/libssh2.$SOEXT
88+
LIBSSH2_PREFIX=$PREFIX
89+
fi
90+
91+
# Install libgit2
92+
if [ -n "$LIBGIT2_VERSION" ]; then
93+
FILENAME=libgit2-$LIBGIT2_VERSION
94+
wget https://github.com/libgit2/libgit2/releases/download/v$LIBGIT2_VERSION/$FILENAME.tar.gz -N
95+
tar xf $FILENAME.tar.gz
96+
cd $FILENAME
97+
CMAKE_PREFIX_PATH=$OPENSSL_PREFIX:$LIBSSH2_PREFIX cmake . -DBUILD_CLAR=OFF -DCMAKE_INSTALL_PREFIX=$PREFIX
98+
cmake --build . --target install
99+
cd ..
100+
$LDD $PREFIX/lib/libgit2.$SOEXT
101+
export LIBGIT2=$PREFIX
102+
fi
103+
104+
# Build pygit2
105+
cd ..
106+
$PREFIX/bin/pip install -U pip
107+
if [ $WHAT = "wheel" ]; then
108+
$PREFIX/bin/pip install wheel
109+
$PREFIX/bin/python setup.py bdist_wheel
110+
else
111+
# Install Python requirements & build inplace
112+
$PREFIX/bin/python setup.py egg_info
113+
$PREFIX/bin/pip install -r pygit2.egg-info/requires.txt
114+
$PREFIX/bin/python setup.py build_ext --inplace
115+
fi
116+
117+
# Tests
118+
if [ $WHAT = "test" ]; then
119+
$PREFIX/bin/pip install -r requirements-test.txt
120+
$PREFIX/bin/pytest --cov=pygit2
121+
fi

ci.sh

Lines changed: 0 additions & 70 deletions
This file was deleted.

docs/index.rst

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,6 @@ pygit2 - libgit2 bindings in Python
55
Bindings to the libgit2 shared library, implements Git plumbing.
66
Supports Python 3.6+ and PyPy3 7.3+
77

8-
.. image:: https://travis-ci.org/libgit2/pygit2.svg?branch=master
9-
:target: http://travis-ci.org/libgit2/pygit2
10-
11-
.. image:: https://ci.appveyor.com/api/projects/status/edmwc0dctk5nacx0/branch/master?svg=true
12-
:target: https://ci.appveyor.com/project/jdavid/pygit2/branch/master
13-
14-
.. image:: https://github.com/libgit2/pygit2/workflows/macOS/badge.svg
15-
:target: https://github.com/libgit2/pygit2/actions?query=workflow%3AmacOS
16-
178
Links
189
=====================================
1910

0 commit comments

Comments
 (0)