From 5a602830a67418cae105ecd89000b6b20e1951b7 Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Thu, 4 Sep 2025 17:36:36 +0800 Subject: [PATCH] ci(release test):restore other ci --- .github/workflows/doc.yml | 169 ++++++++++++++++++++ .github/workflows/fmt.yml | 30 ++++ .github/workflows/go.yml | 54 +++++++ .github/workflows/llgo.yml | 281 ++++++++++++++++++++++++++++++++++ .github/workflows/targets.yml | 40 +++++ 5 files changed, 574 insertions(+) create mode 100644 .github/workflows/doc.yml create mode 100644 .github/workflows/fmt.yml create mode 100644 .github/workflows/go.yml create mode 100644 .github/workflows/llgo.yml create mode 100644 .github/workflows/targets.yml diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml new file mode 100644 index 00000000..1bb57c3e --- /dev/null +++ b/.github/workflows/doc.yml @@ -0,0 +1,169 @@ +name: Docs + +on: + push: + branches: ["**"] + pull_request: + branches: ["**"] + +jobs: + doc_verify: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: "20" + + - name: Install embedme + run: npm install -g embedme + + - name: Verify README.md embedded code + run: embedme --verify README.md + + - name: Link Checker + id: lychee + uses: lycheeverse/lychee-action@v2 + with: + args: --max-concurrency 3 --retry-wait-time 15 README.md + + remote_install: + continue-on-error: true + strategy: + matrix: + os: + - macos-latest + - ubuntu-24.04 + runs-on: ${{matrix.os}} + steps: + - uses: actions/checkout@v5 + + - name: Set up Go + uses: ./.github/actions/setup-go + with: + go-version: "1.24.2" + + - name: Install dependencies on macOS + if: startsWith(matrix.os, 'macos') + run: | + set -e + set -x + source doc/_readme/scripts/install_macos.sh + + - name: Install dependencies on Ubuntu + if: startsWith(matrix.os, 'ubuntu') + run: | + set -e + set -x + source doc/_readme/scripts/install_ubuntu.sh + + - name: Test doc code blocks + run: | + set -e + set -x + source doc/_readme/scripts/run.sh + + local_install: + continue-on-error: true + strategy: + matrix: + os: + - macos-latest + - ubuntu-24.04 + runs-on: ${{matrix.os}} + steps: + - uses: actions/checkout@v5 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: "1.23" + + - name: Install dependencies on macOS + if: startsWith(matrix.os, 'macos') + run: | + set -e + set -x + source doc/_readme/scripts/install_macos.sh + + - name: Install dependencies on Ubuntu + if: startsWith(matrix.os, 'ubuntu') + run: | + set -e + set -x + source doc/_readme/scripts/install_ubuntu.sh + + - name: Install llgo with tools + run: | + set -e + set -x + git() { + if [ "$1" = "clone" ]; then + # do nothing because we already have the branch + cd .. + else + command git "$@" + fi + } + source doc/_readme/scripts/install_llgo.sh + echo "LLGO_ROOT=$GITHUB_WORKSPACE" >> $GITHUB_ENV + + - name: Test doc code blocks + run: | + set -e + set -x + source doc/_readme/scripts/run.sh + + local_install_full: + continue-on-error: true + strategy: + matrix: + os: + - macos-latest + - ubuntu-24.04 + runs-on: ${{matrix.os}} + steps: + - uses: actions/checkout@v5 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: "1.23" + + - name: Install dependencies on macOS + if: startsWith(matrix.os, 'macos') + run: | + set -e + set -x + source doc/_readme/scripts/install_macos.sh + + - name: Install dependencies on Ubuntu + if: startsWith(matrix.os, 'ubuntu') + run: | + set -e + set -x + source doc/_readme/scripts/install_ubuntu.sh + echo "PATH=/usr/lib/llvm-19/bin:$PATH" >> $GITHUB_ENV + + - name: Install llgo with tools + run: | + set -e + set -x + git() { + if [ "$1" = "clone" ]; then + # do nothing because we already have the branch + cd .. + else + command git "$@" + fi + } + source doc/_readme/scripts/install_full.sh + echo "LLGO_ROOT=$GITHUB_WORKSPACE" >> $GITHUB_ENV + + - name: Test doc code blocks + run: | + set -e + set -x + source doc/_readme/scripts/run.sh diff --git a/.github/workflows/fmt.yml b/.github/workflows/fmt.yml new file mode 100644 index 00000000..e946028f --- /dev/null +++ b/.github/workflows/fmt.yml @@ -0,0 +1,30 @@ +name: Format Check + +on: + push: + branches: ["**"] + pull_request: + branches: ["**"] + +jobs: + fmt: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + + - name: Set up Go + uses: ./.github/actions/setup-go + with: + go-version: "1.24.2" + + - name: Check formatting + run: | + for dir in . runtime; do + pushd $dir + if [ -n "$(go fmt ./... | grep -v xgo_autogen.go)" ]; then + echo "Some files are not properly formatted. Please run 'go fmt ./...'" + exit 1 + fi + popd + done + echo "All files are properly formatted." diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 00000000..17614d34 --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,54 @@ +# 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: Go + +on: + push: + branches: ["**"] + pull_request: + branches: ["**"] + +jobs: + test: + continue-on-error: true + strategy: + matrix: + os: + - macos-latest + - ubuntu-24.04 + llvm: [19] + runs-on: ${{matrix.os}} + steps: + - uses: actions/checkout@v5 + - name: Install dependencies + uses: ./.github/actions/setup-deps + with: + llvm-version: ${{matrix.llvm}} + + - name: Clang information + run: | + echo $PATH + which clang + clang --version + + - name: Set up Go + uses: ./.github/actions/setup-go + with: + go-version: "1.24.2" + + - name: Build + run: go build -v ./... + + - name: Test + if: ${{!startsWith(matrix.os, 'macos')}} + run: go test ./... + + - name: Test with coverage + if: startsWith(matrix.os, 'macos') + run: go test -coverprofile="coverage.txt" -covermode=atomic ./... + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v5 + with: + token: ${{secrets.CODECOV_TOKEN}} diff --git a/.github/workflows/llgo.yml b/.github/workflows/llgo.yml new file mode 100644 index 00000000..bd6d4f70 --- /dev/null +++ b/.github/workflows/llgo.yml @@ -0,0 +1,281 @@ +# 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: ["**"] + pull_request: + branches: ["**"] + +jobs: + download-model: + runs-on: ubuntu-latest + steps: + - name: Download model file + run: | + mkdir -p ./_demo/llama2-c + wget -P ./_demo/llama2-c https://huggingface.co/karpathy/tinyllamas/resolve/main/stories15M.bin + + - name: Upload model as artifact + uses: actions/upload-artifact@v4 + with: + name: llama2-model + path: ./_demo/llama2-c/stories15M.bin + retention-days: 1 + + llgo: + needs: download-model + continue-on-error: true + strategy: + matrix: + os: + - macos-latest + - ubuntu-24.04 + llvm: [19] + go: ["1.21.13", "1.22.12", "1.23.6", "1.24.2"] + runs-on: ${{matrix.os}} + steps: + - uses: actions/checkout@v5 + - name: Install dependencies + uses: ./.github/actions/setup-deps + with: + llvm-version: ${{matrix.llvm}} + - name: Download model artifact + uses: actions/download-artifact@v5 + with: + name: llama2-model + path: ./_demo/llama2-c/ + - name: Download platform-specific demo libs + run: | + if ${{ startsWith(matrix.os, 'macos') }}; then + DEMO_PKG="cargs_darwin_arm64.zip" + else + DEMO_PKG="cargs_linux_amd64.zip" + fi + + mkdir -p ./_demo/cargs/libs + cd ./_demo/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@v5 + 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/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: _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')}} + run: | + echo "Test lldb with llgo plugin on ${{matrix.os}} with LLVM ${{matrix.llvm}}" + bash _lldb/runtest.sh -v + + test: + continue-on-error: true + strategy: + matrix: + os: + - macos-latest + - ubuntu-24.04 + llvm: [19] + go: ["1.24.2"] + runs-on: ${{matrix.os}} + steps: + - uses: actions/checkout@v5 + - 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@v5 + with: + go-version: ${{matrix.go}} + + - name: run llgo test + run: | + llgo test ./... + + hello: + continue-on-error: true + strategy: + matrix: + os: [ubuntu-24.04, macos-latest] + llvm: [19] + go: ["1.21.13", "1.22.12", "1.23.6", "1.24.2"] + runs-on: ${{matrix.os}} + steps: + - uses: actions/checkout@v5 + - 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 + strategy: + matrix: + os: [macos-latest] + llvm: [19] + runs-on: ${{matrix.os}} + steps: + - uses: actions/checkout@v5 + - 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 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 + 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 diff --git a/.github/workflows/targets.yml b/.github/workflows/targets.yml new file mode 100644 index 00000000..c704a675 --- /dev/null +++ b/.github/workflows/targets.yml @@ -0,0 +1,40 @@ + +name: Targets + +on: + push: + branches: ["**"] + pull_request: + branches: ["**"] + +jobs: + llgo: + continue-on-error: true + strategy: + matrix: + os: + - macos-latest + - ubuntu-24.04 + llvm: [19] + runs-on: ${{matrix.os}} + steps: + - uses: actions/checkout@v5 + - name: Install dependencies + uses: ./.github/actions/setup-deps + with: + llvm-version: ${{matrix.llvm}} + + - 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: Build targets + run: | + cd _demo/targetsbuild + bash build.sh