Skip to content

Commit 958c7e4

Browse files
committed
add Github actions for lint, test, and release
1 parent 4401c19 commit 958c7e4

File tree

11 files changed

+565
-88
lines changed

11 files changed

+565
-88
lines changed

.github/workflows/release.yml

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
name: release
2+
on:
3+
release:
4+
types: [published]
5+
tags:
6+
- v*
7+
push:
8+
branches:
9+
- master
10+
pull_request:
11+
branches:
12+
- master
13+
14+
env:
15+
LIBZIM_RELEASE: libzim_linux-x86_64-6.1.1
16+
LIBZIM_LIBRARY_PATH: lib/x86_64-linux-gnu/libzim.so.6.1.1
17+
LIBZIM_INCLUDE_PATH: include/zim
18+
CYTHON_VERSION: 0.29.6
19+
20+
jobs:
21+
release:
22+
runs-on: ${{ matrix.os }}
23+
strategy:
24+
matrix:
25+
os: [ubuntu-latest]
26+
# TODO: expand this to cross-platform builds (see V2 approach below)
27+
# os: [ubuntu-latest, windows-latest, macos-latest]
28+
python-version: [3.6, 3.7, 3.8]
29+
30+
steps:
31+
- uses: actions/checkout@v2
32+
33+
- name: Set up Python ${{ matrix.python-version }}
34+
uses: actions/setup-python@v1
35+
with:
36+
python-version: ${{ matrix.python-version }}
37+
architecture: x64
38+
39+
- name: Cache libzim dylib
40+
uses: actions/cache@master
41+
id: cache-libzim
42+
with:
43+
path: libzim_linux
44+
key: $LIBZIM_RELEASE-libzim-cache
45+
46+
- name: Install libzim dylib & headers in system
47+
if: steps.cache-libzim.outputs.cache-hit != 'true'
48+
run: |
49+
wget -q https://download.openzim.org/release/libzim/$LIBZIM_RELEASE.tar.gz
50+
tar --gunzip --extract --file=$LIBZIM_RELEASE.tar.gz
51+
mv $LIBZIM_RELEASE libzim_linux
52+
53+
- name: Sync libzim dylib & headers in system
54+
run: |
55+
sudo rsync -a $GITHUB_WORKSPACE/libzim_linux/$LIBZIM_LIBRARY_PATH /usr/lib/libzim.so
56+
sudo rsync -a $GITHUB_WORKSPACE/libzim_linux/$LIBZIM_INCLUDE_PATH/ /usr/include/zim/
57+
58+
- name: Copy libzim release for building
59+
run: |
60+
rsync -a $GITHUB_WORKSPACE/libzim_linux/ $GITHUB_WORKSPACE/$LIBZIM_RELEASE/
61+
62+
- name: Build cython, sdist, and bdist_wheels
63+
run: |
64+
pip install --upgrade cython==$CYTHON_VERSION setuptools pip cibuildwheel
65+
python3 setup.py build_ext --inplace
66+
python3 setup.py sdist bdist_wheel
67+
python -m cibuildwheel --output-dir wheelhouse
68+
69+
- uses: actions/upload-artifact@v1
70+
with:
71+
name: wheels
72+
path: ./wheelhouse
73+
74+
- name: Push release to PyPI
75+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
76+
uses: pypa/gh-action-pypi-publish@master
77+
with:
78+
user: __token__
79+
password: ${{ secrets.PYPI_API_TOKEN }}
80+
repository_url: https://test.pypi.org/legacy/
81+
82+
### TODO V2: The more modern wheel-based cross-platform binary distribution approach
83+
84+
# manylinux-release-wheel:
85+
# name: Build release wheels for manylinux2010
86+
# runs-on: ubuntu-18.04
87+
# steps:
88+
# - uses: actions/checkout@v2
89+
# - uses: actions/setup-python@v1
90+
# with:
91+
# python-version: 3.6
92+
# - name: Build manylinux2010 wheels
93+
# run: |
94+
# docker run -e manylinux2010 tools/ci_build/builds/release_linux.sh
95+
# python3 -m pip install -U auditwheel
96+
# for f in artifacts/*.whl; do
97+
# auditwheel repair --plat manylinux2010_x86_64 $f
98+
# done
99+
# ls -al wheelhouse/
100+
101+
# - uses: actions/upload-artifact@v1
102+
# with:
103+
# name: ${{ runner.os }}-wheels
104+
# path: wheelhouse
105+
106+
# macos-release-wheel:
107+
# name: Build release wheels for macOS
108+
# runs-on: macos-latest
109+
# strategy:
110+
# matrix:
111+
# python-version: ['3.6', '3.7', '3.8']
112+
# steps:
113+
# - uses: actions/checkout@v2
114+
# - uses: actions/setup-python@v1
115+
# with:
116+
# python-version: ${{ matrix.python-version }}
117+
# - name: Build macOS wheels
118+
# if: github.event_name == 'release'
119+
# run: |
120+
# python3 --version
121+
# python3 -m pip install cython wheel setuptools
122+
# bazel build \
123+
# -c opt \
124+
# --copt -mmacosx-version-min=10.13 \
125+
# --linkopt -mmacosx-version-min=10.13 \
126+
# --noshow_progress \
127+
# --noshow_loading_progress \
128+
# --verbose_failures \
129+
# --test_output=errors \
130+
# build_pip_pkg
131+
# bazel-bin/build_pip_pkg artifacts
132+
# for f in artifacts/*.whl; do
133+
# delocate-wheel -w wheelhouse $f
134+
# done
135+
# - uses: actions/upload-artifact@v1
136+
# with:
137+
# name: ${{ runner.os }}-wheels
138+
# path: wheelhouse
139+
140+
# windows-release-wheel:
141+
# name: Build release wheels for Windows
142+
# runs-on: windows-latest
143+
# strategy:
144+
# matrix:
145+
# python-version: ['3.6', '3.7', '3.8']
146+
# steps:
147+
# - uses: actions/checkout@v2
148+
# - uses: actions/setup-python@v1
149+
# with:
150+
# python-version: ${{ matrix.python-version }}
151+
# - name: Build Windows wheels
152+
# shell: bash
153+
# if: github.event_name == 'release'
154+
# run: |
155+
# python -m pip install cython wheel setuptools
156+
# # TODO build here
157+
# - uses: actions/upload-artifact@v1
158+
# with:
159+
# name: ${{ runner.os }}-wheels
160+
# path: artifacts
161+
162+
# upload-wheels:
163+
# name: Publish wheels to PyPi
164+
# needs: [manylinux-release-wheel, macos-release-wheel, windows-release-wheel]
165+
# runs-on: ubuntu-18.04
166+
# steps:
167+
# - uses: actions/download-artifact@v1
168+
# with:
169+
# name: Linux-wheels
170+
# path: Linux-wheels
171+
# - uses: actions/download-artifact@v1
172+
# with:
173+
# name: macOS-wheels
174+
# path: macOS-wheels
175+
# - uses: actions/download-artifact@v1
176+
# with:
177+
# name: Windows-wheels
178+
# path: Windows-wheels
179+
# - run: |
180+
# set -e -x
181+
# mkdir -p dist
182+
# cp Linux-wheels/*.whl dist/
183+
# cp macOS-wheels/*.whl dist/
184+
# cp Windows-wheels/*.whl dist/
185+
# ls -la dist/
186+
# sha256sum dist/*.whl
187+
188+
# - uses: pypa/gh-action-pypi-publish@master
189+
# if: github.event_name == 'release'
190+
# with:
191+
# user: __token__
192+
# password: ${{ secrets.pypi_token }}

