|
| 1 | +name: test |
| 2 | +on: [push] |
| 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 --check --exclude=setup.py . |
| 27 | +
|
| 28 | + - name: Lint with flake8 |
| 29 | + run: | |
| 30 | + pip install flake8 |
| 31 | + # one pass for show-stopper syntax errors or undefined names |
| 32 | + flake8 . --count --select=E9,F63,F7,F82 --exclude=setup.py --show-source --statistics |
| 33 | + # one pass for small stylistic things |
| 34 | + flake8 . --count --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 | + |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@v2 |
| 48 | + |
| 49 | + - name: Set up Python ${{ matrix.python }} |
| 50 | + uses: actions/setup-python@v1 |
| 51 | + with: |
| 52 | + python-version: ${{ matrix.python }} |
| 53 | + architecture: x64 |
| 54 | + |
| 55 | + - name: Cache libzim dylib & headers |
| 56 | + uses: actions/cache@master |
| 57 | + id: cache-libzim |
| 58 | + with: |
| 59 | + path: libzim_linux |
| 60 | + key: ${{ env.LIBZIM_RELEASE }}-libzim-cache |
| 61 | + |
| 62 | + - name: Download libzim dylib & headers from OpenZIM.org releases |
| 63 | + if: steps.cache-libzim.outputs.cache-hit != 'true' |
| 64 | + run: | |
| 65 | + wget -q https://download.openzim.org/release/libzim/$LIBZIM_RELEASE.tar.gz |
| 66 | + tar --gunzip --extract --file=$LIBZIM_RELEASE.tar.gz |
| 67 | + mv $LIBZIM_RELEASE libzim_linux |
| 68 | +
|
| 69 | + - name: Link libzim dylib & headers into workspace lib and include folders |
| 70 | + run: | |
| 71 | + cp -p $GITHUB_WORKSPACE/libzim_linux/$LIBZIM_LIBRARY_PATH lib/libzim.so |
| 72 | + cp -p $GITHUB_WORKSPACE/libzim_linux/$LIBZIM_LIBRARY_PATH lib/ |
| 73 | + sudo ldconfig $GITHUB_WORKSPACE/lib |
| 74 | + ln -s $GITHUB_WORKSPACE/libzim_linux/$LIBZIM_INCLUDE_PATH include/zim |
| 75 | + |
| 76 | + - name: Build cython, sdist, and bdist_wheel |
| 77 | + run: | |
| 78 | + pip install --upgrade cython==$CYTHON_VERSION setuptools pip wheel |
| 79 | + python3 setup.py build_ext |
| 80 | + python3 setup.py sdist bdist_wheel |
| 81 | + |
| 82 | + - name: Test built package with pytest |
| 83 | + run: | |
| 84 | + export LD_LIBRARY_PATH=$PWD/lib:$LD_LIBRARY_PATH |
| 85 | + sudo ldconfig |
| 86 | + pip install pytest |
| 87 | + pip install -e . |
| 88 | + pytest . |
0 commit comments