name: E2E tests

on:
  push:
    branches: [main]
  workflow_dispatch:

permissions: {}

jobs:
  e2e:
    runs-on: ubuntu-latest
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@v7
      - uses: actions/setup-node@v7
        with:
          node-version: '24'
      - name: Configure sandboxing
        run: |
          sudo apt-get update
          sudo apt-get install --yes bubblewrap
          sudo sysctl -w kernel.unprivileged_userns_clone=1
          if [ -f /proc/sys/kernel/apparmor_restrict_unprivileged_userns ]; then
            sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
          fi
      - name: Install dependencies
        run: npm ci
      - name: Run e2e tests
        env:
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
        run: npm run test:e2e
