name: CI on: release: types: [created] push: branches: - master pull_request: schedule: # Runs every Thursday at 20:23 GMT to avoid bit rot - cron: "20 23 * * 4" 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 build: runs-on: ${{ matrix.os }} needs: lint strategy: fail-fast: false matrix: rust-toolchain: [1.45, nightly] python-version: [3.6, 3.7, 3.8, 3.9] os: [ubuntu-latest, macos-latest, windows-latest] architecture: [x86, x64] exclude: # Only build 32-bit for Windows - os: macos-latest architecture: x86 - os: ubuntu-latest architecture: x86 # Only build on Rust 1.45 on Linux - os: macos-latest rust-toolchain: 1.45 - os: windows-latest rust-toolchain: 1.45 steps: - name: Checkout uses: actions/checkout@v1 - uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} architecture: ${{ matrix.architecture }} - name: Install dependencies run: | python -m pip install --upgrade pip pip install poetry twine poetry install - name: Set Rust target environment variable run: bash ci/set-target.sh ${{ matrix.os }} ${{ matrix.architecture }} shell: bash - name: Install Rust uses: actions-rs/toolchain@v1 with: toolchain: ${{ matrix.rust-toolchain }} target: ${{ env.ACTIONS_RUST_TARGET }} override: true - name: Build Python package run: poetry run maturin build --interpreter python${{matrix.python_version}} --target ${{ env.ACTIONS_RUST_TARGET }} - name: Check wheels with Twine run: twine check target/wheels/* shell: bash - name: Install Python package run: poetry run pip install target/wheels/adblock*.whl shell: bash - name: Run Python tests run: poetry run pytest -vv --color=yes python-publish: needs: build runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: python-version: [3.6, 3.7, 3.8, 3.9] os: [ubuntu-latest, macos-latest, windows-latest] architecture: [x86, x64] exclude: # Only build 32-bit for Windows - os: macos-latest architecture: x86 - os: ubuntu-latest architecture: x86 steps: - uses: actions/checkout@v1 - uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} architecture: ${{ matrix.architecture }} - name: Set Rust target environment variable run: bash ci/set-target.sh ${{ matrix.os }} ${{ matrix.architecture }} shell: bash - name: Install latest nightly uses: actions-rs/toolchain@v1 with: toolchain: nightly target: ${{ env.ACTIONS_RUST_TARGET }} override: true - name: Install dependencies run: | python -m pip install --upgrade pip pip install poetry twine poetry install - name: Build Python package run: poetry run maturin build --release --strip --interpreter python${{matrix.python_version}} --target ${{ env.ACTIONS_RUST_TARGET }} - name: List wheels if: matrix.os == 'windows-latest' run: dir target\wheels\ - name: List wheels if: matrix.os != 'windows-latest' run: find ./target/wheels/ - name: Install wheels run: pip install target/wheels/adblock*.whl shell: bash - name: Release uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') with: files: target/wheels/adblock*.whl env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: PyPi publish if: github.event_name == 'release' && github.event.action == 'created' env: TWINE_PASSWORD: ${{ secrets.PYPI }} run: twine upload --non-interactive --skip-existing --username __token__ target/wheels/* shell: bash 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