|
| 1 | +name: Hardened Integration Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main, scaffold] |
| 6 | + pull_request: |
| 7 | + branches: [main, scaffold] |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + |
| 12 | +# This workflow runs: |
| 13 | +# 1. Standard tests on Linux (ubuntu-latest) across Python versions. |
| 14 | +# Full platform matrix (Windows, macOS) belongs in ci.yml. |
| 15 | +# 2. Hardened integration tests inside the Docker container. |
| 16 | +# The outer container runs as root with --privileged and AppArmor |
| 17 | +# disabled so bwrap can create namespaces and configure loopback. |
| 18 | +# Running as root is a CI-only requirement — bwrap --unshare-net |
| 19 | +# needs CAP_NET_ADMIN to set up loopback in its network namespace. |
| 20 | +# The product Dockerfile runs as non-root (csc-runner). |
| 21 | +# Network isolation is enforced and tested by bwrap --unshare-net |
| 22 | +# inside the sandbox — the primary hardened-mode boundary. |
| 23 | +# |
| 24 | +# Action versions are not yet pinned to SHA — that is a Stage 3 Step C task. |
| 25 | + |
| 26 | +jobs: |
| 27 | + standard-tests: |
| 28 | + name: Standard Tests (Linux) |
| 29 | + runs-on: ubuntu-latest |
| 30 | + strategy: |
| 31 | + matrix: |
| 32 | + python-version: ["3.11", "3.12", "3.13"] |
| 33 | + steps: |
| 34 | + - uses: actions/checkout@v4 |
| 35 | + |
| 36 | + - name: Set up Python ${{ matrix.python-version }} |
| 37 | + uses: actions/setup-python@v5 |
| 38 | + with: |
| 39 | + python-version: ${{ matrix.python-version }} |
| 40 | + |
| 41 | + - name: Install dependencies |
| 42 | + run: pip install -e ".[dev]" |
| 43 | + |
| 44 | + - name: Lint |
| 45 | + run: | |
| 46 | + ruff check . |
| 47 | + ruff format --check . |
| 48 | +
|
| 49 | + - name: Run standard tests |
| 50 | + run: python -m pytest --tb=short -q --ignore=tests/test_integration_hardened.py |
| 51 | + timeout-minutes: 5 |
| 52 | + |
| 53 | + hardened-tests: |
| 54 | + name: Hardened Integration Tests (Docker) |
| 55 | + runs-on: ubuntu-latest |
| 56 | + needs: standard-tests |
| 57 | + steps: |
| 58 | + - uses: actions/checkout@v4 |
| 59 | + |
| 60 | + - name: Build hardened image |
| 61 | + run: docker build -t csc-hardened . |
| 62 | + |
| 63 | + - name: Verify sandbox tools available |
| 64 | + run: | |
| 65 | + docker run --rm --entrypoint bwrap csc-hardened --version |
| 66 | + docker run --rm --entrypoint setpriv csc-hardened --version |
| 67 | + docker run --rm --entrypoint prlimit csc-hardened --version |
| 68 | +
|
| 69 | + - name: Run hardened integration tests |
| 70 | + run: | |
| 71 | + docker run \ |
| 72 | + --rm \ |
| 73 | + --privileged \ |
| 74 | + --security-opt apparmor=unconfined \ |
| 75 | + --user 0 \ |
| 76 | + --entrypoint python \ |
| 77 | + -v ${{ github.workspace }}:/repo:ro \ |
| 78 | + -w /app \ |
| 79 | + csc-hardened \ |
| 80 | + -m pytest /repo/tests/test_integration_hardened.py -v --tb=short |
| 81 | + timeout-minutes: 10 |
0 commit comments