-
Notifications
You must be signed in to change notification settings - Fork 93
feat(go): add SDK with release-downloaded native bindings #501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
anirudh-makuluri
wants to merge
15
commits into
usemoss:main
Choose a base branch
from
anirudh-makuluri:feat/go-sdk-prebuilt-bindings
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
5f1c228
feat(go): add drop-in SDK distribution via static libmoss modules
anirudh-makuluri a69b197
fix(go): split publish into per-platform tags to avoid push timeouts
anirudh-makuluri c579905
feat(go): download native libs at build time via tools/install
anirudh-makuluri a811acd
chore(go): publish bindings and sdk v0.1.0
anirudh-makuluri 48aefd0
fix(go): install natives into vendor or user cache
anirudh-makuluri e6fc81f
chore(go): publish bindings and sdk v0.1.1
anirudh-makuluri 9a2a1e9
fix(go): vendor bindings before native install
anirudh-makuluri 9a98492
chore(go): align source-only module release version
anirudh-makuluri b56b267
fix(go): harden native SDK publishing and install
anirudh-makuluri e127a6d
fix(go): align bindings and installer versions
anirudh-makuluri 6909a8c
fix(go): limit native bindings to supported targets
anirudh-makuluri 2389b7c
fix(go): harden release and workspace installs
anirudh-makuluri 6ecd902
fix(go): validate releases and atomic tags
anirudh-makuluri af9e961
fix(go): protect module cache installs
anirudh-makuluri d318f47
updated README.md to reflect the correct path
anirudh-makuluri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| name: Go SDK test | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - 'sdks/go/**' | ||
| - '.github/workflows/go-sdk-test.yml' | ||
| pull_request: | ||
| paths: | ||
| - 'sdks/go/**' | ||
| - '.github/workflows/go-sdk-test.yml' | ||
|
|
||
| jobs: | ||
| unit-test: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: '1.22.2' | ||
|
|
||
| - name: Run SDK unit tests without native bindings | ||
| working-directory: sdks/go/sdk | ||
| env: | ||
| CGO_ENABLED: '0' | ||
| run: go test ./... | ||
|
|
||
| - name: Verify SDK standalone module mode | ||
| working-directory: sdks/go/sdk | ||
| env: | ||
| CGO_ENABLED: '0' | ||
| GOWORK: 'off' | ||
| run: go test ./... | ||
|
|
||
| - name: Run native installer tests | ||
| working-directory: sdks/go/tools/install | ||
| run: go test ./... | ||
|
|
||
| bindings-smoke: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: '1.22.2' | ||
|
|
||
| - name: Install linux-amd64 native library | ||
| working-directory: sdks/go | ||
| run: go run ./tools/install --release c-sdk-v0.9.0 | ||
|
|
||
| - name: Verify bindings compile with CGO | ||
| working-directory: sdks/go/bindings | ||
| env: | ||
| CGO_ENABLED: '1' | ||
| run: go build -v . | ||
|
|
||
| - name: Verify SDK compiles with CGO | ||
| working-directory: sdks/go/sdk | ||
| env: | ||
| CGO_ENABLED: '1' | ||
| run: go build -v . | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| name: Publish Go SDK | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| c_sdk_version: | ||
| description: 'C SDK GitHub release tag' | ||
| required: true | ||
| default: 'c-sdk-v0.9.0' | ||
| go_version: | ||
| description: 'Go module version to publish' | ||
| required: true | ||
| default: 'v0.1.2' | ||
|
|
||
| concurrency: | ||
| group: go-sdk-release-${{ github.event.inputs.go_version }} | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| publish: | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| C_SDK_VERSION: ${{ github.event.inputs.c_sdk_version }} | ||
| GO_VERSION: ${{ github.event.inputs.go_version }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: '1.22.2' | ||
|
|
||
| - name: Configure Git author | ||
| run: | | ||
| git config user.name 'github-actions[bot]' | ||
| git config user.email '41898282+github-actions[bot]@users.noreply.github.com' | ||
|
|
||
| - name: Update bindings native version metadata | ||
| shell: bash | ||
| run: | | ||
| if [[ ! "${C_SDK_VERSION}" =~ ^c-sdk-v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then | ||
| echo "c_sdk_version must be a c-sdk-vMAJOR.MINOR.PATCH tag" >&2 | ||
| exit 1 | ||
| fi | ||
| if [[ ! "${GO_VERSION}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then | ||
| echo "go_version must be a vMAJOR.MINOR.PATCH tag" >&2 | ||
| exit 1 | ||
| fi | ||
| NATIVE_VERSION="${C_SDK_VERSION#c-sdk-v}" | ||
| cat > sdks/go/bindings/version.go <<EOF | ||
| package mosscore | ||
|
|
||
| // NativeLibVersion is the Moss C SDK version downloaded at build time. | ||
| const NativeLibVersion = "${NATIVE_VERSION}" | ||
|
|
||
| // NativeLibReleaseTag is the GitHub release tag used to fetch native artifacts. | ||
| const NativeLibReleaseTag = "${C_SDK_VERSION}" | ||
| EOF | ||
|
|
||
| - name: Verify selected C SDK release | ||
| working-directory: sdks/go | ||
| run: go run ./tools/install --all --release "$C_SDK_VERSION" | ||
|
|
||
| - name: Verify native Go SDK build | ||
| run: | | ||
| (cd sdks/go/bindings && CGO_ENABLED=1 go build .) | ||
| (cd sdks/go/sdk && CGO_ENABLED=1 go build .) | ||
|
|
||
| - name: Publish source-only module tags | ||
|
anirudh-makuluri marked this conversation as resolved.
|
||
| run: ./sdks/go/scripts/publish-sdk-module-tags.sh "$GO_VERSION" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,48 @@ | ||
| # Moss Go SDK | ||
|
|
||
| The Go work now has the same two-layer direction as the other Moss SDKs: | ||
| The Go SDK follows the same two-layer design as the other Moss SDKs: | ||
|
|
||
| - `sdks/go/sdk/` contains the public Go SDK | ||
| - `sdks/go/bindings/` wraps the native `libmoss` runtime via CGO | ||
|
|
||
| Current status: | ||
| ## Install | ||
|
|
||
| - bindings-backed manage operations for mutations and metadata reads | ||
| - local `LoadIndex` / `UnloadIndex` / `GetIndexInfo` / local `Query` via `libmoss` | ||
| - examples under `examples/go/` and unit tests | ||
| - env-gated integration test scaffold | ||
| ```bash | ||
| go get github.com/usemoss/moss/sdks/go/sdk | ||
| go run github.com/usemoss/moss/sdks/go/tools/install@latest --vendor | ||
| ``` | ||
|
|
||
| Important note: | ||
| The install tool downloads the static `libmoss` library for your platform from | ||
| [Moss C SDK GitHub Releases](https://github.com/usemoss/moss/releases). You need | ||
| CGO and a C compiler, but not a manual C SDK download or `LD_LIBRARY_PATH`. | ||
| For external projects, the explicit `--vendor` option lets the installer vendor | ||
| the bindings before placing the library next to them, so the normal `go build` | ||
| command finds it. | ||
|
|
||
| - all runtime operations require the `libmoss` C SDK plus `-tags libmoss` | ||
| Native bindings currently support Linux (`amd64`, `arm64`) and Apple Silicon | ||
| macOS (`arm64`). Other platforms, including Windows, use the | ||
| bindings-unavailable stub until a compatible native release is available. | ||
|
|
||
| The public SDK module lives under [`sdks/go/sdk/`](./sdk/), and the native | ||
| bindings module lives under [`sdks/go/bindings/`](./bindings/). | ||
| From a checkout of the bindings package, you can instead use: | ||
|
|
||
| ```bash | ||
| go generate github.com/usemoss/moss/sdks/go/bindings | ||
| ``` | ||
|
|
||
| ## Local development | ||
|
|
||
| ```bash | ||
| ./sdks/go/scripts/link_dev_lib.sh c-sdk-v0.9.0 | ||
| cd sdks/go/sdk | ||
| CGO_ENABLED=1 go test ./... | ||
| ``` | ||
|
|
||
| Unit tests run without native libraries when `CGO_ENABLED=0`. | ||
|
|
||
| ## Publishing | ||
|
|
||
| See [`bindings/README.md`](./bindings/README.md) and | ||
| [`.github/workflows/publish-go-sdk.yml`](../../.github/workflows/publish-go-sdk.yml). | ||
|
|
||
| The public SDK module lives under [`sdk/`](./sdk/), and the native bindings module | ||
| lives under [`bindings/`](./bindings/). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| package mosscore | ||
|
|
||
| //go:generate go run ../tools/install |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.