|
| 1 | +name: build |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +jobs: |
| 11 | + prebuild-agents: |
| 12 | + name: Prebuild Agents |
| 13 | + runs-on: ubuntu-24.04 |
| 14 | + steps: |
| 15 | + - name: Checkout |
| 16 | + uses: actions/checkout@v6 |
| 17 | + |
| 18 | + - name: Install Rust |
| 19 | + uses: dtolnay/rust-toolchain@stable |
| 20 | + |
| 21 | + - name: Cache Rust |
| 22 | + uses: Swatinem/rust-cache@v2 |
| 23 | + |
| 24 | + - name: Add musl targets |
| 25 | + run: rustup target add x86_64-unknown-linux-musl aarch64-unknown-linux-musl |
| 26 | + |
| 27 | + - name: Install cargo-zigbuild (pip) |
| 28 | + run: | |
| 29 | + python -m pip install --user cargo-zigbuild |
| 30 | + echo "$(python -m site --user-base)/bin" >> "$GITHUB_PATH" |
| 31 | +
|
| 32 | + - name: Build intar-agent (musl) |
| 33 | + run: | |
| 34 | + cargo zigbuild --release --target x86_64-unknown-linux-musl -p intar-agent |
| 35 | + cargo zigbuild --release --target aarch64-unknown-linux-musl -p intar-agent |
| 36 | +
|
| 37 | + - name: Stage prebuilt agents |
| 38 | + run: | |
| 39 | + mkdir -p prebuilt-agents |
| 40 | + cp target/x86_64-unknown-linux-musl/release/intar-agent prebuilt-agents/intar-agent-x86_64 |
| 41 | + cp target/aarch64-unknown-linux-musl/release/intar-agent prebuilt-agents/intar-agent-aarch64 |
| 42 | +
|
| 43 | + - name: Upload prebuilt agents |
| 44 | + uses: actions/upload-artifact@v4 |
| 45 | + with: |
| 46 | + name: intar-agent-musl |
| 47 | + path: prebuilt-agents |
| 48 | + |
| 49 | + check: |
| 50 | + name: Check - ${{ matrix.platform.os-name }} |
| 51 | + needs: prebuild-agents |
| 52 | + env: |
| 53 | + INTAR_AGENT_X86_64_PATH: ${{ github.workspace }}/prebuilt-agents/intar-agent-x86_64 |
| 54 | + INTAR_AGENT_AARCH64_PATH: ${{ github.workspace }}/prebuilt-agents/intar-agent-aarch64 |
| 55 | + strategy: |
| 56 | + fail-fast: false |
| 57 | + matrix: |
| 58 | + platform: |
| 59 | + - os-name: Linux-x86_64 |
| 60 | + runs-on: ubuntu-24.04 |
| 61 | + target: x86_64-unknown-linux-musl |
| 62 | + - os-name: Linux-aarch64 |
| 63 | + runs-on: ubuntu-24.04-arm |
| 64 | + target: aarch64-unknown-linux-musl |
| 65 | + - os-name: macOS-x86_64 |
| 66 | + runs-on: macos-15-intel |
| 67 | + target: x86_64-apple-darwin |
| 68 | + - os-name: macOS-aarch64 |
| 69 | + runs-on: macos-26 |
| 70 | + target: aarch64-apple-darwin |
| 71 | + - os-name: Windows-x86_64 |
| 72 | + runs-on: windows-2025 |
| 73 | + target: x86_64-pc-windows-msvc |
| 74 | + - os-name: Windows-aarch64 |
| 75 | + runs-on: windows-11-arm |
| 76 | + target: aarch64-pc-windows-msvc |
| 77 | + |
| 78 | + runs-on: ${{ matrix.platform.runs-on }} |
| 79 | + steps: |
| 80 | + - name: Checkout |
| 81 | + uses: actions/checkout@v6 |
| 82 | + |
| 83 | + - name: Download prebuilt agents |
| 84 | + uses: actions/download-artifact@v4 |
| 85 | + with: |
| 86 | + name: intar-agent-musl |
| 87 | + path: prebuilt-agents |
| 88 | + - name: Install Rust |
| 89 | + uses: dtolnay/rust-toolchain@stable |
| 90 | + with: |
| 91 | + components: rustfmt, clippy |
| 92 | + |
| 93 | + - name: Add musl targets |
| 94 | + run: rustup target add x86_64-unknown-linux-musl aarch64-unknown-linux-musl |
| 95 | + |
| 96 | + - name: Install just |
| 97 | + if: runner.os != 'Windows' |
| 98 | + uses: taiki-e/install-action@v2 |
| 99 | + with: |
| 100 | + tool: just |
| 101 | + |
| 102 | + - name: Install just (Windows) |
| 103 | + if: runner.os == 'Windows' |
| 104 | + shell: pwsh |
| 105 | + run: choco install just -y |
| 106 | + |
| 107 | + - name: Install cargo-nextest |
| 108 | + uses: taiki-e/install-action@v2 |
| 109 | + with: |
| 110 | + tool: cargo-nextest |
| 111 | + |
| 112 | + - name: Run just check (Unix) |
| 113 | + if: runner.os != 'Windows' |
| 114 | + run: just check |
| 115 | + |
| 116 | + - name: Run just check (Windows) |
| 117 | + if: runner.os == 'Windows' |
| 118 | + shell: pwsh |
| 119 | + run: just check |
| 120 | + |
| 121 | + cross-compile: |
| 122 | + name: Build - ${{ matrix.platform.os-name }} |
| 123 | + if: github.ref == 'refs/heads/main' |
| 124 | + needs: prebuild-agents |
| 125 | + env: |
| 126 | + INTAR_AGENT_X86_64_PATH: ${{ github.workspace }}/prebuilt-agents/intar-agent-x86_64 |
| 127 | + INTAR_AGENT_AARCH64_PATH: ${{ github.workspace }}/prebuilt-agents/intar-agent-aarch64 |
| 128 | + strategy: |
| 129 | + fail-fast: false |
| 130 | + matrix: |
| 131 | + platform: |
| 132 | + - os-name: Linux-x86_64 |
| 133 | + runs-on: ubuntu-24.04 |
| 134 | + target: x86_64-unknown-linux-musl |
| 135 | + bin: intar |
| 136 | + - os-name: Linux-aarch64 |
| 137 | + runs-on: ubuntu-24.04-arm |
| 138 | + target: aarch64-unknown-linux-musl |
| 139 | + bin: intar |
| 140 | + - os-name: macOS-x86_64 |
| 141 | + runs-on: macos-15-intel |
| 142 | + target: x86_64-apple-darwin |
| 143 | + bin: intar |
| 144 | + - os-name: macOS-aarch64 |
| 145 | + runs-on: macos-26 |
| 146 | + target: aarch64-apple-darwin |
| 147 | + bin: intar |
| 148 | + - os-name: Windows-x86_64 |
| 149 | + runs-on: windows-2025 |
| 150 | + target: x86_64-pc-windows-msvc |
| 151 | + bin: intar.exe |
| 152 | + - os-name: Windows-aarch64 |
| 153 | + runs-on: windows-11-arm |
| 154 | + target: aarch64-pc-windows-msvc |
| 155 | + bin: intar.exe |
| 156 | + |
| 157 | + runs-on: ${{ matrix.platform.runs-on }} |
| 158 | + steps: |
| 159 | + - name: Checkout |
| 160 | + uses: actions/checkout@v6 |
| 161 | + |
| 162 | + - name: Download prebuilt agents |
| 163 | + uses: actions/download-artifact@v4 |
| 164 | + with: |
| 165 | + name: intar-agent-musl |
| 166 | + path: prebuilt-agents |
| 167 | + |
| 168 | + - name: Install Rust |
| 169 | + uses: dtolnay/rust-toolchain@stable |
| 170 | + |
| 171 | + - name: Add target |
| 172 | + run: rustup target add ${{ matrix.platform.target }} |
| 173 | + |
| 174 | + - name: Build binary |
| 175 | + uses: houseabsolute/actions-rust-cross@v1 |
| 176 | + with: |
| 177 | + command: build |
| 178 | + target: ${{ matrix.platform.target }} |
| 179 | + args: "--locked --release --package intar-cli --bin intar" |
| 180 | + strip: true |
| 181 | + |
| 182 | + - name: Upload binary |
| 183 | + uses: actions/upload-artifact@v4 |
| 184 | + with: |
| 185 | + name: intar-${{ matrix.platform.os-name }} |
| 186 | + path: target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }} |
| 187 | + |
| 188 | + e2e: |
| 189 | + name: E2E - ${{ matrix.os-name }} |
| 190 | + if: github.event_name == 'pull_request' |
| 191 | + needs: prebuild-agents |
| 192 | + strategy: |
| 193 | + fail-fast: false |
| 194 | + matrix: |
| 195 | + include: |
| 196 | + - os-name: Linux |
| 197 | + runs-on: ubuntu-24.04 |
| 198 | + - os-name: macOS-Intel |
| 199 | + runs-on: macos-15-intel |
| 200 | + runs-on: ${{ matrix.runs-on }} |
| 201 | + env: |
| 202 | + RUST_BACKTRACE: "1" |
| 203 | + INTAR_AGENT_X86_64_PATH: ${{ github.workspace }}/prebuilt-agents/intar-agent-x86_64 |
| 204 | + INTAR_AGENT_AARCH64_PATH: ${{ github.workspace }}/prebuilt-agents/intar-agent-aarch64 |
| 205 | + steps: |
| 206 | + - name: Checkout |
| 207 | + uses: actions/checkout@v6 |
| 208 | + |
| 209 | + - name: Download prebuilt agents |
| 210 | + uses: actions/download-artifact@v4 |
| 211 | + with: |
| 212 | + name: intar-agent-musl |
| 213 | + path: prebuilt-agents |
| 214 | + |
| 215 | + - name: Install Rust |
| 216 | + uses: dtolnay/rust-toolchain@stable |
| 217 | + |
| 218 | + - name: Add musl targets |
| 219 | + run: rustup target add x86_64-unknown-linux-musl aarch64-unknown-linux-musl |
| 220 | + |
| 221 | + - name: Cache Rust |
| 222 | + uses: Swatinem/rust-cache@v2 |
| 223 | + |
| 224 | + - name: Install dependencies (Linux) |
| 225 | + if: runner.os == 'Linux' |
| 226 | + run: | |
| 227 | + sudo apt-get update |
| 228 | + sudo apt-get install -y qemu-system-x86 qemu-utils cloud-image-utils tmux |
| 229 | +
|
| 230 | + - name: Enable KVM group perms |
| 231 | + if: runner.os == 'Linux' |
| 232 | + run: | |
| 233 | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules |
| 234 | + sudo udevadm control --reload-rules |
| 235 | + sudo udevadm trigger --name-match=kvm |
| 236 | +
|
| 237 | + - name: Check KVM access |
| 238 | + if: runner.os == 'Linux' |
| 239 | + run: | |
| 240 | + ls -la /dev/kvm |
| 241 | + test -r /dev/kvm |
| 242 | + test -w /dev/kvm |
| 243 | +
|
| 244 | + - name: Install dependencies (macOS) |
| 245 | + if: runner.os == 'macOS' |
| 246 | + run: | |
| 247 | + brew update |
| 248 | + brew install qemu tmux |
| 249 | +
|
| 250 | + - name: Build intar |
| 251 | + run: cargo build --bin intar |
| 252 | + |
| 253 | + - name: Run e2e |
| 254 | + run: bash scripts/e2e-nginx.sh |
0 commit comments