-
-
Notifications
You must be signed in to change notification settings - Fork 29
Add Github Actions CI/CD for build, tests, and PyPI release #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| name: release | ||
| on: | ||
| release: | ||
| types: [published] | ||
| tags: | ||
| - v* | ||
|
|
||
| env: | ||
| LIBZIM_RELEASE: libzim_linux-x86_64-6.1.1 | ||
| LIBZIM_LIBRARY_PATH: lib/x86_64-linux-gnu/libzim.so.6.1.1 | ||
| LIBZIM_INCLUDE_PATH: include/zim | ||
| CYTHON_VERSION: 0.29.6 | ||
|
|
||
| jobs: | ||
| release: | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| matrix: | ||
| os: [ubuntu-latest] | ||
| # TODO: expand this to cross-platform builds (see V2 approach below) | ||
| # os: [ubuntu-latest, windows-latest, macos-latest] | ||
| python-version: [3.6, 3.7, 3.8] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v2 | ||
|
|
||
| - name: Set up Python ${{ matrix.python-version }} | ||
| uses: actions/setup-python@v1 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| architecture: x64 | ||
|
|
||
| - name: Cache libzim dylib & headers | ||
| uses: actions/cache@master | ||
| id: cache-libzim | ||
| with: | ||
| path: libzim_linux | ||
| key: ${{ env.LIBZIM_RELEASE }}-libzim-cache | ||
|
|
||
| - name: Download libzim dylib & headers from OpenZIM.org releases | ||
| if: steps.cache-libzim.outputs.cache-hit != 'true' | ||
| run: | | ||
| wget -q https://download.openzim.org/release/libzim/$LIBZIM_RELEASE.tar.gz | ||
| tar --gunzip --extract --file=$LIBZIM_RELEASE.tar.gz | ||
| mv $LIBZIM_RELEASE libzim_linux | ||
|
|
||
| - name: Link libzim dylib & headers into workspace lib and include folders | ||
| run: | | ||
| cp -p $GITHUB_WORKSPACE/libzim_linux/$LIBZIM_LIBRARY_PATH lib/libzim.so | ||
| cp -p $GITHUB_WORKSPACE/libzim_linux/$LIBZIM_LIBRARY_PATH lib/ | ||
| sudo ldconfig $GITHUB_WORKSPACE/lib | ||
| ln -s $GITHUB_WORKSPACE/libzim_linux/$LIBZIM_INCLUDE_PATH include/zim | ||
|
|
||
| - name: Build cython, sdist, and bdist_wheels | ||
| run: | | ||
| pip install --upgrade cython==$CYTHON_VERSION setuptools pip | ||
| python3 setup.py build_ext | ||
| python3 setup.py sdist bdist_wheel | ||
| python -m cibuildwheel --output-dir wheelhouse | ||
|
|
||
| - uses: actions/upload-artifact@v1 | ||
| with: | ||
| name: wheels | ||
| path: ./wheelhouse | ||
|
|
||
| - name: Push release to PyPI | ||
| if: github.event_name == 'push' && github.ref == 'refs/heads/master' | ||
| uses: pypa/gh-action-pypi-publish@master | ||
| with: | ||
| user: __token__ | ||
| password: ${{ secrets.PYPI_API_TOKEN }} | ||
| # TODO: remove this line to upload to the real PyPI when ready | ||
| repository_url: https://test.pypi.org/legacy/ | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| name: test | ||
| on: [push] | ||
|
|
||
| env: | ||
| LIBZIM_RELEASE: libzim_linux-x86_64-6.1.1 | ||
| LIBZIM_LIBRARY_PATH: lib/x86_64-linux-gnu/libzim.so.6.1.1 | ||
| LIBZIM_INCLUDE_PATH: include/zim | ||
| CYTHON_VERSION: 0.29.6 | ||
| MAX_LINE_LENGTH: 110 | ||
|
|
||
| jobs: | ||
| lint: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
|
|
||
| - name: Set up Python ${{ matrix.python }} | ||
| uses: actions/setup-python@v1 | ||
| with: | ||
| python-version: 3.6 | ||
| architecture: x64 | ||
|
|
||
| - name: Autoformat with black | ||
| run: | | ||
| pip install black | ||
| black --check --exclude=setup.py . | ||
|
|
||
| - name: Lint with flake8 | ||
| run: | | ||
| pip install flake8 | ||
| # one pass for show-stopper syntax errors or undefined names | ||
| flake8 . --count --select=E9,F63,F7,F82 --exclude=setup.py --show-source --statistics | ||
| # one pass for small stylistic things | ||
| flake8 . --count --exclude=setup.py --max-line-length=$MAX_LINE_LENGTH --statistics | ||
|
|
||
| test: | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| matrix: | ||
| os: [ubuntu-latest] | ||
| # TODO: expand this once macos and windows libzim releases become available | ||
| # os: [ubuntu-latest, windows-latest, macos-latest] | ||
| # alternatively we can compile libzim in docker and use the container as an action | ||
| python: [3.6, 3.7, 3.8] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v2 | ||
|
|
||
| - name: Set up Python ${{ matrix.python }} | ||
| uses: actions/setup-python@v1 | ||
| with: | ||
| python-version: ${{ matrix.python }} | ||
| architecture: x64 | ||
|
|
||
| - name: Cache libzim dylib & headers | ||
| uses: actions/cache@master | ||
| id: cache-libzim | ||
| with: | ||
| path: libzim_linux | ||
| key: ${{ env.LIBZIM_RELEASE }}-libzim-cache | ||
|
|
||
| - name: Download libzim dylib & headers from OpenZIM.org releases | ||
| if: steps.cache-libzim.outputs.cache-hit != 'true' | ||
| run: | | ||
| wget -q https://download.openzim.org/release/libzim/$LIBZIM_RELEASE.tar.gz | ||
| tar --gunzip --extract --file=$LIBZIM_RELEASE.tar.gz | ||
| mv $LIBZIM_RELEASE libzim_linux | ||
|
|
||
| - name: Link libzim dylib & headers into workspace lib and include folders | ||
| run: | | ||
| cp -p $GITHUB_WORKSPACE/libzim_linux/$LIBZIM_LIBRARY_PATH lib/libzim.so | ||
| cp -p $GITHUB_WORKSPACE/libzim_linux/$LIBZIM_LIBRARY_PATH lib/ | ||
| sudo ldconfig $GITHUB_WORKSPACE/lib | ||
| ln -s $GITHUB_WORKSPACE/libzim_linux/$LIBZIM_INCLUDE_PATH include/zim | ||
|
|
||
| - name: Build cython, sdist, and bdist_wheel | ||
| run: | | ||
| pip install --upgrade cython==$CYTHON_VERSION setuptools pip wheel | ||
| python3 setup.py build_ext | ||
| python3 setup.py sdist bdist_wheel | ||
|
|
||
| - name: Test built package with pytest | ||
| run: | | ||
| export LD_LIBRARY_PATH=$PWD/lib:$LD_LIBRARY_PATH | ||
| sudo ldconfig | ||
| pip install pytest | ||
| pip install -e . | ||
| pytest . |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,25 @@ | ||
| # General cruft | ||
| .DS_Store | ||
| .venv | ||
| .venv-docker | ||
| .mypy_cache | ||
| __pycache__ | ||
| build | ||
| *.pyc | ||
| .tox | ||
|
|
||
| # Compiled binaries and package builds | ||
| *.so | ||
| build/ | ||
| dist/ | ||
| *.egg-info/ | ||
|
|
||
| # Dylibs and headers | ||
| lib/* | ||
| include/* | ||
| libzim_linux-*/ | ||
|
|
||
| # Autogenerated files | ||
| libzim_wrapper.*.so | ||
| libzim/libzim_wrapper.cpp | ||
| libzim/libzim_wrapper.h | ||
| libzim/libzim_wrapper_api.h | ||
| *.egg-info |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| include LICENSE | ||
| include README.md | ||
| include tests/*.py | ||
| include pyproject.toml | ||
|
|
||
| recursive-include lib * | ||
| recursive-include include * | ||
| recursive-include libzim * |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| [[source]] | ||
| name = "pypi" | ||
| url = "https://pypi.org/simple" | ||
| verify_ssl = true | ||
|
|
||
| [dev-packages] | ||
| pytest = "*" | ||
| cython = "==0.29.6" | ||
| e1839a8 = {editable = true, path = "."} | ||
|
|
||
| [packages] |
File renamed without changes.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Put your zim/*.h folder in here. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Put your libzim.so file in here. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,4 @@ | ||
| # flake8: noqa | ||
|
|
||
| from libzim_wrapper import File | ||
| from libzim_wrapper import ReadArticle as Article |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| [build-system] | ||
| requires = [ "setuptools >= 35.0.2", "wheel >= 0.29.0", "twine", "cython == 0.29.6" ] | ||
| build-backend = "setuptools.build_meta" | ||
|
|
||
| [tool.black] | ||
| line-length = 110 | ||
| target-version = ['py36', 'py37', 'py38'] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.