diff --git a/.github/workflows/ci_bindings_go.yml b/.github/workflows/ci_bindings_go.yml index 5ffd5dca56c1..e4c4df73653a 100644 --- a/.github/workflows/ci_bindings_go.yml +++ b/.github/workflows/ci_bindings_go.yml @@ -123,6 +123,9 @@ jobs: SERVICE: ${{ matrix.service }} working-directory: bindings/go/tests run: | + go work init + go work use .. + go work use ./behavior_tests go work use $GITHUB_WORKSPACE/$(echo $SERVICE | sed 's/-/_/g') - name: Run tests env: diff --git a/bindings/go/README.md b/bindings/go/README.md index bcbb68f161ce..3b6cd166e0a7 100644 --- a/bindings/go/README.md +++ b/bindings/go/README.md @@ -208,6 +208,70 @@ geomean 129.7ยต - [x] Copy - [x] Rename +## Development + +The guide is based on Linux. For other platforms, please adjust the commands accordingly. + +To develop the Go binding, you need to have the following dependencies installed: + +- zstd +- Rust toolchain +- Go + +We use `go workspace` to manage and build the dependencies. To set up the workspace, run the following commands: + +```bash +mkdir opendal_workspace +cd opendal_workspace +git clone --depth 1 git@github.com:apache/opendal.git +git clone --depth 1 git@github.com:apache/opendal-go-services.git + +go work init +go work use ./opendal/bindings/go +go work use ./opendal/bindings/go/tests/behavior_tests +# use the backend you want to test, e.g., fs or memory +go work use ./opendal-go-services/fs +go work use ./opendal-go-services/memory + +cat < ./make_test.sh +#!/bin/bash + +architecture=\$(uname -m) +if [ "\$architecture" = "x86_64" ]; then + ARCH="x86_64" +elif [ "\$architecture" = "aarch64" ] || [ "\$architecture" = "arm64" ]; then + ARCH="arm64" +else + ARCH="unknown" +fi + +cd opendal/bindings/c +cargo build +cd - +zstd -19 opendal/bindings/c/target/debug/libopendal_c.so -o opendal-go-services/fs/libopendal_c.linux.\$ARCH.so.zst + +go test ./opendal/bindings/go/tests/behavior_tests -v -run TestBehavior +EOF + +chmod +x ./make_test.sh + +cd - +``` + +To build and run tests, run the following commands: + +```bash +cd opendal_workspace + +# specify the backend to test +export OPENDAL_TEST=fs +export OPENDAL_FS_ROOT=/tmp/opendal + +# build the C binding and run the tests +./make_test.sh + +cd - +``` ## License and Trademarks diff --git a/bindings/go/tests/go.work b/bindings/go/tests/go.work deleted file mode 100644 index dc66d28856c1..000000000000 --- a/bindings/go/tests/go.work +++ /dev/null @@ -1,6 +0,0 @@ -go 1.22.5 - -use ( - .. - ./behavior_tests -) diff --git a/bindings/go/tests/go.work.sum b/bindings/go/tests/go.work.sum deleted file mode 100644 index 93e5f73a8ecf..000000000000 --- a/bindings/go/tests/go.work.sum +++ /dev/null @@ -1,2 +0,0 @@ -github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= -github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=