Skip to content

Commit 4e6271d

Browse files
Add LLGo open-source compatibility testing (#29)
1 parent 227c411 commit 4e6271d

22 files changed

Lines changed: 3284 additions & 5 deletions

.github/workflows/llgo-binary-size.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,15 @@ on:
99
- ci/llgo-size/publish-site.sh
1010
- ci/llgo-size/prepare-pages-branch.sh
1111
- ci/llgo-performance/**
12+
- ci/llgo-compatibility/**
1213
- cmd/bent/configs/benchmarks-llgo-performance.toml
1314
- cmd/bent/configs/configurations-llgo-performance.toml
15+
- cmd/bent/configs/benchmarks-llgo-compatibility.toml
16+
- cmd/bent/configs/configurations-llgo-compatibility.toml
17+
- cmd/bent/scripts/testjson
1418
- .github/workflows/llgo-binary-size-pages.yml
1519
- .github/workflows/llgo-runtime-performance.yml
20+
- .github/workflows/llgo-open-source-compatibility.yml
1621
# ci/llgo-size/llgo-version.env is intentionally not ignored: changing
1722
# the committed LLGo pin must trigger a binary-size build.
1823
pull_request:
@@ -21,10 +26,15 @@ on:
2126
- ci/llgo-size/publish-site.sh
2227
- ci/llgo-size/prepare-pages-branch.sh
2328
- ci/llgo-performance/**
29+
- ci/llgo-compatibility/**
2430
- cmd/bent/configs/benchmarks-llgo-performance.toml
2531
- cmd/bent/configs/configurations-llgo-performance.toml
32+
- cmd/bent/configs/benchmarks-llgo-compatibility.toml
33+
- cmd/bent/configs/configurations-llgo-compatibility.toml
34+
- cmd/bent/scripts/testjson
2635
- .github/workflows/llgo-binary-size-pages.yml
2736
- .github/workflows/llgo-runtime-performance.yml
37+
- .github/workflows/llgo-open-source-compatibility.yml
2838
# GitHub evaluates repository-dispatch workflows from the receiving
2939
# repository's default branch. Merge this workflow there before enabling
3040
# the sender in xgo-dev/llgo.
@@ -126,6 +136,9 @@ jobs:
126136
cmd/bent \
127137
':(exclude)cmd/bent/configs/benchmarks-llgo-performance.toml' \
128138
':(exclude)cmd/bent/configs/configurations-llgo-performance.toml' \
139+
':(exclude)cmd/bent/configs/benchmarks-llgo-compatibility.toml' \
140+
':(exclude)cmd/bent/configs/configurations-llgo-compatibility.toml' \
141+
':(exclude)cmd/bent/scripts/testjson' \
129142
cmd/bent/configs/benchmarks-llgo-size.toml \
130143
cmd/bent/configs/configurations-llgo-size.toml \
131144
cmd/bent/configs/suites.toml; then
Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
name: LLGo open-source compatibility
2+
3+
on:
4+
repository_dispatch:
5+
types: [llgo-tag-released]
6+
pull_request:
7+
paths:
8+
- .github/workflows/llgo-open-source-compatibility.yml
9+
- ci/llgo-compatibility/**
10+
- cmd/bent/configs/benchmarks-llgo-compatibility.toml
11+
- cmd/bent/configs/configurations-llgo-compatibility.toml
12+
- cmd/bent/scripts/testjson
13+
14+
permissions:
15+
contents: read
16+
17+
concurrency:
18+
group: llgo-open-source-compatibility-${{ github.event_name }}-${{ github.event.pull_request.number || 'release' }}
19+
cancel-in-progress: false
20+
21+
jobs:
22+
compatibility:
23+
runs-on: ubuntu-24.04
24+
timeout-minutes: 180
25+
permissions:
26+
contents: write
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- name: Validate the LLGo release notification
31+
env:
32+
DISPATCH_SOURCE_REPOSITORY: ${{ github.event.client_payload.source_repository }}
33+
DISPATCH_LLGO_REPOSITORY: ${{ github.event.client_payload.llgo_repository }}
34+
DISPATCH_LLGO_COMMIT: ${{ github.event.client_payload.llgo_commit }}
35+
DISPATCH_LLGO_TAG: ${{ github.event.client_payload.llgo_tag }}
36+
run: |
37+
set -euo pipefail
38+
set -a
39+
source ci/llgo-size/llgo-version.env
40+
set +a
41+
42+
if [[ "$GITHUB_EVENT_NAME" == "repository_dispatch" ]]; then
43+
if [[ "$DISPATCH_SOURCE_REPOSITORY" != "xgo-dev/llgo" || \
44+
"$DISPATCH_LLGO_REPOSITORY" != "xgo-dev/llgo" ]]; then
45+
echo "refusing LLGo release notification from ${DISPATCH_SOURCE_REPOSITORY:-unknown}" >&2
46+
exit 1
47+
fi
48+
LLGO_REPOSITORY="$DISPATCH_LLGO_REPOSITORY"
49+
LLGO_COMMIT="$DISPATCH_LLGO_COMMIT"
50+
LLGO_TAG="$DISPATCH_LLGO_TAG"
51+
else
52+
LLGO_REPOSITORY="xgo-dev/llgo"
53+
LLGO_TAG=""
54+
fi
55+
if [[ ! "$LLGO_COMMIT" =~ ^[0-9a-f]{40}$ ]]; then
56+
echo "invalid LLGo commit: ${LLGO_COMMIT:-missing}" >&2
57+
exit 1
58+
fi
59+
if [[ -n "$LLGO_TAG" ]] && ! git check-ref-format "refs/tags/$LLGO_TAG"; then
60+
echo "invalid LLGo tag: $LLGO_TAG" >&2
61+
exit 1
62+
fi
63+
64+
printf 'LLGO_REPOSITORY=%s\n' "$LLGO_REPOSITORY" >> "$GITHUB_ENV"
65+
printf 'LLGO_COMMIT=%s\n' "$LLGO_COMMIT" >> "$GITHUB_ENV"
66+
printf 'LLGO_TAG=%s\n' "$LLGO_TAG" >> "$GITHUB_ENV"
67+
printf 'GO_VERSION=%s\n' "$GO_VERSION" >> "$GITHUB_ENV"
68+
printf 'LLVM_VERSION=%s\n' "$LLVM_VERSION" >> "$GITHUB_ENV"
69+
printf 'LLGO_COMPATIBILITY_CPU=%s\n' "$(lscpu | sed -n 's/^Model name:[[:space:]]*//p' | head -1)" >> "$GITHUB_ENV"
70+
mkdir -p .ci
71+
printf '%s\n' "$GO_VERSION" > .ci/go-version
72+
73+
- uses: actions/setup-go@v5
74+
with:
75+
go-version-file: .ci/go-version
76+
77+
- name: Validate compatibility tooling and manifest
78+
run: |
79+
set -euo pipefail
80+
go test ./cmd/bent
81+
python3 -m unittest discover -s ci/llgo-compatibility -p 'test_*.py'
82+
83+
- name: Install LLVM dependencies
84+
run: |
85+
set -euo pipefail
86+
ubuntu_sources=/etc/apt/sources.list.d/ubuntu.sources
87+
if [[ -f "$ubuntu_sources" ]]; then
88+
sudo sed -i \
89+
-e 's|mirror+file:/etc/apt/apt-mirrors.txt|https://archive.ubuntu.com/ubuntu|g' \
90+
-e 's|http://azure.archive.ubuntu.com/ubuntu|https://archive.ubuntu.com/ubuntu|g' \
91+
"$ubuntu_sources"
92+
fi
93+
apt_options=(
94+
-o Acquire::Retries=3
95+
-o Acquire::http::Timeout=30
96+
-o Acquire::https::Timeout=30
97+
-o DPkg::Lock::Timeout=60
98+
)
99+
sudo timeout --kill-after=30s 5m apt-get "${apt_options[@]}" update
100+
sudo timeout --kill-after=30s 15m apt-get "${apt_options[@]}" install -y \
101+
clang-${LLVM_VERSION} lld-${LLVM_VERSION} llvm-${LLVM_VERSION}-dev \
102+
libuv1-dev libgc-dev libffi-dev
103+
104+
- name: Build the selected LLGo compiler
105+
run: |
106+
set -euo pipefail
107+
git clone --filter=blob:none --no-checkout "https://github.com/${LLGO_REPOSITORY}.git" .ci/llgo
108+
if [[ -n "$LLGO_TAG" ]]; then
109+
git -C .ci/llgo fetch --no-tags --depth=1 origin \
110+
"refs/tags/$LLGO_TAG:refs/tags/$LLGO_TAG"
111+
tag_commit=$(git -C .ci/llgo rev-parse "refs/tags/$LLGO_TAG^{commit}")
112+
if [[ "$tag_commit" != "$LLGO_COMMIT" ]]; then
113+
echo "LLGo tag $LLGO_TAG points to $tag_commit, not dispatched $LLGO_COMMIT" >&2
114+
exit 1
115+
fi
116+
else
117+
git -C .ci/llgo fetch --no-tags --depth=1 origin "$LLGO_COMMIT"
118+
fi
119+
git -C .ci/llgo checkout --detach "$LLGO_COMMIT"
120+
export GOROOT="$(go env GOROOT)"
121+
export GOWORK=off
122+
export PATH="$GOROOT/bin:/usr/lib/llvm-${LLVM_VERSION}/bin:$PATH"
123+
export LLGO_ROOT="$GITHUB_WORKSPACE/.ci/llgo"
124+
(cd "$LLGO_ROOT" && go build -tags=dev -o "$LLGO_ROOT/llgo" ./cmd/llgo)
125+
126+
- name: Run pinned open-source tests
127+
env:
128+
LLGO_BIN: ${{ github.workspace }}/.ci/llgo/llgo
129+
LLGO_ROOT: ${{ github.workspace }}/.ci/llgo
130+
run: |
131+
set -euo pipefail
132+
export GOROOT="$(go env GOROOT)"
133+
export PATH="$GOROOT/bin:/usr/lib/llvm-${LLVM_VERSION}/bin:$PATH"
134+
go build -o .ci/bent ./cmd/bent
135+
ci/llgo-compatibility/run.sh \
136+
.ci/bent-compatibility \
137+
"$GITHUB_WORKSPACE/.ci/bent" | tee -a "$GITHUB_STEP_SUMMARY"
138+
139+
- name: Upload compatibility results
140+
if: always()
141+
uses: actions/upload-artifact@v4
142+
with:
143+
name: llgo-open-source-compatibility
144+
path: |
145+
.ci/bent-compatibility/bench
146+
.ci/bent-compatibility/*.log
147+
.ci/bent-compatibility/*.exitcode
148+
.ci/bent-compatibility/selected-packages.txt
149+
.ci/bent-compatibility/results.json
150+
.ci/bent-compatibility/benchmarks-llgo-compatibility.toml
151+
if-no-files-found: warn
152+
153+
- name: Publish compatibility history to Pages
154+
if: github.event_name == 'repository_dispatch'
155+
env:
156+
PAGES_TOKEN: ${{ secrets.GITHUB_TOKEN }}
157+
run: |
158+
set -euo pipefail
159+
pages_dir="$GITHUB_WORKSPACE/.ci/pages"
160+
bash ci/llgo-size/prepare-pages-branch.sh \
161+
"$pages_dir" \
162+
"https://x-access-token:${PAGES_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
163+
ci/llgo-compatibility/publish.sh \
164+
.ci/bent-compatibility \
165+
"$pages_dir" \
166+
ci/llgo-size/site
167+
168+
deploy-pages:
169+
if: github.event_name == 'repository_dispatch'
170+
needs: compatibility
171+
runs-on: ubuntu-24.04
172+
permissions:
173+
contents: read
174+
pages: write
175+
id-token: write
176+
environment:
177+
name: github-pages
178+
url: ${{ steps.deployment.outputs.page_url }}
179+
steps:
180+
- name: Check out Pages source
181+
uses: actions/checkout@v4
182+
with:
183+
ref: pages
184+
path: pages-source
185+
- name: Configure GitHub Pages
186+
uses: actions/configure-pages@v5
187+
- name: Build Pages with Jekyll
188+
uses: actions/jekyll-build-pages@v1
189+
with:
190+
source: ./pages-source
191+
destination: ./_site
192+
- name: Upload Pages artifact
193+
uses: actions/upload-pages-artifact@v4
194+
with:
195+
path: ./_site
196+
- name: Deploy GitHub Pages
197+
id: deployment
198+
uses: actions/deploy-pages@v4

ci/llgo-compatibility/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# LLGo open-source compatibility
2+
3+
This job compiles and runs 200 pinned, short-mode test packages from
4+
representative pure-Go open-source projects with both Go and LLGo. It is triggered by an LLGo release
5+
tag notification and publishes project-, package-, and test-level results to
6+
GitHub Pages.
7+
8+
Go and LLGo are intentionally run in separate Bent invocations. A compiler
9+
failure in one configuration therefore cannot disable the baseline package in
10+
the other. Test binaries are wrapped with `go tool test2json`, while the native
11+
Bent stdout and driver logs are retained beside the structured report.
12+
13+
The checked-in versions are the release comparison contract. Update them in a
14+
normal reviewable PR; do not replace them with `@latest` in release data.
15+
16+
`projects.toml` defines the reviewed project quotas. Regenerate the embedded
17+
Bent manifest with:
18+
19+
```sh
20+
python3 ci/llgo-compatibility/generate_manifest.py \
21+
--output cmd/bent/configs/benchmarks-llgo-compatibility.toml
22+
```
23+
24+
Generation targets linux/amd64 with cgo disabled and requires exactly 200
25+
packages with ordinary Go test files. It excludes main packages, assembly,
26+
cgo, integration/example trees, and testdata.

0 commit comments

Comments
 (0)