.github/workflows/test.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: test
2+
on: [push, pull_request]
3+
4+
env:
5+
LIBZIM_RELEASE: libzim_linux-x86_64-6.1.1
6+
LIBZIM_LIBRARY_PATH: lib/x86_64-linux-gnu/libzim.so.6.1.1
7+
LIBZIM_INCLUDE_PATH: include/zim
8+
CYTHON_VERSION: 0.29.6
9+
MAX_LINE_LENGTH: 110
10+
11+
jobs:
12+
lint:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
17+
- name: Set up Python ${{ matrix.python }}
18+
uses: actions/setup-python@v1
19+
with:
20+
python-version: 3.6
21+
architecture: x64
22+
23+
- name: Autoformat with black
24+
run: |
25+
pip install black
26+
black . --exclude=setup.py
27+
28+
- name: Lint with flake8
29+
run: |
30+
pip install flake8
31+
# stop the build if there are Python syntax errors or undefined names
32+
flake8 . --count --select=E9,F63,F7,F82 --exclude=setup.py --show-source --statistics
33+
# exit-zero treats all errors as warnings, this can be made stricter later
34+
flake8 . --count --exit-zero --exclude=setup.py --max-line-length=$MAX_LINE_LENGTH --statistics
35+
36+
test:
37+
runs-on: ${{ matrix.os }}
38+
strategy:
39+
matrix:
40+
os: [ubuntu-latest]
41+
# TODO: expand this once macos and windows libzim releases become available
42+
# os: [ubuntu-latest, windows-latest, macos-latest]
43+
# alternatively we can compile libzim in docker and use the container as an action
44+
python: [3.6, 3.7, 3.8]
45+
steps:
46+
- uses: actions/checkout@v2
47+
48+
- name: Set up Python ${{ matrix.python }}
49+
uses: actions/setup-python@v1
50+
with:
51+
python-version: ${{ matrix.python }}
52+
architecture: x64
53+
54+
- name: Cache libzim dylib
55+
uses: actions/cache@master
56+
id: cache-libzim
57+
with:
58+
path: libzim_linux
59+
key: $LIBZIM_RELEASE-libzim-cache
60+
61+
- name: Download libzim dylib & headers in system
62+
if: steps.cache-libzim.outputs.cache-hit != 'true'
63+
run: |
64+
wget -q https://download.openzim.org/release/libzim/$LIBZIM_RELEASE.tar.gz
65+
tar --gunzip --extract --file=$LIBZIM_RELEASE.tar.gz
66+
mv $LIBZIM_RELEASE libzim_linux
67+
68+
- name: Sync libzim dylib & headers in system
69+
run: |
70+
sudo rsync -a $GITHUB_WORKSPACE/libzim_linux/$LIBZIM_LIBRARY_PATH /usr/lib/libzim.so
71+
sudo rsync -a $GITHUB_WORKSPACE/libzim_linux/$LIBZIM_INCLUDE_PATH/ /usr/include/zim/
72+
73+
- name: Build cython, sdist, and bdist_wheel
74+
run: |
75+
pip install --upgrade cython==$CYTHON_VERSION setuptools pip wheel
76+
python3 setup.py build_ext --build-lib=cython_build
77+
python3 setup.py sdist bdist_wheel
78+
79+
- name: Test built package with pytest
80+
run: |
81+
export LD_LIBRARY_PATH=/usr/lib:$LD_LIBRARY_PATH
82+
sudo ldconfig
83+
pip install pytest
84+
pip install -e .
85+
pytest .

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.DS_Store
2+
.venv
3+
.venv-docker
4+
.mypy_cache
5+
__pycache__
6+
*.pyc
7+
.tox
8+
9+
build/
10+
dist/
11+
libzim.egg-info/
12+
libzim_linux-x86_64-6.1.1/

MANIFEST.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
include LICENSE
2+
include README.md
3+
recursive-include libzim_linux-x86_64-6.1.1 *

Pipfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[[source]]
2+
name = "pypi"
3+
url = "https://pypi.org/simple"
4+
verify_ssl = true
5+
6+
[dev-packages]
7+
pytest = "*"
8+
tox = "*"
9+
cython = "==0.29.6"
10+
e1839a8 = {editable = true, path = "."}
11+
12+
[packages]
13+
14+
[requires]
15+
python_version = "3.7"
File renamed without changes.

pyproject.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[build-system]
2+
requires = [ "setuptools >= 35.0.2", "wheel >= 0.29.0", "twine", "cython == 0.29.6" ]
3+
build-backend = "setuptools.build_meta"
4+
5+
[tool.tox]
6+
legacy_tox_ini = """
7+
[tox]
8+
envlist = py36,py37
9+
10+
[testenv]
11+
platform = linux|darwin
12+
deps =
13+
pytest >= 3.0.0, <4
14+
cython
15+
commands = pytest
16+
"""
17+
18+
[tool.black]
19+
line-length = 110
20+
target-version = ['py36', 'py37', 'py38']

rebuild.sh

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

run_tests.sh

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

0 commit comments

Comments
 (0)