|
| 1 | +name: Continous integration |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths-ignore: |
| 6 | + - 'docs/**' |
| 7 | + - '*.rst' |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - develop |
| 11 | + - main |
| 12 | + tags: |
| 13 | + - "*" |
| 14 | + |
| 15 | +jobs: |
| 16 | + lint: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + |
| 20 | + with: |
| 21 | + submodules: recursive |
| 22 | + - name: Set up Python 3.7 |
| 23 | + |
| 24 | + with: |
| 25 | + python-version: 3.7 |
| 26 | + - name: Install tox |
| 27 | + run: pip install tox |
| 28 | + - name: Lint |
| 29 | + run: tox -e lint |
| 30 | + |
| 31 | + package-checks: |
| 32 | + strategy: |
| 33 | + matrix: |
| 34 | + tox_env: |
| 35 | + - docs |
| 36 | + - twine_check |
| 37 | + runs-on: ubuntu-latest |
| 38 | + steps: |
| 39 | + |
| 40 | + with: |
| 41 | + submodules: recursive |
| 42 | + - name: Set up Python 3.7 |
| 43 | + |
| 44 | + with: |
| 45 | + python-version: 3.7 |
| 46 | + - name: Install tox and upgrade setuptools and pip |
| 47 | + run: pip install --upgrade tox setuptools pip |
| 48 | + - name: Run tox -e ${{ matrix.tox_env }} |
| 49 | + run: tox -e ${{ matrix.tox_env }} |
| 50 | + |
| 51 | + test-static: |
| 52 | + runs-on: ${{ matrix.os }} |
| 53 | + strategy: |
| 54 | + matrix: |
| 55 | + python-version: |
| 56 | + - "3.7" |
| 57 | + - "3.8" |
| 58 | + - "3.9" |
| 59 | + - "3.10" |
| 60 | + - "3.11" |
| 61 | + - "pypy-3.7" |
| 62 | + - "pypy-3.8" |
| 63 | + - "pypy-3.9" |
| 64 | + os: ["ubuntu-latest"] |
| 65 | + include: |
| 66 | + - os: "macos-latest" |
| 67 | + python-version: 3.7 |
| 68 | + - os: "windows-latest" |
| 69 | + python-version: 3.7 |
| 70 | + steps: |
| 71 | + |
| 72 | + with: |
| 73 | + submodules: recursive |
| 74 | + - name: Set up Python ${{ matrix.python-version }} |
| 75 | + |
| 76 | + with: |
| 77 | + python-version: ${{ matrix.python-version }} |
| 78 | + - name: Install tox and upgrade setuptools |
| 79 | + run: pip install --upgrade tox setuptools |
| 80 | + - name: Set MSVC developer prompt |
| 81 | + |
| 82 | + if: runner.os == 'Windows' |
| 83 | + - name: Install build dependencies (MacOS) |
| 84 | + run: brew install make |
| 85 | + if: runner.os == 'macOS' |
| 86 | + - name: Run tests |
| 87 | + run: tox |
| 88 | + - name: Upload coverage report |
| 89 | + uses: codecov/codecov-action@v1 |
| 90 | + |
| 91 | + test-arch: |
| 92 | + if: startsWith(github.ref, 'refs/tags') || github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main' |
| 93 | + runs-on: "ubuntu-latest" |
| 94 | + strategy: |
| 95 | + matrix: |
| 96 | + distro: [ "ubuntu_latest" ] |
| 97 | + arch: ["aarch64"] |
| 98 | + steps: |
| 99 | + |
| 100 | + with: |
| 101 | + submodules: recursive |
| 102 | + |
| 103 | + name: Build & run test |
| 104 | + with: |
| 105 | + arch: ${{ matrix.arch }} |
| 106 | + distro: ${{ matrix.distro }} |
| 107 | + install: | |
| 108 | + apt-get update -q -y |
| 109 | + apt-get install -q -y python3 python3-pip tox cmake |
| 110 | + run: | |
| 111 | + tox |
| 112 | +
|
| 113 | + # Test if the python-zlib-ng conda package can be build. Which is linked |
| 114 | + # dynamically to the conda zlib-ng package. |
| 115 | + test-dynamic: |
| 116 | + runs-on: ${{ matrix.os }} |
| 117 | + defaults: |
| 118 | + run: |
| 119 | + # This is needed for miniconda, see: |
| 120 | + # https://github.com/marketplace/actions/setup-miniconda#important. |
| 121 | + shell: bash -l {0} |
| 122 | + strategy: |
| 123 | + matrix: |
| 124 | + os: ["ubuntu-latest", "macos-latest", "windows-latest"] |
| 125 | + python_version: [ "python" ] |
| 126 | + include: |
| 127 | + - os: "ubuntu-latest" |
| 128 | + python_version: "pypy" |
| 129 | + steps: |
| 130 | + |
| 131 | + with: |
| 132 | + submodules: recursive |
| 133 | + - name: Install miniconda. |
| 134 | + uses: conda-incubator/[email protected] # https://github.com/conda-incubator/setup-miniconda. |
| 135 | + with: |
| 136 | + channels: conda-forge,defaults |
| 137 | + - name: Install requirements (universal) |
| 138 | + run: conda install zlib-ng ${{ matrix.python_version}} tox |
| 139 | + - name: Set MSVC developer prompt |
| 140 | + |
| 141 | + if: runner.os == 'Windows' |
| 142 | + - name: Run tests (dynamic link) |
| 143 | + run: tox |
| 144 | + env: |
| 145 | + PYTHON_ZLIB_NG_LINK_DYNAMIC: True |
| 146 | + |
| 147 | + deploy: |
| 148 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') |
| 149 | + runs-on: ${{ matrix.os }} |
| 150 | + needs: |
| 151 | + - lint |
| 152 | + - package-checks |
| 153 | + - test-static |
| 154 | + - test-dynamic |
| 155 | + - test-arch |
| 156 | + strategy: |
| 157 | + matrix: |
| 158 | + os: |
| 159 | + - ubuntu-latest |
| 160 | + - macos-latest |
| 161 | + - windows-latest |
| 162 | + cibw_archs_linux: ["x86_64"] |
| 163 | + build_sdist: [true] |
| 164 | + include: |
| 165 | + - os: "ubuntu-latest" |
| 166 | + cibw_archs_linux: "aarch64" |
| 167 | + steps: |
| 168 | + |
| 169 | + with: |
| 170 | + submodules: recursive |
| 171 | + - uses: actions/setup-python@v2 |
| 172 | + name: Install Python |
| 173 | + - name: Install cibuildwheel twine build |
| 174 | + run: python -m pip install cibuildwheel twine build |
| 175 | + - name: Install build dependencies (Macos) |
| 176 | + run: brew install make |
| 177 | + if: runner.os == 'macOS' |
| 178 | + - name: Set MSVC developer prompt |
| 179 | + |
| 180 | + if: runner.os == 'Windows' |
| 181 | + - name: Set up QEMU |
| 182 | + if: ${{runner.os == 'Linux' && matrix.cibw_archs_linux == 'aarch64'}} |
| 183 | + |
| 184 | + with: |
| 185 | + platforms: arm64 |
| 186 | + - name: Build wheels |
| 187 | + run: cibuildwheel --output-dir dist |
| 188 | + env: |
| 189 | + CIBW_SKIP: "*-win32 *-manylinux_i686" # Skip 32 bit |
| 190 | + CIBW_ARCHS_LINUX: ${{ matrix.cibw_archs_linux }} |
| 191 | + CIBW_TEST_REQUIRES: "pytest" |
| 192 | + # Simple tests that requires the project to be build correctly |
| 193 | + CIBW_TEST_COMMAND_LINUX: >- |
| 194 | + pytest {project}/tests/test_zlib_compliance.py |
| 195 | + {project}/tests/test_gzip_compliance.py |
| 196 | + {project}/tests/test_gzip_ng.py |
| 197 | + CIBW_TEST_COMMAND_MACOS: >- |
| 198 | + pytest {project}/tests/test_zlib_compliance.py |
| 199 | + {project}/tests/test_gzip_compliance.py |
| 200 | + {project}/tests/test_gzip_ng.py |
| 201 | + # Windows does not have the test module in the included python. |
| 202 | + # Run compatibility tests instead. |
| 203 | + CIBW_TEST_COMMAND_WINDOWS: >- |
| 204 | + pytest {project}/tests/test_compat.py |
| 205 | + {project}/tests/test_gzip_ng.py |
| 206 | + CIBW_ENVIRONMENT_LINUX: >- |
| 207 | + PYTHON_ZLIB_NG_BUILD_CACHE=True |
| 208 | + PYTHON_ZLIB_NG_BUILD_CACHE_FILE=/tmp/build_cache |
| 209 | + CFLAGS="-g0 -DNDEBUG" |
| 210 | + CIBW_ENVIRONMENT_WINDOWS: >- |
| 211 | + PYTHON_ZLIB_NG_BUILD_CACHE=True |
| 212 | + PYTHON_ZLIB_NG_BUILD_CACHE_FILE=${{ runner.temp }}\build_cache |
| 213 | + CIBW_ENVIRONMENT_MACOS: >- |
| 214 | + PYTHON_ZLIB_NG_BUILD_CACHE=True |
| 215 | + PYTHON_ZLIB_NG_BUILD_CACHE_FILE=${{ runner.temp }}/build_cache |
| 216 | + CFLAGS="-g0 -DNDEBUG" |
| 217 | + - name: Build sdist |
| 218 | + if: ${{runner.os == 'Linux' && matrix.cibw_archs_linux == 'x86_64'}} |
| 219 | + run: |
| 220 | + python -m build --sdist |
| 221 | + - uses: actions/upload-artifact@v2 |
| 222 | + with: |
| 223 | + name: "dist" |
| 224 | + path: "dist/" |
| 225 | + - name: Publish package to TestPyPI |
| 226 | + # pypa/gh-action-pypi-publish@master does not work on OSX |
| 227 | + # Alpha, Beta and dev releases contain a - in the tag. |
| 228 | + if: contains(github.ref, '-') && startsWith(github.ref, 'refs/tags') |
| 229 | + run: twine upload --skip-existing -r testpypi dist/* |
| 230 | + env: |
| 231 | + TWINE_USERNAME: __token__ |
| 232 | + TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }} |
| 233 | + - name: Publish package to PyPI |
| 234 | + if: "!contains(github.ref, '-') && startsWith(github.ref, 'refs/tags')" |
| 235 | + run: twine upload --skip-existing dist/* |
| 236 | + env: |
| 237 | + TWINE_USERNAME: __token__ |
| 238 | + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} |
0 commit comments