name: CI on: release: types: [created] push: pull_request: jobs: lint: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v1 - name: Install latest nightly uses: actions-rs/toolchain@v1 with: toolchain: nightly override: true components: rustfmt, clippy - name: Lint with rustfmt uses: actions-rs/cargo@v1 with: command: fmt args: -- --check - name: Lint with clippy uses: actions-rs/cargo@v1 with: command: clippy args: --all-targets --all-features -- -D clippy::all - name: Lint with Black run: pip install black && black --check . macos: runs-on: macos-latest needs: lint steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 with: python-version: 3.6 - name: Install Rust toolchain uses: actions-rs/toolchain@v1 with: toolchain: stable target: aarch64-apple-darwin profile: minimal default: true - name: Install maturin run: pip install maturin - name: Build wheels - x86_64 run: | maturin build -i python --target x86_64-apple-darwin --release --out dist pip install adblock --no-index --find-links dist --force-reinstall - name: Build wheels - universal2 env: DEVELOPER_DIR: /Applications/Xcode.app/Contents/Developer MACOSX_DEPLOYMENT_TARGET: "10.9" PYO3_CROSS_LIB_DIR: /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib run: | # Build wheels maturin build -i python --release --universal2 --out dist --no-sdist pip install adblock --no-index --find-links dist --force-reinstall - name: Run PyTest run: | pip install pytest toml pytest -vv --color=yes - name: Check wheels with Twine run: pip install twine && twine check dist/* shell: bash - name: Upload wheels uses: actions/upload-artifact@v2 with: name: wheels path: dist windows: runs-on: windows-latest needs: lint strategy: matrix: platform: [ { python-architecture: "x64", target: "x86_64-pc-windows-msvc" }, { python-architecture: "x86", target: "i686-pc-windows-msvc" }, ] steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 with: python-version: 3.6 architecture: ${{ matrix.platform.python-architecture }} - name: Install Rust toolchain uses: actions-rs/toolchain@v1 with: toolchain: stable target: ${{ matrix.platform.target }} profile: minimal default: true - name: Install maturin run: pip install maturin - name: Build wheels run: | maturin build -i python --release --out dist --no-sdist --target ${{ matrix.platform.target }} pip install adblock --no-index --find-links dist --force-reinstall - name: Run PyTest run: | pip install pytest toml pytest -vv --color=yes - name: Check wheels with Twine run: pip install twine && twine check dist/* shell: bash - name: Upload wheels uses: actions/upload-artifact@v2 with: name: wheels path: dist linux: runs-on: ubuntu-latest needs: lint strategy: matrix: platform: [ { toolchain: "1.49", manylinux: "2010", target: "x86_64-unknown-linux-gnu", arch: "x86_64", python-version: "3.6" }, { toolchain: "nightly", manylinux: "2010", target: "x86_64-unknown-linux-gnu", arch: "x86_64", python-version: "3.6" }, { toolchain: "stable", manylinux: "2010", target: "x86_64-unknown-linux-gnu", arch: "x86_64", python-version: "3.6" }, { toolchain: "stable", manylinux: "2010", target: "x86_64-unknown-linux-gnu", arch: "x86_64", python-version: "3.10" }, ] steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 with: python-version: ${{ matrix.platform.python-version }} - name: Build Wheels run: | echo 'curl --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain ${{ matrix.platform.toolchain }} source ~/.cargo/env export PATH=/opt/python/cp38-cp38/bin:$PATH pip install maturin maturin build -i python --release --out dist --no-sdist --target ${{ matrix.platform.target }} --manylinux ${{ matrix.platform.manylinux }} ' > build-wheel.sh chmod +x build-wheel.sh docker run --rm -v "$PWD":/io -w /io quay.io/pypa/manylinux${{ matrix.platform.manylinux }}_${{ matrix.platform.arch }} bash build-wheel.sh - name: Run PyTest run: | pip install adblock --no-index --find-links dist --force-reinstall pip install pytest toml pytest -vv --color=yes - name: Auditwheel Symbols run: | pip install auditwheel-symbols auditwheel-symbols dist/*.whl - name: Check wheels with Twine run: pip install twine && twine check dist/* shell: bash - name: Upload wheels if: matrix.platform.toolchain == 'stable' uses: actions/upload-artifact@v2 with: name: wheels path: dist linux-cross: runs-on: ubuntu-latest needs: lint strategy: matrix: platform: [ { manylinux: "2014", target: "aarch64-unknown-linux-gnu", arch: "aarch64", }, { manylinux: "2014", target: "armv7-unknown-linux-gnueabihf", arch: "armv7", }, ] steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 with: python-version: 3.6 - name: Build Wheels run: | echo 'curl -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable source ~/.cargo/env rustup target add ${{ matrix.platform.target }} maturin build -i python --release --out dist --no-sdist --target ${{ matrix.platform.target }} --manylinux ${{ matrix.platform.manylinux }} ' > build-wheel.sh chmod +x build-wheel.sh docker run --rm -v "$PWD":/io -w /io messense/manylinux2014-cross:${{ matrix.platform.arch }} bash build-wheel.sh - uses: uraimo/run-on-arch-action@v2.0.5 name: Install built wheel with: arch: ${{ matrix.platform.arch }} distro: ubuntu18.04 # Mount the dist directory as /artifacts in the container dockerRunArgs: | --volume "${PWD}/dist:/artifacts" install: | apt-get update apt-get install -y --no-install-recommends python3 python3-pip pip3 install -U pip run: | ls -lrth /artifacts pip3 install adblock --no-index --find-links /artifacts --force-reinstall cd ~ && python3 -c "import adblock" - name: Auditwheel Symbols run: | pip install auditwheel-symbols auditwheel-symbols dist/*.whl - name: Check wheels with Twine run: pip install twine && twine check dist/* shell: bash - name: Upload wheels uses: actions/upload-artifact@v2 with: name: wheels path: dist python-publish: runs-on: ubuntu-latest needs: [ macos, windows, linux, linux-cross ] steps: - uses: actions/download-artifact@v2 with: name: wheels - uses: actions/setup-python@v2 with: python-version: 3.9 - name: Wheel filename sanity checks run: | num_abi3_whl=$(find | grep "\./adblock.*-abi3.*\.whl" | wc -l) num_whl=$(find | grep "\./adblock.*\.whl" | wc -l) test $num_abi3_whl -eq $num_whl test $num_whl -ge 1 find | grep "\./adblock-.*\.tar\.gz" - name: PyPi publish if: github.event_name == 'release' && github.event.action == 'created' env: TWINE_PASSWORD: ${{ secrets.PYPI }} run: | pip install --upgrade wheel pip setuptools twine twine upload --non-interactive --skip-existing --username __token__ ./* - name: GitHub release uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') with: files: ./* env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} docs-publish: runs-on: ubuntu-latest if: github.ref == 'refs/heads/master' && github.event.action == 'push' steps: - uses: actions/checkout@v2 with: submodules: true fetch-depth: 0 - name: Install latest nightly uses: actions-rs/toolchain@v1 with: toolchain: nightly override: true - name: Build Github Pages run: bash web/create_site.bash - name: Deploy Github Pages uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./target/github-pages