|
| 1 | +name: Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main, develop ] |
| 6 | + pull_request: |
| 7 | + branches: [ main, develop ] |
| 8 | + |
| 9 | +jobs: |
| 10 | + test: |
| 11 | + name: Run Test Suite |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + steps: |
| 15 | + - name: Checkout code |
| 16 | + uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - name: Install dependencies |
| 19 | + run: | |
| 20 | + sudo apt-get install -y expect apparmor-profiles |
| 21 | +
|
| 22 | + - name: Get bubblewrap latest commit |
| 23 | + id: bwrap-commit |
| 24 | + run: | |
| 25 | + COMMIT=$(git ls-remote https://github.com/containers/bubblewrap.git HEAD | cut -f1) |
| 26 | + echo "commit=$COMMIT" >> $GITHUB_OUTPUT |
| 27 | + echo "Bubblewrap latest commit: $COMMIT" |
| 28 | +
|
| 29 | + - name: Restore bubblewrap from cache |
| 30 | + id: cache-bwrap |
| 31 | + uses: actions/cache/restore@v4 |
| 32 | + with: |
| 33 | + path: /tmp/bwrap-bin |
| 34 | + key: bwrap-${{ runner.os }}-${{ steps.bwrap-commit.outputs.commit }} |
| 35 | + |
| 36 | + - name: Install build dependencies |
| 37 | + if: steps.cache-bwrap.outputs.cache-hit != 'true' |
| 38 | + run: | |
| 39 | + sudo apt-get install -y \ |
| 40 | + meson \ |
| 41 | + ninja-build \ |
| 42 | + libcap-dev \ |
| 43 | + gcc \ |
| 44 | + pkg-config |
| 45 | +
|
| 46 | + - name: Build latest bubblewrap |
| 47 | + if: steps.cache-bwrap.outputs.cache-hit != 'true' |
| 48 | + run: | |
| 49 | + # Clone and build latest bubblewrap |
| 50 | + cd /tmp |
| 51 | + git clone https://github.com/containers/bubblewrap.git |
| 52 | + cd bubblewrap |
| 53 | + meson setup builddir --prefix=/usr |
| 54 | + meson compile -C builddir |
| 55 | +
|
| 56 | + # Prepare binary for caching |
| 57 | + mkdir -p /tmp/bwrap-bin |
| 58 | + cp builddir/bwrap /tmp/bwrap-bin/ |
| 59 | +
|
| 60 | + - name: Save bubblewrap to cache |
| 61 | + if: steps.cache-bwrap.outputs.cache-hit != 'true' |
| 62 | + uses: actions/cache/save@v4 |
| 63 | + with: |
| 64 | + path: /tmp/bwrap-bin |
| 65 | + key: bwrap-${{ runner.os }}-${{ steps.bwrap-commit.outputs.commit }} |
| 66 | + |
| 67 | + - name: Install bubblewrap |
| 68 | + run: | |
| 69 | + sudo cp /tmp/bwrap-bin/bwrap /usr/bin/bwrap |
| 70 | + sudo chmod +x /usr/bin/bwrap |
| 71 | +
|
| 72 | + # Verify version (should be 0.11.0 or later) |
| 73 | + bwrap --version |
| 74 | +
|
| 75 | + - name: Setup user namespaces for bubblewrap |
| 76 | + run: | |
| 77 | + # Configure subuid and subgid for unprivileged user namespaces |
| 78 | + USERNAME=$(whoami) |
| 79 | +
|
| 80 | + # Add subuid mapping (100000 UIDs starting from 100000) |
| 81 | + # echo "$USERNAME:100000:65536" | sudo tee -a /etc/subuid |
| 82 | +
|
| 83 | + # Add subgid mapping (100000 GIDs starting from 100000) |
| 84 | + # echo "$USERNAME:100000:65536" | sudo tee -a /etc/subgid |
| 85 | +
|
| 86 | + # Enable unprivileged user namespaces (should already be enabled on Ubuntu) |
| 87 | + # echo "kernel.unprivileged_userns_clone=1" | sudo tee -a /etc/sysctl.conf |
| 88 | + # sudo sysctl -p |
| 89 | +
|
| 90 | + # Setup AppArmor profile for bubblewrap user namespaces |
| 91 | + sudo ln -s /usr/share/apparmor/extra-profiles/bwrap-userns-restrict /etc/apparmor.d/bwrap |
| 92 | + sudo apparmor_parser /etc/apparmor.d/bwrap |
| 93 | +
|
| 94 | + # Verify setup |
| 95 | + cat /etc/subuid |
| 96 | + cat /etc/subgid |
| 97 | +
|
| 98 | + - name: Setup test environment |
| 99 | + run: | |
| 100 | + # Create isolated home for agent |
| 101 | + mkdir -p ~/aihome |
| 102 | +
|
| 103 | + # Initialize git config (required for some tests) |
| 104 | + git config --global user.email "ci@github.actions" |
| 105 | + git config --global user.name "GitHub Actions" |
| 106 | +
|
| 107 | + - name: Run merge-overlay tests |
| 108 | + run: | |
| 109 | + cd ${{ github.workspace }} |
| 110 | + ./tests/test-merge-overlay.expect |
| 111 | +
|
| 112 | + - name: Setup for agent-dev tests |
| 113 | + run: | |
| 114 | + # Ensure we're in a git repo with proper setup |
| 115 | + cd ${{ github.workspace }} |
| 116 | + git status || git init |
| 117 | +
|
| 118 | + # Create .claude directory structure if needed |
| 119 | + mkdir -p .claude |
| 120 | + touch .claude/settings.local.json || true |
| 121 | +
|
| 122 | + - name: Run agent-dev integration tests |
| 123 | + run: | |
| 124 | + cd ${{ github.workspace }} |
| 125 | + ./tests/test-agent-dev.expect |
| 126 | +
|
| 127 | + - name: Test summary |
| 128 | + if: always() |
| 129 | + run: | |
| 130 | + echo "Test execution completed" |
| 131 | + echo "Check logs above for detailed results" |
| 132 | +
|
| 133 | + lint: |
| 134 | + name: Shell Script Linting |
| 135 | + runs-on: ubuntu-latest |
| 136 | + |
| 137 | + steps: |
| 138 | + - name: Checkout code |
| 139 | + uses: actions/checkout@v4 |
| 140 | + |
| 141 | + - name: Install ShellCheck |
| 142 | + run: sudo apt-get install -y shellcheck |
| 143 | + |
| 144 | + - name: Lint shell scripts |
| 145 | + run: | |
| 146 | + echo "Linting bash scripts..." |
| 147 | + shellcheck agent-dev merge-overlay || true |
| 148 | + echo "Note: Some warnings may be acceptable for this use case" |
0 commit comments