Add CI workflow to run the test suite #8
This file contains hidden or 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
| # Runs the pytest suite (IR generation + LLC compilation). Kernel verifier | |
| # tests additionally need passwordless sudo and a kernel with BTF/BPF | |
| # enabled, which isn't guaranteed on every runner, so we probe for working | |
| # sudo first and only attempt them if it's there. | |
| name: Test | |
| on: | |
| workflow_dispatch: | |
| push: | |
| pull_request: | |
| jobs: | |
| test: | |
| name: Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: actions/setup-python@v7 | |
| with: | |
| python-version: "3.12" | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| # bpftool isn't an installable package by itself on Ubuntu: it's a | |
| # virtual package provided by linux-tools-common + a kernel-flavor | |
| # linux-tools-<flavor> package. The runner's exact kernel version | |
| # has no matching linux-tools-<version> package, so the | |
| # update-alternatives symlink for `bpftool` doesn't get set up; | |
| # find whatever binary the generic-flavor package installed and | |
| # put it on PATH ourselves. | |
| sudo apt-get install -y clang llvm libclang-dev linux-tools-common linux-tools-generic | |
| bpftool_bin=$(sudo find /usr/lib/linux-tools* -name bpftool -type f 2>/dev/null | head -1) | |
| if [ -z "$bpftool_bin" ]; then | |
| echo "::error::Could not find a bpftool binary after installing linux-tools-generic" | |
| exit 1 | |
| fi | |
| sudo ln -sf "$bpftool_bin" /usr/local/bin/bpftool | |
| bpftool version | |
| - name: Install uv | |
| run: pip install uv | |
| - name: Install project | |
| run: uv pip install --system -e ".[test]" | |
| - name: Run test suite | |
| run: make test | |
| - name: Check whether sudo is usable | |
| id: sudo-check | |
| run: | | |
| if sudo -n true 2>/dev/null; then | |
| echo "Passwordless sudo is available." | |
| echo "available=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "No passwordless sudo on this runner; kernel verifier tests will be skipped." | |
| echo "available=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Run kernel verifier tests | |
| if: steps.sudo-check.outputs.available == 'true' | |
| run: | | |
| sudo -v | |
| make test-verifier |