|
| 1 | +# Workflow to build and test wheels |
| 2 | +# ================================= |
| 3 | +# This github action gets triggered whenever there |
| 4 | +# is a push to the master branch or a release is created. |
| 5 | +# It generates both wheels and distributions files, |
| 6 | +# making sure their contents are correct via unit-testing. |
| 7 | +# |
| 8 | +# However, only in the case of a github release, the assets |
| 9 | +# are uploaded and attached to a release. In other words, we |
| 10 | +# expect the following workflow: |
| 11 | +# 1- users adds new features to the master branch via PRs. Every |
| 12 | +# time a new feature gets merged to the master branch, this github |
| 13 | +# action gets triggered, and wheels/distribution files are generated |
| 14 | +# to make sure this new change did not break the distribution files. |
| 15 | +# 2- Whenever there is enough PRs in the master branch, we expect the user |
| 16 | +# to create a release following github guidelines from here: |
| 17 | +# https://docs.github.com/en/github/administering-a-repository/releasing-projects-on-github/managing-releases-in-a-repository |
| 18 | +# During a github release, you create a tagged-version (something like v2.3.4.), |
| 19 | +# add a title to the release and a description. Then you publish the release via the |
| 20 | +# publish-button. This effectively creates a github release, triggering this action. |
| 21 | +# When this triggered action finished, the release files are automatically uploaded |
| 22 | +# to your github release page. Check for example: |
| 23 | +# https://github.com/automl/ConfigSpace/releases |
| 24 | +# |
| 25 | +# Please note that creating a git tag and pushing it (git tag <>; git push --tags) is not |
| 26 | +# sufficient to append the wheels and distribution files to your release. |
| 27 | +# You need to generate a new release using github, not git. |
| 28 | + |
| 29 | +name: Wheel builder |
| 30 | + |
| 31 | +on: |
| 32 | + push: |
| 33 | + branches: |
| 34 | + - master |
| 35 | + # Release branches |
| 36 | + - "[0-9]+.[0-9]+.X" |
| 37 | + create: |
| 38 | + tags: |
| 39 | + - v* |
| 40 | + |
| 41 | +jobs: |
| 42 | + # Build the wheels for Linux |
| 43 | + build_wheels: |
| 44 | + name: Build wheel for cp${{ matrix.python }}-${{ matrix.platform_id }}-${{ matrix.manylinux_image }} |
| 45 | + runs-on: ${{ matrix.os }} |
| 46 | + |
| 47 | + strategy: |
| 48 | + # Ensure that a wheel builder finishes even if another fails |
| 49 | + fail-fast: false |
| 50 | + matrix: |
| 51 | + os: [ubuntu-latest] |
| 52 | + python: [36, 37, 38, 39] |
| 53 | + bitness: [32, 64] |
| 54 | + manylinux_image: [manylinux2014] |
| 55 | + include: |
| 56 | + - os: ubuntu-latest |
| 57 | + bitness: 64 |
| 58 | + platform_id: manylinux_x86_64 |
| 59 | + - os: ubuntu-latest |
| 60 | + bitness: 32 |
| 61 | + platform_id: manylinux_i686 |
| 62 | + |
| 63 | + steps: |
| 64 | + - name: Checkout ConfigSpace |
| 65 | + uses: actions/checkout@v1 |
| 66 | + |
| 67 | + - name: Setup Python |
| 68 | + uses: actions/setup-python@v2 |
| 69 | + |
| 70 | + - name: Build and test wheels |
| 71 | + env: |
| 72 | + CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }} |
| 73 | + CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.manylinux_image }} |
| 74 | + CIBW_MANYLINUX_I686_IMAGE: ${{ matrix.manylinux_image }} |
| 75 | + CIBW_TEST_REQUIRES: pytest threadpoolctl numpy |
| 76 | + CIBW_TEST_COMMAND: pytest -v /project/test |
| 77 | + |
| 78 | + run: | |
| 79 | + python -m pip install cibuildwheel |
| 80 | + python -m cibuildwheel --output-dir wheelhouse |
| 81 | +
|
| 82 | + - name: Store artifacts |
| 83 | + uses: actions/upload-artifact@v2 |
| 84 | + with: |
| 85 | + path: wheelhouse/*.whl |
| 86 | + |
| 87 | + # Build the source distribution under Linux |
| 88 | + build_sdist: |
| 89 | + name: Source distribution |
| 90 | + runs-on: ubuntu-latest |
| 91 | + |
| 92 | + steps: |
| 93 | + - name: Checkout ConfigSpace |
| 94 | + uses: actions/checkout@v1 |
| 95 | + |
| 96 | + - name: Setup Python |
| 97 | + uses: actions/setup-python@v2 |
| 98 | + |
| 99 | + - name: Build source distribution |
| 100 | + run: python setup.py sdist |
| 101 | + |
| 102 | + # Full unit-testing is handled in pytest.yml |
| 103 | + - name: Twine check |
| 104 | + run: | |
| 105 | + pip install twine |
| 106 | + last_dist=$(ls -t dist/ConfigSpace-*.tar.gz | head -n 1) |
| 107 | + twine_output=`twine check "$last_dist"` |
| 108 | + if [[ "$twine_output" != "Checking $last_dist: PASSED" ]]; then echo $twine_output && exit 1;fi |
| 109 | + - name: Install dist |
| 110 | + run: | |
| 111 | + last_dist=$(ls -t dist/ConfigSpace-*.tar.gz | head -n 1) |
| 112 | + pip install $last_dist |
| 113 | + - name: PEP 561 Compliance |
| 114 | + run: | |
| 115 | + pip install mypy |
| 116 | + cd .. # required to use the installed version of ConfigSpace |
| 117 | + if ! python -c "import ConfigSpace"; then exit 1; fi |
| 118 | +
|
| 119 | + - name: Store artifacts |
| 120 | + uses: actions/upload-artifact@v2 |
| 121 | + with: |
| 122 | + path: dist/*.tar.gz |
| 123 | + |
| 124 | + # Upload the wheels and the source distribution |
| 125 | + release_assets: |
| 126 | + name: Upload Release |
| 127 | + runs-on: ubuntu-latest |
| 128 | + needs: [build_wheels, build_sdist] |
| 129 | + # Only on a tagged release, push |
| 130 | + if: startsWith(github.ref, 'refs/tags/v') && github.event_name != 'pull_request' |
| 131 | + |
| 132 | + steps: |
| 133 | + - name: Checkout ConfigSpace |
| 134 | + uses: actions/checkout@v1 |
| 135 | + |
| 136 | + - name: Download artifacts |
| 137 | + uses: actions/download-artifact@v2 |
| 138 | + with: |
| 139 | + path: dist |
| 140 | + |
| 141 | + - name: Setup Python |
| 142 | + uses: actions/setup-python@v2 |
| 143 | + |
| 144 | + - name: Install dependencies |
| 145 | + run: | |
| 146 | + python -m pip install --upgrade pip |
| 147 | + pip install setuptools wheel twine |
| 148 | +
|
| 149 | + - name: Upload Release Asset |
| 150 | + id: upload-release-asset |
| 151 | + env: |
| 152 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 153 | + run: | |
| 154 | + tag_name="${GITHUB_REF##*/}" |
| 155 | + echo Uploading `(find ./dist -type f -printf "-a %p ")` |
| 156 | + hub release edit $(find ./dist -type f -printf "-a %p ") -m "" "$tag_name" |
0 commit comments