Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions .github/actions/setup-go/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@ name: "Setup Go"
description: "Set up and verify the requested Go toolchain"
inputs:
go-version:
description: "The exact Go version to install"
description: "The exact Go version to install; omit it for the LLGo build toolchain"
required: false
# Keep this pin synchronized with the primary CI and release smoke-test
# matrices. Upgrade it in a dedicated toolchain-update PR.
default: "1.26.5"
default: ""
runs:
using: "composite"
steps:
- name: Set up Go
- name: Set up the LLGo build toolchain
if: inputs.go-version == ''
uses: actions/setup-go@v7
with:
go-version-file: .go-version
cache: false

- name: Set up an explicit Go toolchain
if: inputs.go-version != ''
uses: actions/setup-go@v7
with:
go-version: ${{ inputs.go-version }}
Expand All @@ -22,6 +28,9 @@ runs:
set -euo pipefail

requested="${{ inputs.go-version }}"
if [[ -z "${requested}" ]]; then
requested="$(tr -d '[:space:]' < .go-version)"
fi
requested="${requested#go}"
actual="$(go env GOVERSION)"
actual="${actual#go}"
Expand Down
60 changes: 10 additions & 50 deletions .github/actions/test-helloworld/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@ name: "Test Hello World"
description: "Test Hello World with specific Go and module versions"
inputs:
go-version:
description: "Go version being tested"
required: true
description: "Exact Go series used to run the smoke test"
required: false
default: "1.26"
embedded:
description: "Also run the ESP32 build smoke test"
required: false
default: "true"
mod-version:
description: "Go module version to use"
required: true
Expand All @@ -13,51 +18,6 @@ runs:
- name: Test Hello World
shell: bash
run: |
echo "Testing with Go ${{ inputs.go-version }} and go.mod ${{ inputs.mod-version }}"
mkdir -p _test/helloworld && cd _test/helloworld
cat > go.mod << 'EOL'
module hello
go ${{ inputs.mod-version }}
EOL
cat > main.go << 'EOL'
package main
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
EXPECTED="Hello, LLGo!
Hello, LLGo!
Hello, LLGo!
Hello LLGo by cpp/std.Str"
OUTPUT=$(llgo run . 2>&1 | tee /dev/stderr)
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

cd ../..
mkdir -p _test/emb && cd _test/emb
cat > main.go << 'EOL'
package main

func main() {
}
EOL
llgo build -v -target esp32-coreboard-v2 -o demo.out .
test -f demo.out.elf && echo "ESP32 cross-compilation test passed: demo.out.elf generated"
exit $?
LLGO_HELLO_EMBED="${{ inputs.embedded }}" \
dev/with_go_version.sh "${{ inputs.go-version }}" \
dev/test_helloworld.sh "${{ inputs.mod-version }}"
10 changes: 10 additions & 0 deletions .github/test-go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module github.com/xgo-dev/llgo

go 1.20

require (
github.com/goplus/lib v0.3.1
github.com/xgo-dev/llgo/runtime v0.0.0-00010101000000-000000000000
go.yaml.in/yaml/v3 v3.0.5
golang.org/x/sys v0.30.0
)
6 changes: 6 additions & 0 deletions .github/test-go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
github.com/goplus/lib v0.3.1 h1:Xws4DBVvgOMu58awqB972wtvTacDbk3nqcbHjdx9KSg=
github.com/goplus/lib v0.3.1/go.mod h1:SgJv3oPqLLHCu0gcL46ejOP3x7/2ry2Jtxu7ta32kp0=
go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw=
go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
set -euo pipefail

# test/go intentionally contains compiler edge cases that make the
# Go 1.26.5 printf analyzer panic. Keep the normal go test vet gate
# The current Go 1.26 printf analyzer panics here. Keep the normal go test vet gate
# for every other package, and disable vet only for that package.
go list ./... \
| grep -v '^github.com/xgo-dev/llgo/test/go$' \
Expand Down
58 changes: 38 additions & 20 deletions .github/workflows/goroot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ concurrency:

jobs:
goroot:
name: GOROOT (${{ matrix.lane }}, ${{ matrix.os }}, Go ${{ matrix.go-version }}, shard ${{ matrix.shard-index }}/4)
name: GOROOT (${{ matrix.lane }}, ${{ matrix.os }}, Go ${{ matrix.go-label }}, shard ${{ matrix.shard-index }}/4)
timeout-minutes: 180
env:
GOPROXY: https://proxy.golang.org,direct
Expand All @@ -24,18 +24,21 @@ jobs:
strategy:
fail-fast: false
matrix:
# These are reproducibility pins, not floating series selectors.
# Upgrade them together in a dedicated toolchain-update PR.
# Go 1.25 is an explicit compatibility target. The primary toolchain
# is read from .go-version after checkout.
os: [macos-latest, ubuntu-latest]
go-version: ["1.25.0", "1.26.5"]
toolchain: [go1.25, current]
shard-index: ["0", "1", "2", "3"]
include:
- go-version: "1.25.0"
- toolchain: go1.25
go-version: "1.25.11"
go-label: "1.25.11"
lane: compatibility
- go-version: "1.26.5"
- toolchain: current
go-version: ""
go-label: current
lane: primary
# Keep both supported runtime generations on Linux and macOS. Go 1.25
# is intentionally omitted because it is not a compatibility target.
# Keep the compatibility and primary toolchains on Linux and macOS.
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v7
Expand All @@ -45,7 +48,14 @@ jobs:
with:
llvm-version: 19

