Skip to content

[Go] Test the Go binding against release archives - #33287

Open
Danny On The Air (dannyota) wants to merge 8 commits into
microsoft:mainfrom
dannyota:go/release-ci
Open

Danny On The Air (dannyota) wants to merge 8 commits into
microsoft:mainfrom
dannyota:go/release-ci

Conversation

@dannyota

Copy link
Copy Markdown
Contributor

Description

Adds a workflow that tests the Go binding against the released ONNX Runtime 1.31.0 archives on Linux x64, Linux arm64, macOS arm64 and Windows x64.

Each target:

  1. Downloads the release archive and verifies its pinned SHA-256.
  2. Runs uncached go test -race on go/onnxruntime. The new go/internal/citest checker requires named passing tests and the expected runtime and API versions.
  3. Builds go/examples/basic in a fresh module using release commit 402979ac1bef89dcd55add41eaa7277c407599eb, verifies the module origin through GOPROXY=direct, and checks inference output and cleanup.
  4. Confirms failure for a missing runtime, wrong API version, wrong runtime version and wrong module origin.

Windows uses MSYS2 UCRT64 GCC for cgo race tests. The profiling test now uses a temporary directory. The Windows loader converts native DLL symbol addresses in C so the package passes go vet.

The workflow runs on pull requests touching go/, the workflow, or the C API headers, and on manual dispatch. Permissions are read-only, actions are pinned by commit, and no secrets are used.

Motivation and Context

Issue #32535 requests a go/v1.31.0 tag at the release commit. This workflow checks that commit on all four targets as a consumer would use it. It also prevents a false green result when the checkout's Go suite exits without running tests because no runtime is configured.

This PR is independent of #33282. The checker selects API 27 for the current checkout and API 31 for the upgrade profile. The fixed release consumer expects API 27.

Testing

  • Final fork run: all four targets passed at head c7b474aca606a9c005b69f1aecf6e6a8ce10b7ce, testing merge 65b63047f2e8da5a21114697c2c4ef85917caea1 through pull_request. Each target passed 134 top-level tests with three skips, verified runtime 1.31.0/API 27, resolved the fixed release commit, returned [11 22 33 44 55 66], and passed the negative checks.
  • Fault-injection run: a wrong digest stopped Linux x64 before extraction; removing the extracted library stopped Linux arm64 and macOS before the suite. Both temporary changes were reverted before the final run.
  • Local Linux race tests passed with runtimes 1.27.0, 1.28.3, 1.29.1, 1.30.0 and 1.31.0. Helper/example tests, vet, formatting, lint, actionlint, shell syntax checks and focused regression probes passed.
  • A combined hosted run with [Go] Update to the current C API and add plugin execution providers #33282 remains pending; compatibility with that branch is not yet claimed.

TestSessionOptionsProfiling wrote its profile under a fixed /tmp path,
which does not exist on Windows. It now writes into t.TempDir(), closes
the session when the test ends, and checks that the profile file was
written.

Signed-off-by: Danny <dannyontheair@outlook.com>
A green `go test` is not enough evidence for CI: on main the suite exits
0 without running anything when no runtime is configured. The new
go/internal/citest command checks a `go test -json` stream for package
success and named passing tests and verifies the runtime version and API
the tests report. It also derives the expected API from the binding's
headers, and checks the module origin a consumer resolved. It uses only
the standard library and does not load ONNX Runtime.

Signed-off-by: Danny <dannyontheair@outlook.com>
go/examples/basic runs the add model through the public API and checks
the output shape and every value. It closes the outputs, inputs and
session before Shutdown and prints success only after cleanup succeeds.
Optional flags check the initialized runtime version, the negotiated API
and, when built as a dependency, the selected module version from build
info, rejecting a replaced module. CI builds this example in a fresh
module to test a released commit as a consumer would.

Signed-off-by: Danny <dannyontheair@outlook.com>
Adds a workflow that runs on four hosted targets (Linux x64, Linux
arm64, macOS arm64 and Windows x64) against the released ONNX Runtime
1.31.0 archives, pinned by SHA-256. Each target runs the race-enabled
test suite from the checkout and checks its JSON output with citest: the
named tests must pass and report the expected runtime and API version.
It then builds the example in a fresh module that depends on release
commit 402979a, verifies the module origin and runs inference.
Negative checks confirm that a missing runtime, a wrong API, a wrong
runtime version and a wrong origin each fail. Windows uses MSYS2 UCRT64
GCC so that -race works with cgo.

The workflow runs on pull requests that touch go/ or the C API headers,
and on manual dispatch, with read-only permissions.

Signed-off-by: Danny <dannyontheair@outlook.com>
Signed-off-by: Danny <dannyontheair@outlook.com>
Signed-off-by: Danny <dannyontheair@outlook.com>
Signed-off-by: Danny <dannyontheair@outlook.com>
This reverts commit 697e8ed.

Signed-off-by: Danny <dannyontheair@outlook.com>
Copilot AI balanced review requested due to automatic review settings October 12, 2026 02:42
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The workflow and supporting changes are thoroughly validated with focused unit and cross-platform integration coverage.

0 open findings

What changed in this PR

Adds cross-platform CI validating the Go binding against ONNX Runtime 1.31.0 release archives. No actionable issues found.

Changes:

  • Adds archive verification and race-tested Go CI across four targets.
  • Adds result, API, and module-origin validation helpers with tests.
  • Adds a release-consumer example and improves profiling portability.
File Description
.github/​workflows/​go-release-ci.yml Defines release-archive and consumer validation.
go/​internal/​citest/​main.go Implements CI evidence checks.
go/​internal/​citest/​main_test.go Tests CI checker behavior.
go/​examples/​basic/​main.go Adds release-consumer inference example.
go/​examples/​basic/​main_test.go Tests example validation helpers.
go/​onnxruntime/​load_windows.go Safely converts native symbol addresses.
go/​onnxruntime/​options_test.go Makes profiling tests portable and verifies output.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants