ci.yml (10059B)
1 name: CI 2 3 on: 4 release: 5 types: [created] 6 push: 7 pull_request: 8 9 jobs: 10 lint: 11 runs-on: ubuntu-latest 12 steps: 13 - name: Checkout 14 uses: actions/checkout@v1 15 16 - name: Install latest nightly 17 uses: actions-rs/toolchain@v1 18 with: 19 toolchain: nightly 20 override: true 21 components: rustfmt, clippy 22 23 - name: Lint with rustfmt 24 uses: actions-rs/cargo@v1 25 with: 26 command: fmt 27 args: -- --check 28 29 # Disabled because of https://github.com/rust-lang/rust-clippy/issues/8971 30 # - name: Lint with clippy 31 # uses: actions-rs/cargo@v1 32 # with: 33 # command: clippy 34 # args: --all-targets --all-features -- -D clippy::all 35 36 - name: Lint with Black 37 run: pip install black && black --check . 38 39 - name: Lint with mypy 40 run: pip install mypy && mypy --non-interactive --install-types --ignore-missing-imports . 41 42 macos: 43 runs-on: macos-latest 44 needs: lint 45 steps: 46 - uses: actions/checkout@v2 47 48 - uses: actions/setup-python@v2 49 with: 50 python-version: 3.7 51 52 - name: Install Rust toolchain 53 uses: actions-rs/toolchain@v1 54 with: 55 toolchain: stable 56 target: aarch64-apple-darwin 57 profile: minimal 58 default: true 59 60 - name: Install maturin 61 run: pip install maturin 62 63 - name: Build wheels - x86_64 64 run: | 65 maturin build -i python --target x86_64-apple-darwin --release --out dist 66 pip install adblock --no-index --find-links dist --force-reinstall 67 68 - name: Build wheels - universal2 69 env: 70 DEVELOPER_DIR: /Applications/Xcode.app/Contents/Developer 71 MACOSX_DEPLOYMENT_TARGET: "10.9" 72 PYO3_CROSS_LIB_DIR: /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib 73 run: | 74 # Build wheels 75 maturin build -i python --release --universal2 --out dist 76 pip install adblock --no-index --find-links dist --force-reinstall 77 78 - name: Run PyTest 79 run: | 80 pip install pytest toml 81 pytest -vv --color=yes 82 83 - name: Check wheels with Twine 84 run: pip install twine && twine check dist/* 85 shell: bash 86 87 - name: Upload wheels 88 uses: actions/upload-artifact@v2 89 with: 90 name: wheels 91 path: dist 92 93 windows: 94 runs-on: windows-latest 95 needs: lint 96 strategy: 97 matrix: 98 platform: 99 [ 100 { python-architecture: "x64", target: "x86_64-pc-windows-msvc" }, 101 { python-architecture: "x86", target: "i686-pc-windows-msvc" }, 102 ] 103 steps: 104 - uses: actions/checkout@v2 105 106 - uses: actions/setup-python@v2 107 with: 108 python-version: 3.7 109 architecture: ${{ matrix.platform.python-architecture }} 110 111 - name: Install Rust toolchain 112 uses: actions-rs/toolchain@v1 113 with: 114 toolchain: stable 115 target: ${{ matrix.platform.target }} 116 profile: minimal 117 default: true 118 119 - name: Install maturin 120 run: pip install maturin 121 122 - name: Build wheels 123 run: | 124 maturin build -i python --release --out dist --target ${{ matrix.platform.target }} 125 pip install adblock --no-index --find-links dist --force-reinstall 126 127 - name: Run PyTest 128 run: | 129 pip install pytest toml 130 pytest -vv --color=yes 131 132 - name: Check wheels with Twine 133 run: pip install twine && twine check dist/* 134 shell: bash 135 136 - name: Upload wheels 137 uses: actions/upload-artifact@v2 138 with: 139 name: wheels 140 path: dist 141 142 linux: 143 runs-on: ubuntu-latest 144 needs: lint 145 strategy: 146 matrix: 147 platform: 148 [ 149 { 150 toolchain: "1.53", 151 manylinux: "2014", 152 target: "x86_64-unknown-linux-gnu", 153 arch: "x86_64", 154 python-version: "3.7" 155 }, 156 { 157 toolchain: "nightly", 158 manylinux: "2014", 159 target: "x86_64-unknown-linux-gnu", 160 arch: "x86_64", 161 python-version: "3.7" 162 }, 163 { 164 toolchain: "stable", 165 manylinux: "2014", 166 target: "x86_64-unknown-linux-gnu", 167 arch: "x86_64", 168 python-version: "3.7" 169 }, 170 { 171 toolchain: "stable", 172 manylinux: "2014", 173 target: "x86_64-unknown-linux-gnu", 174 arch: "x86_64", 175 python-version: "3.11" 176 } 177 ] 178 steps: 179 - uses: actions/checkout@v2 180 181 - uses: actions/setup-python@v2 182 with: 183 python-version: ${{ matrix.platform.python-version }} 184 185 - name: Build Wheels 186 run: | 187 echo 'curl -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain ${{ matrix.platform.toolchain }} 188 source ~/.cargo/env 189 export PATH=/opt/python/cp38-cp38/bin:$PATH 190 pip install maturin 191 maturin build -i python --release --out dist --target ${{ matrix.platform.target }} --manylinux ${{ matrix.platform.manylinux }} 192 ' > build-wheel.sh 193 chmod +x build-wheel.sh 194 docker run --rm -v "$PWD":/io -w /io quay.io/pypa/manylinux${{ matrix.platform.manylinux }}_${{ matrix.platform.arch }} bash build-wheel.sh 195 196 - name: Run PyTest 197 run: | 198 pip install adblock --no-index --find-links dist --force-reinstall 199 pip install pytest toml 200 pytest -vv --color=yes 201 202 - name: Auditwheel Symbols 203 run: | 204 pip install auditwheel-symbols 205 auditwheel-symbols dist/*.whl 206 207 - name: Check wheels with Twine 208 run: pip install twine && twine check dist/* 209 shell: bash 210 211 - name: Upload wheels 212 if: matrix.platform.toolchain == 'stable' 213 uses: actions/upload-artifact@v2 214 with: 215 name: wheels 216 path: dist 217 218 linux-cross: 219 runs-on: ubuntu-latest 220 needs: lint 221 strategy: 222 matrix: 223 platform: 224 [ 225 { 226 manylinux: "2014", 227 target: "aarch64-unknown-linux-gnu", 228 arch: "aarch64", 229 }, 230 { 231 manylinux: "2014", 232 target: "armv7-unknown-linux-gnueabihf", 233 arch: "armv7", 234 }, 235 ] 236 steps: 237 - uses: actions/checkout@v2 238 239 - uses: actions/setup-python@v2 240 with: 241 python-version: 3.7 242 243 - name: Build Wheels 244 run: | 245 echo 'curl -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable 246 source ~/.cargo/env 247 rustup target add ${{ matrix.platform.target }} 248 pip install maturin 249 maturin build -i python --release --out dist --target ${{ matrix.platform.target }} --manylinux ${{ matrix.platform.manylinux }} 250 ' > build-wheel.sh 251 chmod +x build-wheel.sh 252 docker run --rm -v "$PWD":/io -w /io messense/manylinux2014-cross:${{ matrix.platform.arch }} bash build-wheel.sh 253 254 - uses: uraimo/run-on-arch-action@v2.2.0 255 name: Install built wheel 256 with: 257 arch: ${{ matrix.platform.arch }} 258 distro: ubuntu22.04 259 # Mount the dist directory as /artifacts in the container 260 dockerRunArgs: | 261 --volume "${PWD}/dist:/artifacts" 262 install: | 263 apt-get update 264 apt-get install -y --no-install-recommends python3 python3-pip 265 pip3 install -U pip 266 run: | 267 ls -lrth /artifacts 268 pip3 install adblock --no-index --find-links /artifacts --force-reinstall 269 cd ~ && python3 -c "import adblock" 270 271 - name: Auditwheel Symbols 272 run: | 273 pip install auditwheel-symbols 274 auditwheel-symbols dist/*.whl 275 276 - name: Check wheels with Twine 277 run: pip install twine && twine check dist/* 278 shell: bash 279 280 - name: Upload wheels 281 uses: actions/upload-artifact@v2 282 with: 283 name: wheels 284 path: dist 285 286 python-publish: 287 runs-on: ubuntu-latest 288 needs: [ macos, windows, linux, linux-cross ] 289 steps: 290 - uses: actions/download-artifact@v2 291 with: 292 name: wheels 293 294 - uses: actions/setup-python@v2 295 with: 296 python-version: 3.9 297 298 - name: Wheel filename sanity checks 299 run: | 300 ls -lah 301 num_abi3_whl=$(find | grep "\./adblock.*-abi3.*\.whl" | wc -l) 302 num_whl=$(find | grep "\./adblock.*\.whl" | wc -l) 303 test $num_abi3_whl -eq $num_whl 304 test $num_whl -ge 1 305 find | grep "\./adblock-.*\.tar\.gz" 306 307 - name: PyPi publish 308 if: github.event_name == 'release' && github.event.action == 'created' 309 env: 310 TWINE_PASSWORD: ${{ secrets.PYPI }} 311 run: | 312 pip install --upgrade wheel pip setuptools twine 313 twine upload --non-interactive --skip-existing --username __token__ ./* 314 315 - name: GitHub release 316 uses: softprops/action-gh-release@v1 317 if: startsWith(github.ref, 'refs/tags/') 318 with: 319 files: ./* 320 env: 321 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 322 323 docs-publish: 324 runs-on: ubuntu-latest 325 if: github.ref == 'refs/heads/master' && github.event.action == 'push' 326 steps: 327 - uses: actions/checkout@v2 328 with: 329 submodules: true 330 fetch-depth: 0 331 332 - name: Install latest nightly 333 uses: actions-rs/toolchain@v1 334 with: 335 toolchain: nightly 336 override: true 337 338 - name: Build Github Pages 339 run: bash web/create_site.bash 340 341 - name: Deploy Github Pages 342 uses: peaceiris/actions-gh-pages@v3 343 with: 344 github_token: ${{ secrets.GITHUB_TOKEN }} 345 publish_dir: ./target/github-pages