Skip to content

build: report empty package matches in cmptest #3804

build: report empty package matches in cmptest

build: report empty package matches in cmptest #3804

Workflow file for this run

# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: LLGo
on:
push:
branches:
- "**"
- "!dependabot/**"
- "!xgopilot/**"
pull_request:
branches: ["**"]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
download-model:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Download model file
run: |
mkdir -p ./_demo/c/llama2-c
wget -P ./_demo/c/llama2-c https://huggingface.co/karpathy/tinyllamas/resolve/main/stories15M.bin
- name: Upload model as artifact
uses: actions/upload-artifact@v7
with:
name: llama2-model
path: ./_demo/c/llama2-c/stories15M.bin
retention-days: 1
llgo:
needs: download-model
continue-on-error: true
# macOS Intel is much slower than macOS ARM in the "Test demos" step.
# Observed: macOS ARM about 2m49s vs macOS Intel about 10m26s.
# Keep a larger budget to avoid timeout-related cancellations.
timeout-minutes: 60
strategy:
matrix:
os:
- macos-latest
- macos-15-intel
- ubuntu-latest
llvm: [19]
go: ["1.21.13", "1.24.2"]
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v6
- name: Install dependencies
uses: ./.github/actions/setup-deps
with:
llvm-version: ${{matrix.llvm}}
- name: Install embedded dependencies
uses: ./.github/actions/setup-embed-deps
- name: Download model artifact
uses: actions/download-artifact@v8
with:
name: llama2-model
path: ./_demo/c/llama2-c/
- name: Download platform-specific demo libs
run: |
if ${{ startsWith(matrix.os, 'macos') }}; then
# Use uname -m to detect actual CPU architecture
if [[ "$(uname -m)" == "x86_64" ]]; then
DEMO_PKG="cargs_darwin_amd64.zip"
else
DEMO_PKG="cargs_darwin_arm64.zip"
fi
else
DEMO_PKG="cargs_linux_amd64.zip"
fi
mkdir -p ./_demo/c/cargs/libs
cd ./_demo/c/cargs/libs
wget https://github.com/goplus/llpkg/releases/download/cargs/v1.0.0/${DEMO_PKG}
unzip ${DEMO_PKG}
# Process pc template files - replace {{.Prefix}} with actual path
ACTUAL_PREFIX="$(pwd)"
for tmpl in lib/pkgconfig/*.pc.tmpl; do
pc_file="${tmpl%.tmpl}"
sed "s|{{.Prefix}}|${ACTUAL_PREFIX}|g" "$tmpl" > "$pc_file"
done
echo "PKG_CONFIG_PATH=${ACTUAL_PREFIX}/lib/pkgconfig:${PKG_CONFIG_PATH}" >> $GITHUB_ENV
- name: Install further optional dependencies for demos
run: |
py_deps=(
numpy # for github.com/goplus/lib/py/numpy
torch # for github.com/goplus/lib/py/torch
)
pip3.12 install --break-system-packages "${py_deps[@]}"
- name: Set up Go for build
uses: ./.github/actions/setup-go
with:
go-version: "1.24.2"
- name: Install
run: |
go install ./...
echo "LLGO_ROOT=$GITHUB_WORKSPACE" >> $GITHUB_ENV
- name: Set up Go for testing
uses: actions/setup-go@v6
with:
go-version: ${{matrix.go}}
- name: Test demo without RPATH (expect failure)
run: |
echo "Testing demo without RPATH (should fail)..."
export LLGO_FULL_RPATH=false
pkg-config --libs cargs
if (cd ./_demo/c/cargs && llgo run .); then
echo "ERROR: cargs demo should have failed without RPATH!"
exit 1
else
echo "✓ cargs demo correctly failed without RPATH"
fi
- name: Test demos
run: |
# TODO(lijie): force python3-embed to be linked with python-3.12-embed
# Currently, python3-embed is python-3.13-embed, doesn't work with pytorch
# Will remove this after pytorch is fixed.
pcdir=$HOME/pc
mkdir -p $pcdir
libdir=$(pkg-config --variable=libdir python-3.12-embed)
echo "libdir: $libdir"
ln -s $libdir/pkgconfig/python-3.12-embed.pc $pcdir/python3-embed.pc
export PKG_CONFIG_PATH=$pcdir:${PKG_CONFIG_PATH}
export LLGO_FULL_RPATH=true
bash .github/workflows/test_demo.sh
- name: Test C header generation
run: |
echo "Testing C header generation in different build modes..."
cd _demo/go/export
chmod +x test.sh
./test.sh
- name: Test export with different symbol names on embedded targets
run: |
echo "Testing //export with different symbol names on embedded targets..."
cd _demo/embed/export
chmod +x verify_export.sh
./verify_export.sh
- name: Test ESP serial smoke (build + emulator)
run: |
echo "Testing ESP32/ESP32-C3 build + emulator smoke..."
cd _demo/embed
chmod +x test-esp-serial-startup.sh
./test-esp-serial-startup.sh
- name: Test ESP32-C3 startup regression
run: |
echo "Testing ESP32-C3 startup regressions..."
pip3 install --break-system-packages esptool==5.1.0
cd _demo/embed
chmod +x test_esp32c3_startup.sh
./test_esp32c3_startup.sh
- name: _xtool build tests
run: |
cd _xtool
llgo build -v ./...
- name: Show test result
run: cat result.md
- name: LLDB tests
if: ${{ startsWith(matrix.os, 'macos') && matrix.os != 'macos-15-intel' }}
run: |
echo "Test lldb with llgo plugin on ${{matrix.os}} with LLVM ${{matrix.llvm}}"
bash _lldb/runtest.sh -v
test:
continue-on-error: true
timeout-minutes: 30
strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
llvm: [19]
go: ["1.24.2"]
shard: ["0", "1", "2", "3"]
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v6
- name: Install dependencies
uses: ./.github/actions/setup-deps
with:
llvm-version: ${{matrix.llvm}}
- name: Install further optional dependencies for demos
run: |
py_deps=(
numpy # for github.com/goplus/lib/py/numpy
torch # for github.com/goplus/lib/py/torch
)
pip3.12 install --break-system-packages "${py_deps[@]}"
- name: Set up Go for build
uses: ./.github/actions/setup-go
with:
go-version: "1.24.2"
- name: Install
run: |
go install ./...
echo "LLGO_ROOT=$GITHUB_WORKSPACE" >> $GITHUB_ENV
- name: Set up Go for testing
uses: actions/setup-go@v6
with:
go-version: ${{matrix.go}}
- name: Test Baremetal GC
if: ${{!startsWith(matrix.os, 'macos') && matrix.shard == '0'}}
working-directory: runtime/internal/runtime/tinygogc
run: llgo test -timeout=20m -tags testGC .
- name: run llgo test
env:
SHARD_INDEX: ${{ matrix.shard }}
SHARD_TOTAL: "4"
run: |
set -euo pipefail
pkgs=()
while IFS= read -r pkg; do
pkgs+=("${pkg}")
done < <(go list -tags=llgo ./test/... | sort)
selected=()
for i in "${!pkgs[@]}"; do
if (( i % SHARD_TOTAL == SHARD_INDEX )); then
selected+=("${pkgs[$i]}")
fi
done
echo "Shard: ${SHARD_INDEX}/${SHARD_TOTAL}, selected: ${#selected[@]} package(s)"
if [ "${#selected[@]}" -eq 0 ]; then
echo "No packages in this shard."
exit 0
fi
printf ' %s\n' "${selected[@]}"
# Run per-package and print elapsed time to keep logs readable.
for pkg in "${selected[@]}"; do
echo "==> llgo test -timeout=20m ${pkg}"
SECONDS=0
llgo test -timeout=20m "${pkg}"
echo "==> done ${pkg} (${SECONDS}s)"
done
hello:
continue-on-error: true
timeout-minutes: 30
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
llvm: [19]
go: ["1.21.13", "1.24.2"]
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v6
- name: Install dependencies
uses: ./.github/actions/setup-deps
with:
llvm-version: ${{matrix.llvm}}
- name: Set up Go 1.23 for building llgo
uses: ./.github/actions/setup-go
with:
go-version: "1.24.2"
- name: Install llgo
run: |
go install ./...
echo "LLGO_ROOT=$GITHUB_WORKSPACE" >> $GITHUB_ENV
- name: Set up Go for testing
uses: ./.github/actions/setup-go
with:
go-version: ${{matrix.go}}
- name: Test Hello World with go.mod 1.21
if: startsWith(matrix.go, '1.21') || startsWith(matrix.go, '1.22') || startsWith(matrix.go, '1.23') || startsWith(matrix.go, '1.24')
uses: ./.github/actions/test-helloworld
with:
go-version: ${{matrix.go}}
mod-version: "1.21"
- name: Test Hello World with go.mod 1.22
if: startsWith(matrix.go, '1.22') || startsWith(matrix.go, '1.23') || startsWith(matrix.go, '1.24')
uses: ./.github/actions/test-helloworld
with:
go-version: ${{matrix.go}}
mod-version: "1.22"
- name: Test Hello World with go.mod 1.23
if: startsWith(matrix.go, '1.23') || startsWith(matrix.go, '1.24')
uses: ./.github/actions/test-helloworld
with:
go-version: ${{matrix.go}}
mod-version: "1.23"
- name: Test Hello World with go.mod 1.24
if: startsWith(matrix.go, '1.24')
uses: ./.github/actions/test-helloworld
with:
go-version: ${{matrix.go}}
mod-version: "1.24"
cross-compile:
continue-on-error: true
timeout-minutes: 30
strategy:
matrix:
os: [macos-latest]
llvm: [19]
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v6
- name: Install dependencies
uses: ./.github/actions/setup-deps
with:
llvm-version: ${{matrix.llvm}}
- name: Set up Go for building llgo
uses: ./.github/actions/setup-go
with:
go-version: "1.24.2"
- name: Install wamr
run: |
git clone --branch WAMR-2.4.4 --depth 1 https://github.com/bytecodealliance/wasm-micro-runtime.git
mkdir wasm-micro-runtime/product-mini/platforms/darwin/build
cd wasm-micro-runtime/product-mini/platforms/darwin/build
cmake -D WAMR_BUILD_EXCE_HANDLING=1 -D WAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_SHARED_MEMORY=1 -DWAMR_BUILD_LIB_WASI_THREADS=1 -DWAMR_BUILD_LIB_PTHREAD=1 -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_DEBUG_INTERP=1 ..
make -j8
echo "$PWD" >> $GITHUB_PATH
- name: Install llgo
run: |
go install ./...
echo "LLGO_ROOT=$GITHUB_WORKSPACE" >> $GITHUB_ENV
- name: Test Cross Compilation (wasm)
shell: bash
working-directory: _demo/c
run: |
echo "Testing cross-compilation wasm with Go 1.24.2"
# Compile for wasm architecture
GOOS=wasip1 GOARCH=wasm llgo build -o hello -tags=nogc -v ./helloc
# Check file type
file hello.wasm
# Run the wasm binary using llgo_wasm
iwasm --stack-size=819200000 --heap-size=800000000 hello.wasm