|
| 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 |
0 commit comments