From 0ff2d5d931a346599865d2d7f9fca4634eccf637 Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Wed, 3 Sep 2025 14:12:23 +0800 Subject: [PATCH 01/26] ci:goreleaser file to artifacts & temp move ci for test --- .github/workflows/doc.yml | 169 ----------------- .github/workflows/fmt.yml | 30 --- .github/workflows/go.yml | 54 ------ .github/workflows/llgo.yml | 281 ---------------------------- .github/workflows/release-build.yml | 30 ++- .github/workflows/targets.yml | 40 ---- 6 files changed, 27 insertions(+), 577 deletions(-) delete mode 100644 .github/workflows/doc.yml delete mode 100644 .github/workflows/fmt.yml delete mode 100644 .github/workflows/go.yml delete mode 100644 .github/workflows/llgo.yml delete mode 100644 .github/workflows/targets.yml diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml deleted file mode 100644 index 1bb57c3e..00000000 --- a/.github/workflows/doc.yml +++ /dev/null @@ -1,169 +0,0 @@ -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 deleted file mode 100644 index e946028f..00000000 --- a/.github/workflows/fmt.yml +++ /dev/null @@ -1,30 +0,0 @@ -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 deleted file mode 100644 index 17614d34..00000000 --- a/.github/workflows/go.yml +++ /dev/null @@ -1,54 +0,0 @@ -# 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 deleted file mode 100644 index bd6d4f70..00000000 --- a/.github/workflows/llgo.yml +++ /dev/null @@ -1,281 +0,0 @@ -# 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/release-build.yml b/.github/workflows/release-build.yml index 289d8767..b086dd00 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -2,8 +2,10 @@ name: Release Build on: push: - tags: - - "*" + branches: ["**"] + tags: ["*"] + pull_request: + branches: ["**"] jobs: populate-darwin-sysroot: @@ -46,10 +48,32 @@ jobs: run: tar -xzvf .sysroot/darwin.tar.gz -C .sysroot - name: Populate Linux sysroot run: bash .github/workflows/populate_linux_sysroot.sh - - name: Run GoReleaser + - name: Run GoReleaser (Build & Test) env: GITHUB_TOKEN: ${{github.token}} run: | + docker run \ + --rm \ + -e GITHUB_TOKEN=${GITHUB_TOKEN} \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v $(pwd):/go/src/llgo \ + -w /go/src/llgo \ + ghcr.io/goreleaser/goreleaser-cross:v1.22 \ + release --skip=publish,nfpm,snapcraft --clean + + - name: Upload Build Artifacts + uses: actions/upload-artifact@v4 + with: + name: llgo-build-artifacts + path: dist + retention-days: 7 + + - name: Run GoReleaser (Release) + if: startsWith(github.ref, 'refs/tags/') + env: + GITHUB_TOKEN: ${{github.token}} + run: | + echo "Publishing release for tag: ${{ github.ref }}" docker run \ --rm \ -e GITHUB_TOKEN=${GITHUB_TOKEN} \ diff --git a/.github/workflows/targets.yml b/.github/workflows/targets.yml deleted file mode 100644 index c704a675..00000000 --- a/.github/workflows/targets.yml +++ /dev/null @@ -1,40 +0,0 @@ - -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 From 77a7d9e5490579939ade2a66367686b24d2de816 Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Wed, 3 Sep 2025 15:04:08 +0800 Subject: [PATCH 02/26] release:with --snapshot for release test --- .github/workflows/release-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index b086dd00..57e84a69 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -59,14 +59,14 @@ jobs: -v $(pwd):/go/src/llgo \ -w /go/src/llgo \ ghcr.io/goreleaser/goreleaser-cross:v1.22 \ - release --skip=publish,nfpm,snapcraft --clean + release --skip=publish,nfpm,snapcraft --snapshot --clean - name: Upload Build Artifacts uses: actions/upload-artifact@v4 with: name: llgo-build-artifacts path: dist - retention-days: 7 + retention-days: 3 - name: Run GoReleaser (Release) if: startsWith(github.ref, 'refs/tags/') From 7f05aa54c2f39daef620c3062a9c221867738283 Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Wed, 3 Sep 2025 15:35:13 +0800 Subject: [PATCH 03/26] release:upload goreleaser result to artifact & test it --- .github/workflows/release-build.yml | 125 +++++++++++++++++++++++++++- 1 file changed, 121 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 57e84a69..751c9e69 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -61,19 +61,136 @@ jobs: ghcr.io/goreleaser/goreleaser-cross:v1.22 \ release --skip=publish,nfpm,snapcraft --snapshot --clean - - name: Upload Build Artifacts + - name: Upload Darwin AMD64 Artifacts uses: actions/upload-artifact@v4 with: - name: llgo-build-artifacts - path: dist + name: llgo-darwin-amd64 + path: .dist/*darwin-amd64.tar.gz retention-days: 3 + - name: Upload Darwin ARM64 Artifacts + uses: actions/upload-artifact@v4 + with: + name: llgo-darwin-arm64 + path: .dist/*darwin-arm64.tar.gz + retention-days: 3 + + - name: Upload Linux AMD64 Artifacts + uses: actions/upload-artifact@v4 + with: + name: llgo-linux-amd64 + path: .dist/*linux-amd64.tar.gz + retention-days: 3 + + - name: Upload Linux ARM64 Artifacts + uses: actions/upload-artifact@v4 + with: + name: llgo-linux-arm64 + path: .dist/*linux-arm64.tar.gz + retention-days: 3 + + - name: Upload Checksums + uses: actions/upload-artifact@v4 + with: + name: llgo-checksums + path: .dist/checksums.txt + retention-days: 3 + + test-artifacts: + needs: build + strategy: + matrix: + include: + - os: macos-latest + goos: darwin + goarch: amd64 + - os: macos-latest + goos: darwin + goarch: arm64 + - os: ubuntu-latest + goos: linux + goarch: amd64 + - os: ubuntu-latest + goos: linux + goarch: arm64 + runs-on: ${{ matrix.os }} + steps: + - name: Download Platform Artifact + uses: actions/download-artifact@v5 + with: + name: llgo-${{ matrix.goos }}-${{ matrix.goarch }} + path: . + + - name: Extract LLGO Archive + run: | + echo "Looking for ${{ matrix.goos }}_${{ matrix.goarch }} archive..." + ls -la + + # Find the tar.gz file (should be only one) + ARCHIVE=$(ls *.tar.gz | head -n1) + if [ -z "$ARCHIVE" ]; then + echo "No archive found for platform ${{ matrix.goos }}_${{ matrix.goarch }}" + exit 1 + fi + + echo "Found archive: $ARCHIVE" + mkdir -p extracted + tar -xzf "$ARCHIVE" -C extracted + ls -la extracted/ + + - name: Test LLGO Binary + run: | + # Find the llgo binary in the extracted files + LLGO_BIN=$(find extracted/ -name "llgo" -type f | head -n1) + if [ -z "$LLGO_BIN" ]; then + echo "llgo binary not found" + exit 1 + fi + + echo "Found llgo binary: $LLGO_BIN" + chmod +x "$LLGO_BIN" + + # Test basic functionality + echo "Testing llgo version..." + "$LLGO_BIN" version + + echo "Testing llgo help..." + "$LLGO_BIN" --help + + echo "LLGO binary test passed for ${{ matrix.goos }}_${{ matrix.goarch }}" + + release: + needs: [build, test-artifacts] + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + steps: + - name: Check out code + uses: actions/checkout@v5 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: 1.24.x + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + image: tonistiigi/binfmt:qemu-v7.0.0-28 + - name: Download Darwin sysroot tarball + uses: actions/download-artifact@v5 + with: + name: darwin-sysroot-tarball + path: .sysroot + - name: Populate Darwin sysroot + run: tar -xzvf .sysroot/darwin.tar.gz -C .sysroot + - name: Populate Linux sysroot + run: bash .github/workflows/populate_linux_sysroot.sh - name: Run GoReleaser (Release) - if: startsWith(github.ref, 'refs/tags/') env: GITHUB_TOKEN: ${{github.token}} run: | echo "Publishing release for tag: ${{ github.ref }}" + echo "All artifact tests passed, proceeding with release..." docker run \ --rm \ -e GITHUB_TOKEN=${GITHUB_TOKEN} \ From d3ded9f861b166f05d50c110c08fa0edec9b212a Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Wed, 3 Sep 2025 16:03:01 +0800 Subject: [PATCH 04/26] release:cache .sysroot --- .github/workflows/release-build.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 751c9e69..5e649570 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -13,10 +13,24 @@ jobs: steps: - name: Check out code uses: actions/checkout@v5 + - name: Restore Darwin sysroot cache + id: cache-darwin-sysroot + uses: actions/cache/restore@v4 + with: + path: .sysroot/darwin.tar.gz + key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }} - name: Populate Darwin sysroot + if: steps.cache-darwin-sysroot.outputs.cache-hit != 'true' run: bash .github/workflows/populate_darwin_sysroot.sh - name: Create Darwin sysroot tarball + if: steps.cache-darwin-sysroot.outputs.cache-hit != 'true' run: tar -czvf .sysroot/darwin.tar.gz -C .sysroot darwin + - name: Save Darwin sysroot cache + if: steps.cache-darwin-sysroot.outputs.cache-hit != 'true' + uses: actions/cache/save@v4 + with: + path: .sysroot/darwin.tar.gz + key: ${{ steps.cache-darwin-sysroot.outputs.cache-primary-key }} - name: Upload Darwin sysroot tarball uses: actions/upload-artifact@v4 with: @@ -46,8 +60,21 @@ jobs: path: .sysroot - name: Populate Darwin sysroot run: tar -xzvf .sysroot/darwin.tar.gz -C .sysroot + - name: Restore Linux sysroot cache + id: cache-linux-sysroot + uses: actions/cache/restore@v4 + with: + path: .sysroot + key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }} - name: Populate Linux sysroot + if: steps.cache-linux-sysroot.outputs.cache-hit != 'true' run: bash .github/workflows/populate_linux_sysroot.sh + - name: Save Linux sysroot cache + if: steps.cache-linux-sysroot.outputs.cache-hit != 'true' + uses: actions/cache/save@v4 + with: + path: .sysroot + key: ${{ steps.cache-linux-sysroot.outputs.cache-primary-key }} - name: Run GoReleaser (Build & Test) env: GITHUB_TOKEN: ${{github.token}} From 7c792e8ca64579ea5b96b47831ad17a3d1280115 Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Wed, 3 Sep 2025 16:08:51 +0800 Subject: [PATCH 05/26] release:check artifact --- .github/workflows/release-build.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 5e649570..4445d46b 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -88,6 +88,23 @@ jobs: ghcr.io/goreleaser/goreleaser-cross:v1.22 \ release --skip=publish,nfpm,snapcraft --snapshot --clean + - name: Debug - Check Generated Files + run: | + echo "=== Listing .dist/ directory ===" + find .dist/ -name "*.tar.gz" -type f + echo "" + echo "=== Looking for darwin-amd64 files ===" + find .dist/ -name "*darwin-amd64*" -type f + echo "" + echo "=== Looking for darwin-arm64 files ===" + find .dist/ -name "*darwin-arm64*" -type f + echo "" + echo "=== Looking for linux files ===" + find .dist/ -name "*linux*" -type f + echo "" + echo "=== All files in .dist/ ===" + ls -la .dist/ + - name: Upload Darwin AMD64 Artifacts uses: actions/upload-artifact@v4 with: From 58e5f5e4a1ec8a3bcde4cd4c620b129c46d23d66 Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Wed, 3 Sep 2025 16:32:25 +0800 Subject: [PATCH 06/26] release:check upload --- .github/workflows/release-build.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 4445d46b..cb3f3c41 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -111,6 +111,7 @@ jobs: name: llgo-darwin-amd64 path: .dist/*darwin-amd64.tar.gz retention-days: 3 + include-hidden-files: true - name: Upload Darwin ARM64 Artifacts uses: actions/upload-artifact@v4 @@ -118,6 +119,7 @@ jobs: name: llgo-darwin-arm64 path: .dist/*darwin-arm64.tar.gz retention-days: 3 + include-hidden-files: true - name: Upload Linux AMD64 Artifacts uses: actions/upload-artifact@v4 @@ -125,6 +127,7 @@ jobs: name: llgo-linux-amd64 path: .dist/*linux-amd64.tar.gz retention-days: 3 + include-hidden-files: true - name: Upload Linux ARM64 Artifacts uses: actions/upload-artifact@v4 @@ -132,13 +135,15 @@ jobs: name: llgo-linux-arm64 path: .dist/*linux-arm64.tar.gz retention-days: 3 + include-hidden-files: true - name: Upload Checksums uses: actions/upload-artifact@v4 with: name: llgo-checksums - path: .dist/checksums.txt + path: .dist/*checksums.txt retention-days: 3 + include-hidden-files: true test-artifacts: needs: build From 865095214594d916a3a4b861bb4ca5af1e220ce8 Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Wed, 3 Sep 2025 16:58:01 +0800 Subject: [PATCH 07/26] ci(release test):with macos/arm macos/amd linux/arm linux/amd --- .github/workflows/release-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index cb3f3c41..2331df50 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -150,7 +150,7 @@ jobs: strategy: matrix: include: - - os: macos-latest + - os: macos-latest-large goos: darwin goarch: amd64 - os: macos-latest @@ -159,7 +159,7 @@ jobs: - os: ubuntu-latest goos: linux goarch: amd64 - - os: ubuntu-latest + - os: ubuntu-24.04-arm goos: linux goarch: arm64 runs-on: ${{ matrix.os }} From 96cd52dccc3d1379e2e2577dc1ad02faed816d18 Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Wed, 3 Sep 2025 17:16:05 +0800 Subject: [PATCH 08/26] ci(release test):use macos13 instead macos-latest-large try to resolve action bug --- .github/workflows/release-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 2331df50..736f2eab 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -150,7 +150,7 @@ jobs: strategy: matrix: include: - - os: macos-latest-large + - os: macos-13 goos: darwin goarch: amd64 - os: macos-latest From 740a260708df9e4a220e9a64627385eb32ae35ef Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Wed, 3 Sep 2025 17:26:26 +0800 Subject: [PATCH 09/26] ci(release test):with dependency --- .github/workflows/release-build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 736f2eab..f297d7e3 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -164,6 +164,9 @@ jobs: goarch: arm64 runs-on: ${{ matrix.os }} steps: + - uses: actions/checkout@v5 + - name: Install dependencies + uses: ./.github/actions/setup-deps - name: Download Platform Artifact uses: actions/download-artifact@v5 with: From 07d69295b9df6158ed510862fb8aaa02dd7143d0 Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Wed, 3 Sep 2025 18:07:50 +0800 Subject: [PATCH 10/26] ci(release test):test with hello --- .github/workflows/release-build.yml | 70 +++++++++-------------------- 1 file changed, 21 insertions(+), 49 deletions(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index f297d7e3..9f152ac7 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -88,23 +88,6 @@ jobs: ghcr.io/goreleaser/goreleaser-cross:v1.22 \ release --skip=publish,nfpm,snapcraft --snapshot --clean - - name: Debug - Check Generated Files - run: | - echo "=== Listing .dist/ directory ===" - find .dist/ -name "*.tar.gz" -type f - echo "" - echo "=== Looking for darwin-amd64 files ===" - find .dist/ -name "*darwin-amd64*" -type f - echo "" - echo "=== Looking for darwin-arm64 files ===" - find .dist/ -name "*darwin-arm64*" -type f - echo "" - echo "=== Looking for linux files ===" - find .dist/ -name "*linux*" -type f - echo "" - echo "=== All files in .dist/ ===" - ls -la .dist/ - - name: Upload Darwin AMD64 Artifacts uses: actions/upload-artifact@v4 with: @@ -153,20 +136,32 @@ jobs: - os: macos-13 goos: darwin goarch: amd64 + go-version: "1.24.2" + go-mod-version: "1.24" - os: macos-latest goos: darwin goarch: arm64 + go-version: "1.24.2" + go-mod-version: "1.24" - os: ubuntu-latest goos: linux goarch: amd64 + go-version: "1.24.2" + go-mod-version: "1.24" - os: ubuntu-24.04-arm goos: linux goarch: arm64 + go-version: "1.24.2" + go-mod-version: "1.24" runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v5 - name: Install dependencies uses: ./.github/actions/setup-deps + - name: Set up Go for building llgo + uses: ./.github/actions/setup-go + with: + go-version: "1.24.2" - name: Download Platform Artifact uses: actions/download-artifact@v5 with: @@ -176,40 +171,17 @@ jobs: - name: Extract LLGO Archive run: | echo "Looking for ${{ matrix.goos }}_${{ matrix.goarch }} archive..." - ls -la - - # Find the tar.gz file (should be only one) ARCHIVE=$(ls *.tar.gz | head -n1) - if [ -z "$ARCHIVE" ]; then - echo "No archive found for platform ${{ matrix.goos }}_${{ matrix.goarch }}" - exit 1 - fi + mkdir -p release-llgo + tar -xzf "$ARCHIVE" -C release-llgo + ls -la release-llgo/ + echo "${{ github.workspace }}/release-llgo/bin/" >> $GITHUB_PATH - echo "Found archive: $ARCHIVE" - mkdir -p extracted - tar -xzf "$ARCHIVE" -C extracted - ls -la extracted/ - - - name: Test LLGO Binary - run: | - # Find the llgo binary in the extracted files - LLGO_BIN=$(find extracted/ -name "llgo" -type f | head -n1) - if [ -z "$LLGO_BIN" ]; then - echo "llgo binary not found" - exit 1 - fi - - echo "Found llgo binary: $LLGO_BIN" - chmod +x "$LLGO_BIN" - - # Test basic functionality - echo "Testing llgo version..." - "$LLGO_BIN" version - - echo "Testing llgo help..." - "$LLGO_BIN" --help - - echo "LLGO binary test passed for ${{ matrix.goos }}_${{ matrix.goarch }}" + - name: Test Hello World with go.mod 1.21 + uses: ./.github/actions/test-helloworld + with: + go-version: ${{matrix.go-version}} + mod-version: ${{ matrix.go-mod-version }} release: needs: [build, test-artifacts] From 5e32a15146122218c77abf84fe4fa1e5bff2de58 Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Wed, 3 Sep 2025 18:21:30 +0800 Subject: [PATCH 11/26] ci(release test):set go dep --- .github/workflows/release-build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 9f152ac7..4b0f18a7 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -158,10 +158,10 @@ jobs: - uses: actions/checkout@v5 - name: Install dependencies uses: ./.github/actions/setup-deps - - name: Set up Go for building llgo - uses: ./.github/actions/setup-go + - name: Set up Go + uses: actions/setup-go@v5 with: - go-version: "1.24.2" + go-version: ${{ matrix.go-version }} - name: Download Platform Artifact uses: actions/download-artifact@v5 with: From da319e2a7cb65f62642acf59fd166438c71f1e59 Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Wed, 3 Sep 2025 19:11:30 +0800 Subject: [PATCH 12/26] ci(release test):use cache .sysroot both for test & release --- .github/workflows/release-build.yml | 82 ++++++++++++++++------------- 1 file changed, 44 insertions(+), 38 deletions(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 4b0f18a7..25fc9dfb 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -13,33 +13,46 @@ jobs: steps: - name: Check out code uses: actions/checkout@v5 - - name: Restore Darwin sysroot cache + - name: Check sysroot cache id: cache-darwin-sysroot uses: actions/cache/restore@v4 with: - path: .sysroot/darwin.tar.gz - key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }} + path: .sysroot/darwin + key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.1 + lookup-only: true - name: Populate Darwin sysroot if: steps.cache-darwin-sysroot.outputs.cache-hit != 'true' run: bash .github/workflows/populate_darwin_sysroot.sh - - name: Create Darwin sysroot tarball - if: steps.cache-darwin-sysroot.outputs.cache-hit != 'true' - run: tar -czvf .sysroot/darwin.tar.gz -C .sysroot darwin - name: Save Darwin sysroot cache if: steps.cache-darwin-sysroot.outputs.cache-hit != 'true' uses: actions/cache/save@v4 with: - path: .sysroot/darwin.tar.gz + path: .sysroot/darwin key: ${{ steps.cache-darwin-sysroot.outputs.cache-primary-key }} - - name: Upload Darwin sysroot tarball - uses: actions/upload-artifact@v4 + populate-linux-sysroot: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v5 + - name: Check sysroot cache + id: cache-linux-sysroot + uses: actions/cache/restore@v4 with: - name: darwin-sysroot-tarball - path: .sysroot/darwin.tar.gz - compression-level: 0 + path: .sysroot/linux + key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }}-0.0.1 + lookup-only: true + - name: Populate Linux sysroot + if: steps.cache-linux-sysroot.outputs.cache-hit != 'true' + run: bash .github/workflows/populate_linux_sysroot.sh + - name: Save Linux sysroot cache + uses: actions/cache/save@v4 + if: steps.cache-linux-sysroot.outputs.cache-hit != 'true' + with: + path: .sysroot/linux + key: ${{ steps.cache-linux-sysroot.outputs.cache-primary-key }} build: runs-on: ubuntu-latest - needs: populate-darwin-sysroot + needs: [populate-darwin-sysroot, populate-linux-sysroot] steps: - name: Check out code uses: actions/checkout@v5 @@ -53,28 +66,18 @@ jobs: uses: docker/setup-qemu-action@v3 with: image: tonistiigi/binfmt:qemu-v7.0.0-28 - - name: Download Darwin sysroot tarball - uses: actions/download-artifact@v5 + - name: Restore Macos sysroot cache + id: cache-macos-sysroot + uses: actions/cache/restore@v4 with: - name: darwin-sysroot-tarball - path: .sysroot - - name: Populate Darwin sysroot - run: tar -xzvf .sysroot/darwin.tar.gz -C .sysroot + path: .sysroot/darwin + key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.1 - name: Restore Linux sysroot cache id: cache-linux-sysroot uses: actions/cache/restore@v4 with: - path: .sysroot - key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }} - - name: Populate Linux sysroot - if: steps.cache-linux-sysroot.outputs.cache-hit != 'true' - run: bash .github/workflows/populate_linux_sysroot.sh - - name: Save Linux sysroot cache - if: steps.cache-linux-sysroot.outputs.cache-hit != 'true' - uses: actions/cache/save@v4 - with: - path: .sysroot - key: ${{ steps.cache-linux-sysroot.outputs.cache-primary-key }} + path: .sysroot/linux + key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }}-0.0.1 - name: Run GoReleaser (Build & Test) env: GITHUB_TOKEN: ${{github.token}} @@ -200,15 +203,18 @@ jobs: uses: docker/setup-qemu-action@v3 with: image: tonistiigi/binfmt:qemu-v7.0.0-28 - - name: Download Darwin sysroot tarball - uses: actions/download-artifact@v5 + - name: Restore Macos sysroot cache + id: cache-macos-sysroot + uses: actions/cache/restore@v4 with: - name: darwin-sysroot-tarball - path: .sysroot - - name: Populate Darwin sysroot - run: tar -xzvf .sysroot/darwin.tar.gz -C .sysroot - - name: Populate Linux sysroot - run: bash .github/workflows/populate_linux_sysroot.sh + path: .sysroot/darwin + key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.1 + - name: Restore Linux sysroot cache + id: cache-linux-sysroot + uses: actions/cache/restore@v4 + with: + path: .sysroot/linux + key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }}-0.0.1 - name: Run GoReleaser (Release) env: GITHUB_TOKEN: ${{github.token}} From 6ba182afc74cc933fd53d653f060cae5e4092ea8 Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Wed, 3 Sep 2025 19:30:07 +0800 Subject: [PATCH 13/26] ci(release test):output sysroot --- .github/workflows/release-build.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 25fc9dfb..5ce00086 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -62,10 +62,6 @@ jobs: uses: actions/setup-go@v5 with: go-version: 1.24.x - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - with: - image: tonistiigi/binfmt:qemu-v7.0.0-28 - name: Restore Macos sysroot cache id: cache-macos-sysroot uses: actions/cache/restore@v4 @@ -78,6 +74,13 @@ jobs: with: path: .sysroot/linux key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }}-0.0.1 + - name: Check .sysroot + run: | + ls -la .sysroot + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + image: tonistiigi/binfmt:qemu-v7.0.0-28 - name: Run GoReleaser (Build & Test) env: GITHUB_TOKEN: ${{github.token}} From a1f9afc88f2bc505dda5b66fa9770e74eb657309 Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Wed, 3 Sep 2025 20:00:14 +0800 Subject: [PATCH 14/26] debug --- .github/workflows/release-build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 5ce00086..cd15409e 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -77,6 +77,7 @@ jobs: - name: Check .sysroot run: | ls -la .sysroot + tree .sysroot - name: Set up QEMU uses: docker/setup-qemu-action@v3 with: From b58cce09abff86fe4432e31aa687d56a68803246 Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Wed, 3 Sep 2025 20:19:53 +0800 Subject: [PATCH 15/26] ci(release test):cache with tar -xzvf --- .github/workflows/release-build.yml | 52 ++++++++++++++++++----------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index cd15409e..1b0b2ae0 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -17,18 +17,21 @@ jobs: id: cache-darwin-sysroot uses: actions/cache/restore@v4 with: - path: .sysroot/darwin - key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.1 + path: .sysroot/darwin.tar.gz + key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.2 lookup-only: true - name: Populate Darwin sysroot if: steps.cache-darwin-sysroot.outputs.cache-hit != 'true' - run: bash .github/workflows/populate_darwin_sysroot.sh + run: | + bash .github/workflows/populate_darwin_sysroot.sh + tar -czvf .sysroot/darwin.tar.gz -C .sysroot darwin - name: Save Darwin sysroot cache if: steps.cache-darwin-sysroot.outputs.cache-hit != 'true' uses: actions/cache/save@v4 with: - path: .sysroot/darwin + path: .sysroot/darwin.tar.gz key: ${{ steps.cache-darwin-sysroot.outputs.cache-primary-key }} + populate-linux-sysroot: runs-on: ubuntu-latest steps: @@ -38,18 +41,21 @@ jobs: id: cache-linux-sysroot uses: actions/cache/restore@v4 with: - path: .sysroot/linux - key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }}-0.0.1 + path: .sysroot/linux.tar.gz + key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }}-0.0.2 lookup-only: true - name: Populate Linux sysroot if: steps.cache-linux-sysroot.outputs.cache-hit != 'true' - run: bash .github/workflows/populate_linux_sysroot.sh + run: | + bash .github/workflows/populate_linux_sysroot.sh + tar -czvf .sysroot/linux.tar.gz -C .sysroot linux - name: Save Linux sysroot cache - uses: actions/cache/save@v4 if: steps.cache-linux-sysroot.outputs.cache-hit != 'true' + uses: actions/cache/save@v4 with: - path: .sysroot/linux + path: .sysroot/linux.tar.gz key: ${{ steps.cache-linux-sysroot.outputs.cache-primary-key }} + build: runs-on: ubuntu-latest needs: [populate-darwin-sysroot, populate-linux-sysroot] @@ -66,16 +72,19 @@ jobs: id: cache-macos-sysroot uses: actions/cache/restore@v4 with: - path: .sysroot/darwin - key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.1 + path: .sysroot/darwin.tar.gz + key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.2 - name: Restore Linux sysroot cache id: cache-linux-sysroot uses: actions/cache/restore@v4 with: - path: .sysroot/linux - key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }}-0.0.1 - - name: Check .sysroot + path: .sysroot/linux.tar.gz + key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }}-0.0.2 + - name: Extract sysroots run: | + mkdir -p .sysroot + if [ -f .sysroot/darwin.tar.gz ]; then tar -xzvf .sysroot/darwin.tar.gz -C .sysroot; fi + if [ -f .sysroot/linux.tar.gz ]; then tar -xzvf .sysroot/linux.tar.gz -C .sysroot; fi ls -la .sysroot tree .sysroot - name: Set up QEMU @@ -180,7 +189,7 @@ jobs: echo "Looking for ${{ matrix.goos }}_${{ matrix.goarch }} archive..." ARCHIVE=$(ls *.tar.gz | head -n1) mkdir -p release-llgo - tar -xzf "$ARCHIVE" -C release-llgo + tar -xzvf "$ARCHIVE" -C release-llgo ls -la release-llgo/ echo "${{ github.workspace }}/release-llgo/bin/" >> $GITHUB_PATH @@ -211,14 +220,19 @@ jobs: id: cache-macos-sysroot uses: actions/cache/restore@v4 with: - path: .sysroot/darwin - key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.1 + path: .sysroot/darwin.tar.gz + key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.2 - name: Restore Linux sysroot cache id: cache-linux-sysroot uses: actions/cache/restore@v4 with: - path: .sysroot/linux - key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }}-0.0.1 + path: .sysroot/linux.tar.gz + key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }}-0.0.2 + - name: Extract sysroots + run: | + mkdir -p .sysroot + if [ -f .sysroot/darwin.tar.gz ]; then tar -xzvf .sysroot/darwin.tar.gz -C .sysroot; fi + if [ -f .sysroot/linux.tar.gz ]; then tar -xzvf .sysroot/linux.tar.gz -C .sysroot; fi - name: Run GoReleaser (Release) env: GITHUB_TOKEN: ${{github.token}} From b8b0ae00d02470de59408d6cdbf9dc5c126128c6 Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Wed, 3 Sep 2025 20:48:16 +0800 Subject: [PATCH 16/26] ci(release test):revert to cache linux --- .github/workflows/release-build.yml | 60 ++++++----------------------- 1 file changed, 11 insertions(+), 49 deletions(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 1b0b2ae0..175bfd4c 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -18,7 +18,7 @@ jobs: uses: actions/cache/restore@v4 with: path: .sysroot/darwin.tar.gz - key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.2 + key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.3 lookup-only: true - name: Populate Darwin sysroot if: steps.cache-darwin-sysroot.outputs.cache-hit != 'true' @@ -31,34 +31,9 @@ jobs: with: path: .sysroot/darwin.tar.gz key: ${{ steps.cache-darwin-sysroot.outputs.cache-primary-key }} - - populate-linux-sysroot: - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@v5 - - name: Check sysroot cache - id: cache-linux-sysroot - uses: actions/cache/restore@v4 - with: - path: .sysroot/linux.tar.gz - key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }}-0.0.2 - lookup-only: true - - name: Populate Linux sysroot - if: steps.cache-linux-sysroot.outputs.cache-hit != 'true' - run: | - bash .github/workflows/populate_linux_sysroot.sh - tar -czvf .sysroot/linux.tar.gz -C .sysroot linux - - name: Save Linux sysroot cache - if: steps.cache-linux-sysroot.outputs.cache-hit != 'true' - uses: actions/cache/save@v4 - with: - path: .sysroot/linux.tar.gz - key: ${{ steps.cache-linux-sysroot.outputs.cache-primary-key }} - build: runs-on: ubuntu-latest - needs: [populate-darwin-sysroot, populate-linux-sysroot] + needs: [populate-darwin-sysroot] steps: - name: Check out code uses: actions/checkout@v5 @@ -73,19 +48,13 @@ jobs: uses: actions/cache/restore@v4 with: path: .sysroot/darwin.tar.gz - key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.2 - - name: Restore Linux sysroot cache - id: cache-linux-sysroot - uses: actions/cache/restore@v4 - with: - path: .sysroot/linux.tar.gz - key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }}-0.0.2 + key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.3 - name: Extract sysroots run: | - mkdir -p .sysroot - if [ -f .sysroot/darwin.tar.gz ]; then tar -xzvf .sysroot/darwin.tar.gz -C .sysroot; fi - if [ -f .sysroot/linux.tar.gz ]; then tar -xzvf .sysroot/linux.tar.gz -C .sysroot; fi - ls -la .sysroot + tar -xzvf .sysroot/darwin.tar.gz -C .sysroot + - name: Populate Linux sysroot + run: | + bash .github/workflows/populate_linux_sysroot.sh tree .sysroot - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -221,18 +190,11 @@ jobs: uses: actions/cache/restore@v4 with: path: .sysroot/darwin.tar.gz - key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.2 - - name: Restore Linux sysroot cache - id: cache-linux-sysroot - uses: actions/cache/restore@v4 - with: - path: .sysroot/linux.tar.gz - key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }}-0.0.2 + key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.3 - name: Extract sysroots - run: | - mkdir -p .sysroot - if [ -f .sysroot/darwin.tar.gz ]; then tar -xzvf .sysroot/darwin.tar.gz -C .sysroot; fi - if [ -f .sysroot/linux.tar.gz ]; then tar -xzvf .sysroot/linux.tar.gz -C .sysroot; fi + run: tar -xzvf .sysroot/darwin.tar.gz -C .sysroot + - name: Populate Linux sysroot + run: bash .github/workflows/populate_linux_sysroot.sh - name: Run GoReleaser (Release) env: GITHUB_TOKEN: ${{github.token}} From 23b5e77dccf6542f837e4374f75b6bb451e07486 Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Wed, 3 Sep 2025 21:10:25 +0800 Subject: [PATCH 17/26] ci(release test):test cache macos tarball --- .github/workflows/release-build.yml | 92 ++++++++++++++++++----------- 1 file changed, 58 insertions(+), 34 deletions(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 175bfd4c..24d62d41 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -13,27 +13,35 @@ jobs: steps: - name: Check out code uses: actions/checkout@v5 - - name: Check sysroot cache - id: cache-darwin-sysroot - uses: actions/cache/restore@v4 - with: - path: .sysroot/darwin.tar.gz - key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.3 - lookup-only: true + # - name: Restore Darwin sysroot cache + # id: cache-darwin-sysroot + # uses: actions/cache/restore@v4 + # with: + # path: .sysroot/darwin.tar.gz + # key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }} + # - name: Populate Darwin sysroot + # if: steps.cache-darwin-sysroot.outputs.cache-hit != 'true' + # run: bash .github/workflows/populate_darwin_sysroot.sh - name: Populate Darwin sysroot - if: steps.cache-darwin-sysroot.outputs.cache-hit != 'true' - run: | - bash .github/workflows/populate_darwin_sysroot.sh - tar -czvf .sysroot/darwin.tar.gz -C .sysroot darwin + run: bash .github/workflows/populate_darwin_sysroot.sh + - name: Create Darwin sysroot tarball + # if: steps.cache-darwin-sysroot.outputs.cache-hit != 'true' + run: tar -czvf .sysroot/darwin.tar.gz -C .sysroot darwin - name: Save Darwin sysroot cache - if: steps.cache-darwin-sysroot.outputs.cache-hit != 'true' + # if: steps.cache-darwin-sysroot.outputs.cache-hit != 'true' uses: actions/cache/save@v4 with: path: .sysroot/darwin.tar.gz - key: ${{ steps.cache-darwin-sysroot.outputs.cache-primary-key }} + key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.5 + # - name: Upload Darwin sysroot tarball + # uses: actions/upload-artifact@v4 + # with: + # name: darwin-sysroot-tarball + # path: .sysroot/darwin.tar.gz + # compression-level: 0 build: runs-on: ubuntu-latest - needs: [populate-darwin-sysroot] + needs: populate-darwin-sysroot steps: - name: Check out code uses: actions/checkout@v5 @@ -43,23 +51,40 @@ jobs: uses: actions/setup-go@v5 with: go-version: 1.24.x - - name: Restore Macos sysroot cache - id: cache-macos-sysroot - uses: actions/cache/restore@v4 - with: - path: .sysroot/darwin.tar.gz - key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.3 - - name: Extract sysroots - run: | - tar -xzvf .sysroot/darwin.tar.gz -C .sysroot - - name: Populate Linux sysroot - run: | - bash .github/workflows/populate_linux_sysroot.sh - tree .sysroot - name: Set up QEMU uses: docker/setup-qemu-action@v3 with: image: tonistiigi/binfmt:qemu-v7.0.0-28 + # - name: Download Darwin sysroot tarball + # uses: actions/download-artifact@v5 + # with: + # name: darwin-sysroot-tarball + # path: .sysroot + - name: Restore Darwin sysroot cache + id: cache-darwin-sysroot + uses: actions/cache/restore@v4 + with: + path: .sysroot/darwin.tar.gz + key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.5 + - name: Populate Darwin sysroot + run: tar -xzvf .sysroot/darwin.tar.gz -C .sysroot + - name: Populate Linux sysroot + run: bash .github/workflows/populate_linux_sysroot.sh + # - name: Restore Linux sysroot cache + # id: cache-linux-sysroot + # uses: actions/cache/restore@v4 + # with: + # path: .sysroot + # key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }} + + # - name: Save Linux sysroot cache + # if: steps.cache-linux-sysroot.outputs.cache-hit != 'true' + # uses: actions/cache/save@v4 + # with: + # path: .sysroot + # key: ${{ steps.cache-linux-sysroot.outputs.cache-primary-key }} + - name: Check file + run: tree .sysroot - name: Run GoReleaser (Build & Test) env: GITHUB_TOKEN: ${{github.token}} @@ -158,7 +183,7 @@ jobs: echo "Looking for ${{ matrix.goos }}_${{ matrix.goarch }} archive..." ARCHIVE=$(ls *.tar.gz | head -n1) mkdir -p release-llgo - tar -xzvf "$ARCHIVE" -C release-llgo + tar -xzf "$ARCHIVE" -C release-llgo ls -la release-llgo/ echo "${{ github.workspace }}/release-llgo/bin/" >> $GITHUB_PATH @@ -185,13 +210,12 @@ jobs: uses: docker/setup-qemu-action@v3 with: image: tonistiigi/binfmt:qemu-v7.0.0-28 - - name: Restore Macos sysroot cache - id: cache-macos-sysroot - uses: actions/cache/restore@v4 + - name: Download Darwin sysroot tarball + uses: actions/download-artifact@v5 with: - path: .sysroot/darwin.tar.gz - key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.3 - - name: Extract sysroots + name: darwin-sysroot-tarball + path: .sysroot + - name: Populate Darwin sysroot run: tar -xzvf .sysroot/darwin.tar.gz -C .sysroot - name: Populate Linux sysroot run: bash .github/workflows/populate_linux_sysroot.sh From 002a68009e99d907674a0ee14598f20d30df6486 Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Wed, 3 Sep 2025 22:14:33 +0800 Subject: [PATCH 18/26] ci(release test):cache macos --- .github/workflows/release-build.yml | 42 ++++++----------------------- 1 file changed, 8 insertions(+), 34 deletions(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 24d62d41..72a77ace 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -13,19 +13,17 @@ jobs: steps: - name: Check out code uses: actions/checkout@v5 - # - name: Restore Darwin sysroot cache - # id: cache-darwin-sysroot - # uses: actions/cache/restore@v4 - # with: - # path: .sysroot/darwin.tar.gz - # key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }} - # - name: Populate Darwin sysroot - # if: steps.cache-darwin-sysroot.outputs.cache-hit != 'true' - # run: bash .github/workflows/populate_darwin_sysroot.sh + - name: Restore Darwin sysroot cache + id: cache-darwin-sysroot + uses: actions/cache/restore@v4 + with: + path: .sysroot/darwin.tar.gz + key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.5 - name: Populate Darwin sysroot + if: steps.cache-darwin-sysroot.outputs.cache-hit != 'true' run: bash .github/workflows/populate_darwin_sysroot.sh - name: Create Darwin sysroot tarball - # if: steps.cache-darwin-sysroot.outputs.cache-hit != 'true' + if: steps.cache-darwin-sysroot.outputs.cache-hit != 'true' run: tar -czvf .sysroot/darwin.tar.gz -C .sysroot darwin - name: Save Darwin sysroot cache # if: steps.cache-darwin-sysroot.outputs.cache-hit != 'true' @@ -33,12 +31,6 @@ jobs: with: path: .sysroot/darwin.tar.gz key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.5 - # - name: Upload Darwin sysroot tarball - # uses: actions/upload-artifact@v4 - # with: - # name: darwin-sysroot-tarball - # path: .sysroot/darwin.tar.gz - # compression-level: 0 build: runs-on: ubuntu-latest needs: populate-darwin-sysroot @@ -55,11 +47,6 @@ jobs: uses: docker/setup-qemu-action@v3 with: image: tonistiigi/binfmt:qemu-v7.0.0-28 - # - name: Download Darwin sysroot tarball - # uses: actions/download-artifact@v5 - # with: - # name: darwin-sysroot-tarball - # path: .sysroot - name: Restore Darwin sysroot cache id: cache-darwin-sysroot uses: actions/cache/restore@v4 @@ -70,19 +57,6 @@ jobs: run: tar -xzvf .sysroot/darwin.tar.gz -C .sysroot - name: Populate Linux sysroot run: bash .github/workflows/populate_linux_sysroot.sh - # - name: Restore Linux sysroot cache - # id: cache-linux-sysroot - # uses: actions/cache/restore@v4 - # with: - # path: .sysroot - # key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }} - - # - name: Save Linux sysroot cache - # if: steps.cache-linux-sysroot.outputs.cache-hit != 'true' - # uses: actions/cache/save@v4 - # with: - # path: .sysroot - # key: ${{ steps.cache-linux-sysroot.outputs.cache-primary-key }} - name: Check file run: tree .sysroot - name: Run GoReleaser (Build & Test) From bedb45442715e54979a6885a1d9301499add776f Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Wed, 3 Sep 2025 22:46:38 +0800 Subject: [PATCH 19/26] ci(release test):cache linux & check file --- .github/workflows/release-build.yml | 53 +++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 72a77ace..e65f36f3 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -31,9 +31,52 @@ jobs: with: path: .sysroot/darwin.tar.gz key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.5 + populate-linux-sysroot: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v5 + - name: Restore Linux sysroot cache + id: cache-linux-sysroot + uses: actions/cache/restore@v4 + with: + path: .sysroot/linux.tar.gz + key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }}-0.0.7 + - name: Populate Linux sysroot + if: steps.cache-linux-sysroot.outputs.cache-hit != 'true' + run: bash .github/workflows/populate_linux_sysroot.sh + - name: Create Linux sysroot tarball + if: steps.cache-linux-sysroot.outputs.cache-hit != 'true' + run: tar -czvf .sysroot/linux.tar.gz -C .sysroot linux + - name: Verify Linux sysroot contents + if: steps.cache-linux-sysroot.outputs.cache-hit != 'true' + run: | + echo "验证 AMD64 sysroot..." + if [ ! -d ".sysroot/linux/amd64/usr/include/llvm-19" ]; then + echo "错误:AMD64 sysroot 缺少 LLVM 头文件" + exit 1 + fi + + echo "验证 ARM64 sysroot..." + if [ ! -d ".sysroot/linux/arm64/usr/include/llvm-19" ]; then + echo "错误:ARM64 sysroot 缺少 LLVM 头文件" + exit 1 + fi + + echo "检查关键文件..." + ls -la .sysroot/linux/amd64/usr/include/llvm-c/Core.h || echo "AMD64 Core.h 缺失" + ls -la .sysroot/linux/arm64/usr/include/llvm-c/Core.h || echo "ARM64 Core.h 缺失" + + echo "sysroot 验证通过!" + - name: Save Linux sysroot cache + if: steps.cache-linux-sysroot.outputs.cache-hit != 'true' + uses: actions/cache/save@v4 + with: + path: .sysroot/linux.tar.gz + key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }}-0.0.7 build: runs-on: ubuntu-latest - needs: populate-darwin-sysroot + needs: [populate-darwin-sysroot, populate-linux-sysroot] steps: - name: Check out code uses: actions/checkout@v5 @@ -53,10 +96,16 @@ jobs: with: path: .sysroot/darwin.tar.gz key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.5 + - name: Restore Linux sysroot cache + id: cache-linux-sysroot + uses: actions/cache/restore@v4 + with: + path: .sysroot/linux.tar.gz + key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }}-0.0.7 - name: Populate Darwin sysroot run: tar -xzvf .sysroot/darwin.tar.gz -C .sysroot - name: Populate Linux sysroot - run: bash .github/workflows/populate_linux_sysroot.sh + run: tar -xzvf .sysroot/linux.tar.gz -C .sysroot - name: Check file run: tree .sysroot - name: Run GoReleaser (Build & Test) From 825f0bd83f39e7658cf6af645fe1b53090915938 Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Thu, 4 Sep 2025 11:12:55 +0800 Subject: [PATCH 20/26] ci(release test):cache linux & set qemu --- .github/workflows/release-build.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index e65f36f3..01c7c0be 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -42,6 +42,11 @@ jobs: with: path: .sysroot/linux.tar.gz key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }}-0.0.7 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + if: steps.cache-linux-sysroot.outputs.cache-hit != 'true' + with: + image: tonistiigi/binfmt:qemu-v7.0.0-28 - name: Populate Linux sysroot if: steps.cache-linux-sysroot.outputs.cache-hit != 'true' run: bash .github/workflows/populate_linux_sysroot.sh From 9d7664373ee7657bfc4c0f69f29c107f3189ad72 Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Thu, 4 Sep 2025 14:32:05 +0800 Subject: [PATCH 21/26] ci(release test):setup releaser --- .github/actions/setup-goreleaser/action.yml | 30 +++++++++ .github/workflows/release-build.yml | 69 ++------------------- 2 files changed, 34 insertions(+), 65 deletions(-) create mode 100644 .github/actions/setup-goreleaser/action.yml diff --git a/.github/actions/setup-goreleaser/action.yml b/.github/actions/setup-goreleaser/action.yml new file mode 100644 index 00000000..1748c12e --- /dev/null +++ b/.github/actions/setup-goreleaser/action.yml @@ -0,0 +1,30 @@ +name: "Setup GoReleaser" +description: "Setup GoReleaser environment" +runs: + using: "composite" + steps: + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: 1.24.x + - name: Restore Darwin sysroot cache + id: cache-darwin-sysroot + uses: actions/cache/restore@v4 + with: + path: .sysroot/darwin.tar.gz + key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.5 + - name: Restore Linux sysroot cache + id: cache-linux-sysroot + uses: actions/cache/restore@v4 + with: + path: .sysroot/linux.tar.gz + key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }}-0.0.7 + - name: Populate Darwin sysroot + run: tar -xzvf .sysroot/darwin.tar.gz -C .sysroot + shell: bash + - name: Populate Linux sysroot + run: tar -xzvf .sysroot/linux.tar.gz -C .sysroot + shell: bash + - name: Check file + run: tree .sysroot + shell: bash diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 01c7c0be..c9a6603c 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -53,26 +53,6 @@ jobs: - name: Create Linux sysroot tarball if: steps.cache-linux-sysroot.outputs.cache-hit != 'true' run: tar -czvf .sysroot/linux.tar.gz -C .sysroot linux - - name: Verify Linux sysroot contents - if: steps.cache-linux-sysroot.outputs.cache-hit != 'true' - run: | - echo "验证 AMD64 sysroot..." - if [ ! -d ".sysroot/linux/amd64/usr/include/llvm-19" ]; then - echo "错误:AMD64 sysroot 缺少 LLVM 头文件" - exit 1 - fi - - echo "验证 ARM64 sysroot..." - if [ ! -d ".sysroot/linux/arm64/usr/include/llvm-19" ]; then - echo "错误:ARM64 sysroot 缺少 LLVM 头文件" - exit 1 - fi - - echo "检查关键文件..." - ls -la .sysroot/linux/amd64/usr/include/llvm-c/Core.h || echo "AMD64 Core.h 缺失" - ls -la .sysroot/linux/arm64/usr/include/llvm-c/Core.h || echo "ARM64 Core.h 缺失" - - echo "sysroot 验证通过!" - name: Save Linux sysroot cache if: steps.cache-linux-sysroot.outputs.cache-hit != 'true' uses: actions/cache/save@v4 @@ -85,34 +65,8 @@ jobs: steps: - name: Check out code uses: actions/checkout@v5 - with: - fetch-depth: 0 - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: 1.24.x - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - with: - image: tonistiigi/binfmt:qemu-v7.0.0-28 - - name: Restore Darwin sysroot cache - id: cache-darwin-sysroot - uses: actions/cache/restore@v4 - with: - path: .sysroot/darwin.tar.gz - key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.5 - - name: Restore Linux sysroot cache - id: cache-linux-sysroot - uses: actions/cache/restore@v4 - with: - path: .sysroot/linux.tar.gz - key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }}-0.0.7 - - name: Populate Darwin sysroot - run: tar -xzvf .sysroot/darwin.tar.gz -C .sysroot - - name: Populate Linux sysroot - run: tar -xzvf .sysroot/linux.tar.gz -C .sysroot - - name: Check file - run: tree .sysroot + - name: Set up Release + uses: ./.github/actions/setup-goreleaser - name: Run GoReleaser (Build & Test) env: GITHUB_TOKEN: ${{github.token}} @@ -230,23 +184,8 @@ jobs: uses: actions/checkout@v5 with: fetch-depth: 0 - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: 1.24.x - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - with: - image: tonistiigi/binfmt:qemu-v7.0.0-28 - - name: Download Darwin sysroot tarball - uses: actions/download-artifact@v5 - with: - name: darwin-sysroot-tarball - path: .sysroot - - name: Populate Darwin sysroot - run: tar -xzvf .sysroot/darwin.tar.gz -C .sysroot - - name: Populate Linux sysroot - run: bash .github/workflows/populate_linux_sysroot.sh + - name: Set up Release + uses: ./.github/actions/setup-goreleaser - name: Run GoReleaser (Release) env: GITHUB_TOKEN: ${{github.token}} From e5c86fe93618e2e8aaa5018a8ba89fb4e0267585 Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Thu, 4 Sep 2025 14:37:09 +0800 Subject: [PATCH 22/26] ci(release test):lookup cache --- .github/workflows/release-build.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index c9a6603c..9e320358 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -13,12 +13,13 @@ jobs: steps: - name: Check out code uses: actions/checkout@v5 - - name: Restore Darwin sysroot cache + - name: Check Darwin sysroot cache id: cache-darwin-sysroot uses: actions/cache/restore@v4 with: path: .sysroot/darwin.tar.gz key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.5 + lookup-only: true - name: Populate Darwin sysroot if: steps.cache-darwin-sysroot.outputs.cache-hit != 'true' run: bash .github/workflows/populate_darwin_sysroot.sh @@ -36,12 +37,13 @@ jobs: steps: - name: Check out code uses: actions/checkout@v5 - - name: Restore Linux sysroot cache + - name: Check Linux sysroot cache id: cache-linux-sysroot uses: actions/cache/restore@v4 with: path: .sysroot/linux.tar.gz key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }}-0.0.7 + lookup-only: true - name: Set up QEMU uses: docker/setup-qemu-action@v3 if: steps.cache-linux-sysroot.outputs.cache-hit != 'true' From 40b142f947b135920020f5a879342614bee5628d Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Thu, 4 Sep 2025 15:24:39 +0800 Subject: [PATCH 23/26] ci(release test):hello check cpp & todo build --- .github/actions/test-helloworld/action.yml | 28 ++++++++++++++++++---- .github/workflows/release-build.yml | 4 ++-- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/.github/actions/test-helloworld/action.yml b/.github/actions/test-helloworld/action.yml index 76b92a70..9ce49ef9 100644 --- a/.github/actions/test-helloworld/action.yml +++ b/.github/actions/test-helloworld/action.yml @@ -1,11 +1,11 @@ -name: 'Test Hello World' -description: 'Test Hello World with specific Go and module versions' +name: "Test Hello World" +description: "Test Hello World with specific Go and module versions" inputs: go-version: - description: 'Go version being tested' + description: "Go version being tested" required: true mod-version: - description: 'Go module version to use' + description: "Go module version to use" required: true runs: using: "composite" @@ -24,12 +24,30 @@ runs: import ( "fmt" "github.com/goplus/lib/c" + "github.com/goplus/lib/cpp/std" ) func main() { fmt.Println("Hello, LLGo!") println("Hello, LLGo!") c.Printf(c.Str("Hello, LLGo!\n")) + c.Printf(std.Str("Hello LLGo by cpp/std.Str\n").CStr()) } EOL go mod tidy - llgo run . + EXPECTED="Hello, LLGo! + Hello, LLGo! + Hello, LLGo! + Hello LLGo by cpp/std.Str" + OUTPUT=$(llgo run . 2>&1) + if echo "$OUTPUT" | grep -qF "$EXPECTED"; then + echo "Basic test passed" + else + echo "Basic test failed" + echo "Expected to contain:" + echo "$EXPECTED" + echo "Got:" + echo "$OUTPUT" + exit 1 + fi + + #TODO(zzy): Test embed targets, need dispatch target dir diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 9e320358..c678d7df 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -27,7 +27,7 @@ jobs: if: steps.cache-darwin-sysroot.outputs.cache-hit != 'true' run: tar -czvf .sysroot/darwin.tar.gz -C .sysroot darwin - name: Save Darwin sysroot cache - # if: steps.cache-darwin-sysroot.outputs.cache-hit != 'true' + if: steps.cache-darwin-sysroot.outputs.cache-hit != 'true' uses: actions/cache/save@v4 with: path: .sysroot/darwin.tar.gz @@ -171,7 +171,7 @@ jobs: ls -la release-llgo/ echo "${{ github.workspace }}/release-llgo/bin/" >> $GITHUB_PATH - - name: Test Hello World with go.mod 1.21 + - name: Test Hello World uses: ./.github/actions/test-helloworld with: go-version: ${{matrix.go-version}} From 16845123086ab6c1191da3c4c17c131ae5ea67bd Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Thu, 4 Sep 2025 16:29:39 +0800 Subject: [PATCH 24/26] ci(release test):cache key to env --- .github/actions/setup-goreleaser/action.yml | 11 +++++-- .github/workflows/release-build.yml | 36 +++++++++++++++++---- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/.github/actions/setup-goreleaser/action.yml b/.github/actions/setup-goreleaser/action.yml index 1748c12e..d4ef8665 100644 --- a/.github/actions/setup-goreleaser/action.yml +++ b/.github/actions/setup-goreleaser/action.yml @@ -1,5 +1,12 @@ name: "Setup GoReleaser" description: "Setup GoReleaser environment" +inputs: + darwin-cache-key: + description: "Darwin sysroot cache key" + required: true + linux-cache-key: + description: "Linux sysroot cache key" + required: true runs: using: "composite" steps: @@ -12,13 +19,13 @@ runs: uses: actions/cache/restore@v4 with: path: .sysroot/darwin.tar.gz - key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.5 + key: ${{ inputs.darwin-cache-key }} - name: Restore Linux sysroot cache id: cache-linux-sysroot uses: actions/cache/restore@v4 with: path: .sysroot/linux.tar.gz - key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }}-0.0.7 + key: ${{ inputs.linux-cache-key }} - name: Populate Darwin sysroot run: tar -xzvf .sysroot/darwin.tar.gz -C .sysroot shell: bash diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index c678d7df..53deb458 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -8,8 +8,25 @@ on: branches: ["**"] jobs: + setup: + runs-on: ubuntu-latest + outputs: + darwin-cache-key: ${{ steps.cache-keys.outputs.darwin-key }} + linux-cache-key: ${{ steps.cache-keys.outputs.linux-key }} + steps: + - name: Check out code + uses: actions/checkout@v5 + - name: Calculate cache keys + id: cache-keys + run: | + DARWIN_KEY="darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.5" + LINUX_KEY="linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }}-0.0.7" + echo "darwin-key=$DARWIN_KEY" >> $GITHUB_OUTPUT + echo "linux-key=$LINUX_KEY" >> $GITHUB_OUTPUT + populate-darwin-sysroot: runs-on: macos-latest + needs: setup steps: - name: Check out code uses: actions/checkout@v5 @@ -18,7 +35,7 @@ jobs: uses: actions/cache/restore@v4 with: path: .sysroot/darwin.tar.gz - key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.5 + key: ${{ needs.setup.outputs.darwin-cache-key }} lookup-only: true - name: Populate Darwin sysroot if: steps.cache-darwin-sysroot.outputs.cache-hit != 'true' @@ -31,9 +48,10 @@ jobs: uses: actions/cache/save@v4 with: path: .sysroot/darwin.tar.gz - key: darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.5 + key: ${{ needs.setup.outputs.darwin-cache-key }} populate-linux-sysroot: runs-on: ubuntu-latest + needs: setup steps: - name: Check out code uses: actions/checkout@v5 @@ -42,7 +60,7 @@ jobs: uses: actions/cache/restore@v4 with: path: .sysroot/linux.tar.gz - key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }}-0.0.7 + key: ${{ needs.setup.outputs.linux-cache-key }} lookup-only: true - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -60,15 +78,18 @@ jobs: uses: actions/cache/save@v4 with: path: .sysroot/linux.tar.gz - key: linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }}-0.0.7 + key: ${{ needs.setup.outputs.linux-cache-key }} build: runs-on: ubuntu-latest - needs: [populate-darwin-sysroot, populate-linux-sysroot] + needs: [setup, populate-darwin-sysroot, populate-linux-sysroot] steps: - name: Check out code uses: actions/checkout@v5 - name: Set up Release uses: ./.github/actions/setup-goreleaser + with: + darwin-cache-key: ${{ needs.setup.outputs.darwin-cache-key }} + linux-cache-key: ${{ needs.setup.outputs.linux-cache-key }} - name: Run GoReleaser (Build & Test) env: GITHUB_TOKEN: ${{github.token}} @@ -178,7 +199,7 @@ jobs: mod-version: ${{ matrix.go-mod-version }} release: - needs: [build, test-artifacts] + needs: [setup, build, test-artifacts] runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/') steps: @@ -188,6 +209,9 @@ jobs: fetch-depth: 0 - name: Set up Release uses: ./.github/actions/setup-goreleaser + with: + darwin-cache-key: ${{ needs.setup.outputs.darwin-cache-key }} + linux-cache-key: ${{ needs.setup.outputs.linux-cache-key }} - name: Run GoReleaser (Release) env: GITHUB_TOKEN: ${{github.token}} From 00dbc91745ec38e58fc10d1f71ca053408a8d68b Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Thu, 4 Sep 2025 17:07:55 +0800 Subject: [PATCH 25/26] ci(release test):cache with sh & gh yml --- .github/workflows/release-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 53deb458..2acd9152 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -19,8 +19,8 @@ jobs: - name: Calculate cache keys id: cache-keys run: | - DARWIN_KEY="darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh') }}-0.0.5" - LINUX_KEY="linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh') }}-0.0.7" + DARWIN_KEY="darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh', '.github/workflows/release-build.yml') }}" + LINUX_KEY="linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh', '.github/workflows/release-build.yml') }}" echo "darwin-key=$DARWIN_KEY" >> $GITHUB_OUTPUT echo "linux-key=$LINUX_KEY" >> $GITHUB_OUTPUT 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 26/26] 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