|
| 1 | +name: ci |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + |
| 12 | +env: |
| 13 | + MCPP_VERSION: "2026.7.28.2" |
| 14 | + MCPP_RELEASE_BASE: https://github.com/mcpp-community/mcpp/releases/download |
| 15 | + |
| 16 | +jobs: |
| 17 | + unit-and-import: |
| 18 | + runs-on: ubuntu-24.04 |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + - uses: actions/setup-python@v5 |
| 22 | + with: |
| 23 | + python-version: "3.12" |
| 24 | + - name: Install pinned mcpp |
| 25 | + shell: bash |
| 26 | + run: | |
| 27 | + set -euo pipefail |
| 28 | + asset="mcpp-${MCPP_VERSION}-linux-x86_64.tar.gz" |
| 29 | + wrapper="${asset%.tar.gz}" |
| 30 | + url="${MCPP_RELEASE_BASE}/v${MCPP_VERSION}/${asset}" |
| 31 | + curl --fail --location --retry 5 --retry-all-errors \ |
| 32 | + --retry-delay 2 --output "${RUNNER_TEMP}/${asset}" "${url}" |
| 33 | + curl --fail --location --retry 5 --retry-all-errors \ |
| 34 | + --retry-delay 2 --output "${RUNNER_TEMP}/${asset}.sha256" \ |
| 35 | + "${url}.sha256" |
| 36 | + (cd "${RUNNER_TEMP}" && sha256sum -c "${asset}.sha256") |
| 37 | + tar -xzf "${RUNNER_TEMP}/${asset}" -C "${RUNNER_TEMP}" |
| 38 | + echo "${RUNNER_TEMP}/${wrapper}/bin" >> "${GITHUB_PATH}" |
| 39 | + - name: Unit and repository checks |
| 40 | + run: python3 -m unittest discover -s tests/unit -p 'test_*.py' -v |
| 41 | + - name: Verify vendored upstream and generated API |
| 42 | + env: |
| 43 | + GITHUB_TOKEN: ${{ github.token }} |
| 44 | + run: | |
| 45 | + python3 tools/import_upstream.py --lock upstream.lock --check --verify-tag |
| 46 | + python3 tools/gen_exports.py --check |
| 47 | + python3 tools/audit_snapshot.py --check snapshots/b10069.json |
| 48 | + - name: Cold CPU package build |
| 49 | + run: | |
| 50 | + rm -rf target |
| 51 | + mcpp --version | grep -F "${MCPP_VERSION}" |
| 52 | + mcpp build --strict --no-cache |
| 53 | +
|
| 54 | + cpu: |
| 55 | + name: cpu (${{ matrix.os }}) |
| 56 | + runs-on: ${{ matrix.os }} |
| 57 | + strategy: |
| 58 | + fail-fast: false |
| 59 | + matrix: |
| 60 | + include: |
| 61 | + - os: ubuntu-24.04 |
| 62 | + platform: linux-x86_64 |
| 63 | + format: tar.gz |
| 64 | + - os: windows-latest |
| 65 | + platform: windows-x86_64 |
| 66 | + format: zip |
| 67 | + - os: macos-15 |
| 68 | + platform: macosx-arm64 |
| 69 | + format: tar.gz |
| 70 | + steps: |
| 71 | + - uses: actions/checkout@v4 |
| 72 | + - uses: actions/setup-python@v5 |
| 73 | + with: |
| 74 | + python-version: "3.12" |
| 75 | + - name: Install pinned mcpp (Unix) |
| 76 | + if: runner.os != 'Windows' |
| 77 | + shell: bash |
| 78 | + run: | |
| 79 | + set -euo pipefail |
| 80 | + asset="mcpp-${MCPP_VERSION}-${{ matrix.platform }}.${{ matrix.format }}" |
| 81 | + wrapper="mcpp-${MCPP_VERSION}-${{ matrix.platform }}" |
| 82 | + url="${MCPP_RELEASE_BASE}/v${MCPP_VERSION}/${asset}" |
| 83 | + curl --fail --location --retry 5 --retry-all-errors \ |
| 84 | + --retry-delay 2 --output "${RUNNER_TEMP}/${asset}" "${url}" |
| 85 | + curl --fail --location --retry 5 --retry-all-errors \ |
| 86 | + --retry-delay 2 --output "${RUNNER_TEMP}/${asset}.sha256" \ |
| 87 | + "${url}.sha256" |
| 88 | + if [[ "${RUNNER_OS}" == "macOS" ]]; then |
| 89 | + (cd "${RUNNER_TEMP}" && shasum -a 256 -c "${asset}.sha256") |
| 90 | + else |
| 91 | + (cd "${RUNNER_TEMP}" && sha256sum -c "${asset}.sha256") |
| 92 | + fi |
| 93 | + tar -xzf "${RUNNER_TEMP}/${asset}" -C "${RUNNER_TEMP}" |
| 94 | + echo "${RUNNER_TEMP}/${wrapper}/bin" >> "${GITHUB_PATH}" |
| 95 | + - name: Install pinned mcpp (Windows) |
| 96 | + if: runner.os == 'Windows' |
| 97 | + shell: pwsh |
| 98 | + run: | |
| 99 | + $asset = "mcpp-$env:MCPP_VERSION-${{ matrix.platform }}.${{ matrix.format }}" |
| 100 | + $wrapper = "mcpp-$env:MCPP_VERSION-${{ matrix.platform }}" |
| 101 | + $url = "$env:MCPP_RELEASE_BASE/v$env:MCPP_VERSION/$asset" |
| 102 | + curl.exe --fail --location --retry 5 --retry-all-errors ` |
| 103 | + --retry-delay 2 --output "$env:RUNNER_TEMP/$asset" $url |
| 104 | + curl.exe --fail --location --retry 5 --retry-all-errors ` |
| 105 | + --retry-delay 2 --output "$env:RUNNER_TEMP/$asset.sha256" ` |
| 106 | + "$url.sha256" |
| 107 | + $expected = (Get-Content "$env:RUNNER_TEMP/$asset.sha256").Split()[0] |
| 108 | + $actual = (Get-FileHash "$env:RUNNER_TEMP/$asset" -Algorithm SHA256).Hash.ToLower() |
| 109 | + if ($actual -ne $expected) { throw "mcpp archive checksum mismatch" } |
| 110 | + Expand-Archive "$env:RUNNER_TEMP/$asset" -DestinationPath $env:RUNNER_TEMP |
| 111 | + "$env:RUNNER_TEMP/$wrapper/bin" | Out-File -FilePath $env:GITHUB_PATH -Append |
| 112 | + - name: Fetch pinned model (Unix) |
| 113 | + if: runner.os != 'Windows' |
| 114 | + shell: bash |
| 115 | + run: python3 tests/support/fetch_model.py --output "${RUNNER_TEMP}/stories15M.gguf" |
| 116 | + - name: Fetch pinned model (Windows) |
| 117 | + if: runner.os == 'Windows' |
| 118 | + shell: pwsh |
| 119 | + run: python tests/support/fetch_model.py --output "$env:RUNNER_TEMP/stories15M.gguf" |
| 120 | + - name: Run CPU inference (Unix) |
| 121 | + if: runner.os != 'Windows' |
| 122 | + shell: bash |
| 123 | + run: | |
| 124 | + set -euo pipefail |
| 125 | + rm -rf target |
| 126 | + LLAMACPP_TEST_MODEL="${RUNNER_TEMP}/stories15M.gguf" \ |
| 127 | + mcpp test cpu_decode --strict 2>&1 | tee cpu.log |
| 128 | + grep -F "LLAMACPP_CPU_TEST=PASS" cpu.log |
| 129 | + - name: Run CPU inference (Windows) |
| 130 | + if: runner.os == 'Windows' |
| 131 | + shell: pwsh |
| 132 | + run: | |
| 133 | + Remove-Item -Recurse -Force target -ErrorAction SilentlyContinue |
| 134 | + $env:LLAMACPP_TEST_MODEL = "$env:RUNNER_TEMP/stories15M.gguf" |
| 135 | + & mcpp test cpu_decode --strict 2>&1 | Tee-Object -FilePath cpu.log |
| 136 | + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } |
| 137 | + if (-not (Select-String -Quiet -SimpleMatch "LLAMACPP_CPU_TEST=PASS" cpu.log)) { |
| 138 | + throw "CPU pass marker missing" |
| 139 | + } |
| 140 | +
|
| 141 | + linux-arm64: |
| 142 | + runs-on: ubuntu-24.04-arm |
| 143 | + steps: |
| 144 | + - uses: actions/checkout@v4 |
| 145 | + - name: Native ARM64 CPU inference in Ubuntu container |
| 146 | + shell: bash |
| 147 | + run: | |
| 148 | + docker run --rm \ |
| 149 | + -e MCPP_VERSION="${MCPP_VERSION}" \ |
| 150 | + -v "${GITHUB_WORKSPACE}:/workspace" \ |
| 151 | + -w /workspace \ |
| 152 | + ubuntu:24.04 bash -euxo pipefail -c ' |
| 153 | + sed -i \ |
| 154 | + "s|http://ports.ubuntu.com/ubuntu-ports|http://mirrors.ustc.edu.cn/ubuntu-ports|g" \ |
| 155 | + /etc/apt/sources.list.d/ubuntu.sources |
| 156 | + cat /etc/apt/sources.list.d/ubuntu.sources |
| 157 | + apt-get update |
| 158 | + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ |
| 159 | + ca-certificates curl python3 file binutils |
| 160 | +
|
| 161 | + asset="mcpp-${MCPP_VERSION}-linux-aarch64.tar.gz" |
| 162 | + wrapper="${asset%.tar.gz}" |
| 163 | + url="https://github.com/mcpp-community/mcpp/releases/download/v${MCPP_VERSION}/${asset}" |
| 164 | + curl --fail --location --retry 5 --retry-all-errors \ |
| 165 | + --retry-delay 2 --output "/tmp/${asset}" "${url}" |
| 166 | + curl --fail --location --retry 5 --retry-all-errors \ |
| 167 | + --retry-delay 2 --output "/tmp/${asset}.sha256" "${url}.sha256" |
| 168 | + (cd /tmp && sha256sum -c "${asset}.sha256") |
| 169 | + mkdir -p /opt/mcpp |
| 170 | + tar -xzf "/tmp/${asset}" -C /opt/mcpp |
| 171 | + export PATH="/opt/mcpp/${wrapper}/bin:${PATH}" |
| 172 | + export MCPP_HOME=/tmp/llamacpp-mcpp-home |
| 173 | + export MCPP_VENDORED_XLINGS="/opt/mcpp/${wrapper}/registry/bin/xlings" |
| 174 | + mcpp --version | grep -F "${MCPP_VERSION}" |
| 175 | +
|
| 176 | + python3 tests/support/fetch_model.py --output /tmp/stories15M.gguf |
| 177 | + rm -rf target |
| 178 | + LLAMACPP_TEST_MODEL=/tmp/stories15M.gguf \ |
| 179 | + mcpp test cpu_decode --strict 2>&1 | tee /tmp/cpu.log |
| 180 | + grep -F "LLAMACPP_CPU_TEST=PASS" /tmp/cpu.log |
| 181 | +
|
| 182 | + helper=target/.build-mcpp/build.mcpp.bin |
| 183 | + test_bin=$(find target -type f -path "*/bin/cpu_decode" -print -quit) |
| 184 | + test -x "${helper}" |
| 185 | + test -n "${test_bin}" |
| 186 | + for binary in "${helper}" "${test_bin}"; do |
| 187 | + file "${binary}" | tee /tmp/file.log |
| 188 | + grep -F "ARM aarch64" /tmp/file.log |
| 189 | + grep -F "statically linked" /tmp/file.log |
| 190 | + if readelf -l "${binary}" | grep -q INTERP; then |
| 191 | + echo "PT_INTERP present in ${binary}" |
| 192 | + exit 1 |
| 193 | + fi |
| 194 | + echo "PT_INTERP absent in ${binary}" |
| 195 | + done |
| 196 | +
|
| 197 | + test -f compile_commands.json |
| 198 | + grep -F "/arch/arm/quants.c" compile_commands.json |
| 199 | + grep -F "/arch/arm/repack.cpp" compile_commands.json |
| 200 | + if grep -F "/arch/x86/" compile_commands.json; then |
| 201 | + echo "x86 sources selected on ARM64" |
| 202 | + exit 1 |
| 203 | + fi |
| 204 | + ' |
| 205 | +
|
| 206 | + metal: |
| 207 | + runs-on: macos-15 |
| 208 | + steps: |
| 209 | + - uses: actions/checkout@v4 |
| 210 | + - uses: actions/setup-python@v5 |
| 211 | + with: |
| 212 | + python-version: "3.12" |
| 213 | + - name: Install pinned mcpp |
| 214 | + shell: bash |
| 215 | + run: | |
| 216 | + set -euo pipefail |
| 217 | + asset="mcpp-${MCPP_VERSION}-macosx-arm64.tar.gz" |
| 218 | + wrapper="${asset%.tar.gz}" |
| 219 | + url="${MCPP_RELEASE_BASE}/v${MCPP_VERSION}/${asset}" |
| 220 | + curl --fail --location --retry 5 --retry-all-errors \ |
| 221 | + --retry-delay 2 --output "${RUNNER_TEMP}/${asset}" "${url}" |
| 222 | + curl --fail --location --retry 5 --retry-all-errors \ |
| 223 | + --retry-delay 2 --output "${RUNNER_TEMP}/${asset}.sha256" \ |
| 224 | + "${url}.sha256" |
| 225 | + (cd "${RUNNER_TEMP}" && shasum -a 256 -c "${asset}.sha256") |
| 226 | + tar -xzf "${RUNNER_TEMP}/${asset}" -C "${RUNNER_TEMP}" |
| 227 | + echo "${RUNNER_TEMP}/${wrapper}/bin" >> "${GITHUB_PATH}" |
| 228 | + - name: Run real Metal inference |
| 229 | + shell: bash |
| 230 | + run: | |
| 231 | + set -euo pipefail |
| 232 | + python3 tests/support/fetch_model.py --output "${RUNNER_TEMP}/stories15M.gguf" |
| 233 | + rm -rf target |
| 234 | + LLAMACPP_TEST_MODEL="${RUNNER_TEMP}/stories15M.gguf" \ |
| 235 | + mcpp test metal_decode --features backend-metal --strict \ |
| 236 | + 2>&1 | tee metal.log |
| 237 | + grep -F "LLAMACPP_METAL_TEST=PASS" metal.log |
| 238 | + grep -F "using embedded metal library" metal.log |
| 239 | + grep -E "offloaded [1-9][0-9]*/[1-9][0-9]* layers to GPU" metal.log |
| 240 | +
|
| 241 | + release-contract: |
| 242 | + runs-on: ubuntu-24.04 |
| 243 | + needs: [unit-and-import, cpu, linux-arm64, metal] |
| 244 | + steps: |
| 245 | + - uses: actions/checkout@v4 |
| 246 | + with: |
| 247 | + fetch-depth: 0 |
| 248 | + - uses: actions/setup-python@v5 |
| 249 | + with: |
| 250 | + python-version: "3.12" |
| 251 | + - name: Verify release mapping and reproducibility |
| 252 | + env: |
| 253 | + GITHUB_TOKEN: ${{ github.token }} |
| 254 | + run: python3 tools/check_release.py --tag v0.1.0 |
0 commit comments