|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + branches: |
| 8 | + - main |
| 9 | + paths-ignore: |
| 10 | + - '**.md' |
| 11 | + - '**.yml' |
| 12 | + - '.github/**' |
| 13 | + - 'examples/**' |
| 14 | + - 'tests/**' |
| 15 | + pull_request: |
| 16 | + branches: |
| 17 | + - main |
| 18 | + workflow_dispatch: |
| 19 | + |
| 20 | +jobs: |
| 21 | + build_wheels_linux_arm64: |
| 22 | + name: ${{ matrix.os }} py${{ matrix.python-version }} |
| 23 | + runs-on: |
| 24 | + - self-hosted |
| 25 | + - ARM64 |
| 26 | + strategy: |
| 27 | + fail-fast: false |
| 28 | + matrix: |
| 29 | + os: [ ubuntu-20.04 ] |
| 30 | + python-version: [ "3.8", "3.9", "3.10", "3.11"] |
| 31 | + # python-version: [ "3.7" ] |
| 32 | + env: |
| 33 | + RUNNER_OS: ${{ matrix.os }} |
| 34 | + PYTHON_VERSION: ${{ matrix.python-version }} |
| 35 | + steps: |
| 36 | + - name: switch python |
| 37 | + run: | |
| 38 | + pyenv local "${{ matrix.python-version }}" |
| 39 | + python --version |
| 40 | + shell: bash |
| 41 | + - name: Install clang++ for Ubuntu |
| 42 | + if: matrix.os == 'ubuntu-20.04' |
| 43 | + run: | |
| 44 | + python --version |
| 45 | + pwd |
| 46 | + uname -a |
| 47 | + wget https://apt.llvm.org/llvm.sh |
| 48 | + chmod +x llvm.sh |
| 49 | + sudo ./llvm.sh 15 |
| 50 | + which clang++-15 |
| 51 | + clang++-15 --version |
| 52 | + sudo apt-get install -y make cmake ccache ninja-build yasm gawk wget |
| 53 | + ccache -s |
| 54 | + - name: Update git |
| 55 | + run: | |
| 56 | + sudo add-apt-repository ppa:git-core/ppa -y |
| 57 | + sudo apt-get update |
| 58 | + sudo apt-get install -y git |
| 59 | + git --version |
| 60 | + - uses: actions/checkout@v3 |
| 61 | + with: |
| 62 | + fetch-depth: 0 |
| 63 | + - name: Restore submodules cache |
| 64 | + uses: actions/cache/restore@v3 |
| 65 | + id: cache |
| 66 | + with: |
| 67 | + path: | |
| 68 | + contrib/** |
| 69 | + key: | |
| 70 | + submodule-${{ hashFiles('.gitmodules') }} |
| 71 | + - name: Update submodules if cache miss |
| 72 | + if: steps.cache.outputs.cache-hit != 'true' |
| 73 | + run: | |
| 74 | + git submodule update --init --recursive --jobs 4 |
| 75 | + - name: Save submodules cache |
| 76 | + if: steps.cache.outputs.cache-hit != 'true' |
| 77 | + uses: actions/cache/save@v3 |
| 78 | + with: |
| 79 | + path: | |
| 80 | + contrib/** |
| 81 | + key: | |
| 82 | + submodule-${{ hashFiles('.gitmodules') }} |
| 83 | + - name: ccache |
| 84 | + uses: hendrikmuhs/[email protected] |
| 85 | + with: |
| 86 | + key: ${{ matrix.os }} |
| 87 | + max-size: 5G |
| 88 | + append-timestamp: true |
| 89 | + - name: remove old clang and link clang-15 to clang |
| 90 | + if: matrix.os == 'ubuntu-20.04' |
| 91 | + run: | |
| 92 | + sudo rm /usr/bin/clang |
| 93 | + sudo ln -s /usr/bin/clang-15 /usr/bin/clang |
| 94 | + sudo rm /usr/bin/clang++ |
| 95 | + sudo ln -s /usr/bin/clang++-15 /usr/bin/clang++ |
| 96 | + which clang++ |
| 97 | + clang++ --version |
| 98 | + - name: Run chdb/build.sh |
| 99 | + run: | |
| 100 | + python3 --version |
| 101 | + python3 -m pip install pybind11 |
| 102 | + export CC=/usr/bin/clang |
| 103 | + export CXX=/usr/bin/clang++ |
| 104 | + bash ./chdb/build.sh |
| 105 | + python3 -m pip install pandas pyarrow |
| 106 | + bash -x ./chdb/test_smoke.sh |
| 107 | + shell: bash |
| 108 | + continue-on-error: false |
| 109 | + - name: Check ccache statistics |
| 110 | + run: | |
| 111 | + ccache -s |
| 112 | + ls -lh chdb |
| 113 | + df -h |
| 114 | + - name: Install dependencies for building wheels |
| 115 | + run: python3 -m pip install -U pip tox pybind11 twine setuptools wheel |
| 116 | + shell: bash |
| 117 | + - name: Build wheels |
| 118 | + run: | |
| 119 | + export CC=/usr/bin/clang |
| 120 | + export CXX=/usr/bin/clang++ |
| 121 | + make wheel |
| 122 | + shell: bash |
| 123 | + - name: Install patchelf from github |
| 124 | + run: | |
| 125 | + wget https://github.com/NixOS/patchelf/releases/download/0.17.2/patchelf-0.17.2-x86_64.tar.gz -O patchelf.tar.gz |
| 126 | + tar -xvf patchelf.tar.gz |
| 127 | + sudo cp bin/patchelf /usr/bin/ |
| 128 | + sudo chmod +x /usr/bin/patchelf |
| 129 | + patchelf --version |
| 130 | + - name: Audit wheels |
| 131 | + run: | |
| 132 | + python3 --version |
| 133 | + python3 -m pip install auditwheel |
| 134 | + auditwheel -v repair -w dist/ --plat manylinux2014_x86_64 dist/*.whl |
| 135 | + shell: bash |
| 136 | + continue-on-error: false |
| 137 | + - name: Show files |
| 138 | + run: | |
| 139 | + sudo rm -f dist/*-linux_x86_64.whl |
| 140 | + ls -lh dist |
| 141 | + shell: bash |
| 142 | + - name: Run tests |
| 143 | + run: | |
| 144 | + python3 --version |
| 145 | + python3 -m pip install dist/*.whl |
| 146 | + python3 -m pip install pandas pyarrow psutil |
| 147 | + python3 -c "import chdb; res = chdb.query('select 1112222222,555', 'CSV'); print(res)" |
| 148 | + make test |
| 149 | + shell: bash |
| 150 | + continue-on-error: false |
| 151 | + - uses: actions/upload-artifact@v3 |
| 152 | + with: |
| 153 | + path: ./dist/*.whl |
| 154 | + - name: Upload pypi |
| 155 | + if: startsWith(github.ref, 'refs/tags/v') |
| 156 | + run: | |
| 157 | + python3 -m pip install twine |
| 158 | + python3 -m twine upload dist/*.whl |
| 159 | + env: |
| 160 | + TWINE_USERNAME: __token__ |
| 161 | + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} |
| 162 | + |
| 163 | + # #build for macos12 arm64(Apple Silicon) |
| 164 | + # build_wheels_macos_arm64: |
| 165 | + |
| 166 | + ## Experimental Restart on Expire/Cancel (WIP) |
| 167 | + ## Requires: PAT Token |
| 168 | + ## the PAT token should have permissions according to this |
| 169 | + ## documentation - https://developer.github.com/v3/actions/workflow-runs/ |
| 170 | + restart_failed: |
| 171 | + name: Retry Expired Builds |
| 172 | + runs-on: ubuntu-latest |
| 173 | + if: github.event_name == 'push' && cancelled() |
| 174 | + needs: [ build_wheels_linux_arm64 ] |
| 175 | + steps: |
| 176 | + - name: Sleep for 20 seconds |
| 177 | + run: sleep 20s |
| 178 | + shell: bash |
| 179 | + - name: Retry Failed/Expired Build |
| 180 | + run: | |
| 181 | + curl -i \ |
| 182 | + -X POST \ |
| 183 | + -H "Accept: application/vnd.github.v3+json" \ |
| 184 | + -H "Authorization: token ${{ secrets.PAT_TOKEN }}" \ |
| 185 | + https://api.github.com/repos/chdb-io/chdb/actions/runs/${{ github.run_id }}/rerun \ |
| 186 | + -d '{"ref": "${{ github.ref }}" }' |
| 187 | + |
0 commit comments