nix: inject pyperscan in python3Packages #243
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- v*.*.* | |
pull_request: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }} | |
cancel-in-progress: true | |
jobs: | |
checks: | |
name: Checks | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: cachix/install-nix-action@v22 | |
- uses: cachix/cachix-action@v12 | |
with: | |
name: pyperscan | |
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" | |
- name: Nix Flake checks | |
run: | | |
nix flake check \ | |
--keep-going \ | |
--print-build-logs | |
- name: Code coverage | |
run: | | |
nix build .#checks.x86_64-linux.coverage -o pytest.codecov | |
- uses: codecov/codecov-action@v3 | |
with: | |
flags: cargo-test | |
files: cargo-test.codecov | |
- uses: codecov/codecov-action@v3 | |
with: | |
flags: pytest | |
files: pytest.codecov | |
build: | |
needs: | |
- checks | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-latest | |
arch: x86_64-linux | |
drv: "shared" | |
- os: ubuntu-latest | |
arch: x86_64-linux | |
drv: "hyperscan" | |
- os: ubuntu-latest | |
arch: x86_64-linux | |
drv: "vectorscan" | |
- os: ubuntu-latest | |
arch: aarch64-linux | |
drv: "vectorscan" | |
- os: macos-11 | |
arch: x86_64-darwin | |
drv: vectorscan | |
name: Nix - ${{ matrix.arch }}.${{ matrix.drv }} | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- uses: cachix/install-nix-action@v22 | |
- uses: cachix/cachix-action@v12 | |
with: | |
name: pyperscan | |
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" | |
- name: setup emulation | |
if: ${{ matrix.arch == 'aarch64-linux' }} | |
run: | | |
sudo apt update | |
sudo apt install -q -y qemu-system-aarch64 qemu-efi binfmt-support qemu-user-static | |
mkdir -p ~/.config/nix | |
echo "system-features = aarch64-linux arm-linux" | sudo tee -a /etc/nix/nix.conf | |
- name: Build nix shell | |
run: | | |
nix build -L .#devShells.${{ matrix.arch }}.default --option system ${{ matrix.arch }} --extra-platforms ${{ matrix.arch }} | |
- name: Build nix package | |
run: nix build -L .?submodules=1#packages.${{ matrix.arch }}.default.${{ matrix.drv }} --option system ${{ matrix.arch }} --extra-platforms ${{ matrix.arch }} | |
sdist: | |
name: Build - sdist | |
needs: | |
- checks | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: PyO3/maturin-action@v1 | |
with: | |
container: off | |
command: sdist | |
args: -o dist | |
- name: Upload sdist | |
uses: actions/upload-artifact@v3 | |
with: | |
name: sdist | |
path: dist | |
linux-wheels: | |
strategy: | |
matrix: | |
include: | |
- target: x86_64-unknown-linux-gnu | |
arch: amd64 | |
- target: x86_64-unknown-linux-musl | |
arch: amd64 | |
- target: aarch64-unknown-linux-gnu | |
arch: arm64 | |
- target: aarch64-unknown-linux-musl | |
arch: arm64 | |
name: Build wheel - ${{ matrix.target }} | |
needs: | |
- checks | |
runs-on: ubuntu-latest | |
env: | |
image: ghcr.io/vlaci/pyperscan-builder-${{ matrix.target }} | |
permissions: | |
packages: write | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- name: Cache rust | |
uses: Swatinem/rust-cache@v2 | |
with: | |
key: wheel-linux-${{ matrix.target }}-${{ matrix.tag }} | |
- name: Install dependencies | |
uses: extractions/setup-crate@v1 | |
with: | |
owner: casey | |
name: just | |
version: 1.9.0 | |
- name: Log in to the GitHub Container registry | |
uses: redhat-actions/podman-login@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Check cached build image | |
run: | | |
TAG=${{hashFiles(format('Containerfile.{0}', matrix.target)) }} | |
echo tag=$TAG >> $GITHUB_ENV | |
- run: just wheel ${{ matrix.target }} | |
- run: podman push $image:$tag | |
- run: podman push $image:latest | |
if: github.ref_name == 'main' | |
- name: Upload wheels | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wheels-${{ matrix.target }} | |
path: dist | |
macos-wheel: | |
needs: | |
- checks | |
name: Build wheel - ${{ matrix.target }}-apple-darwin | |
runs-on: macos-latest | |
env: | |
MACOSX_DEPLOYMENT_TARGET: "10.9" | |
strategy: | |
matrix: | |
target: [x86_64, aarch64] | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- name: Cache rust | |
uses: Swatinem/rust-cache@v2 | |
with: | |
key: wheel-macos-${{ matrix.target }} | |
- name: Install dependencies | |
run: | | |
brew install boost ragel | |
echo container= > $GITHUB_ENV | |
- name: Disable tools | |
run: | | |
rm hyperscan-sys/*/tools/CMakeLists.txt | |
- uses: PyO3/maturin-action@v1 | |
with: | |
target: ${{ matrix.target }} | |
args: --release --out dist -F vectorscan | |
sccache: "true" | |
- name: Upload wheels | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wheels-${{ matrix.target }}-darwin | |
path: dist | |
- uses: pdm-project/setup-pdm@v3 | |
- name: Test wheels | |
if: ${{ matrix.target == 'x86_64' }} | |
run: | | |
pdm sync -d --no-self -G test | |
pdm run python -m ensurepip | |
pdm run python -m pip install dist/*.whl | |
pdm pytest | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
if: "startsWith(github.ref, 'refs/tags/')" | |
needs: | |
- sdist | |
- linux-wheels | |
- macos-wheel | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
path: dist | |
- name: Publish to PyPI | |
uses: messense/maturin-action@v1 | |
env: | |
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} | |
with: | |
command: upload | |
args: --skip-existing dist/*/* |