- name: Set up Go
- name: Set up Go for building llgo and the runner
uses: ./.github/actions/setup-go

- name: Build llgo and the GOROOT runner
run: |
LLGO_BUILD_GOROOT_RUNNER=1 dev/build_ci_tools.sh "$RUNNER_TEMP/llgo-bin"

- name: Set up target Go
uses: ./.github/actions/setup-go
with:
go-version: ${{ matrix.go-version }}
Expand All @@ -56,20 +66,21 @@ jobs:
go env GOPROXY GOMODCACHE
clang --version

- name: Download Go modules
timeout-minutes: 10
run: go mod download

- name: Run GOROOT runner
env:
GOTOOLCHAIN: local
LLGO_GOROOT_RUNNER: ${{ runner.temp }}/llgo-bin/goroot-runner
LLGO_TEST_LLGO: ${{ runner.temp }}/llgo-bin/llgo
run: |
min_swap_free_mib=512
if [[ "$RUNNER_OS" == "macOS" ]]; then
# macOS manages swap dynamically; a low instantaneous free value
# does not mean the runner cannot make forward progress.
min_swap_free_mib=0
fi
target_goroot="$(go env GOROOT)"
set +e
bash dev/test_goroot.sh -- \
bash dev/test_goroot.sh "$target_goroot" -- \
-directive-mode ci \
-min-swap-free-mib "$min_swap_free_mib" \
-progress 60s \
Expand All @@ -83,9 +94,10 @@ jobs:
if: always()
env:
MATRIX_OS: ${{ matrix.os }}
GO_VERSION: ${{ matrix.go-version }}
SHARD_INDEX: ${{ matrix.shard-index }}
run: |
GO_VERSION="$(GOTOOLCHAIN=local go env GOVERSION)"
GO_VERSION="${GO_VERSION#go}"
log="$RUNNER_TEMP/goroot.log"
report_dir="$RUNNER_TEMP/goroot-report"
mkdir -p "$report_dir"
Expand Down Expand Up @@ -139,7 +151,7 @@ jobs:
if: always()
uses: actions/upload-artifact@v7
with:
name: goroot-stat-${{ matrix.os }}-${{ matrix.go-version }}-${{ matrix.shard-index }}
name: goroot-stat-${{ matrix.os }}-${{ matrix.toolchain }}-${{ matrix.shard-index }}
path: ${{ runner.temp }}/goroot-report
if-no-files-found: error
retention-days: 7
Expand Down Expand Up @@ -167,6 +179,12 @@ jobs:
find reports -type f -name 'failures-*.tsv' -exec cat {} + >"$failure_tsv"

report_count=$(wc -l <"$summary_tsv" | tr -d ' ')
compatibility_version=$(awk -F '\t' '$2 ~ /^1\.25\./ { print $2; exit }' "$summary_tsv")
primary_version=$(awk -F '\t' '$2 ~ /^1\.26\./ { print $2; exit }' "$summary_tsv")
if [[ -z "$compatibility_version" || -z "$primary_version" ]]; then
echo "error: could not determine compatibility and primary Go versions" >&2
exit 1
fi
write_row() {
local label=$1
local platform=$2
Expand Down Expand Up @@ -204,11 +222,11 @@ jobs:
echo
echo '| Platform / toolchain | Shards | Selected | Observed | Passed | Failed | Skipped |'
echo '|---|---:|---:|---:|---:|---:|---:|'
write_row 'Darwin · Go 1.25.0' darwin/arm64 1.25.0 4
write_row 'Darwin · Go 1.26.5' darwin/arm64 1.26.5 4
write_row "Darwin · Go $compatibility_version" darwin/arm64 "$compatibility_version" 4
write_row "Darwin · Go $primary_version" darwin/arm64 "$primary_version" 4
write_row '**Darwin total**' darwin/arm64 '' 8
write_row 'Linux · Go 1.25.0' linux/amd64 1.25.0 4
write_row 'Linux · Go 1.26.5' linux/amd64 1.26.5 4
write_row "Linux · Go $compatibility_version" linux/amd64 "$compatibility_version" 4
write_row "Linux · Go $primary_version" linux/amd64 "$primary_version" 4
write_row '**Linux total**' linux/amd64 '' 8
echo
echo '_Passed means the runner classification succeeded; expected xfail/not-applicable failures and classified flakes are counted as Passed._'
Expand Down
Loading
Loading