diff --git a/.github/scripts/test_go_binding/matrix.yaml b/.github/scripts/test_go_binding/matrix.yaml new file mode 100644 index 000000000000..27ba73a8501a --- /dev/null +++ b/.github/scripts/test_go_binding/matrix.yaml @@ -0,0 +1,26 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +os: ["ubuntu-latest"] +build: + - target: "x86_64-unknown-linux-gnu" + cc: "gcc" + goos: "linux" + goarch: "amd64" +service: + - "memory" + diff --git a/.github/workflows/ci_bindings_go.yml b/.github/workflows/ci_bindings_go.yml index edb853921816..bb975fce4f0d 100644 --- a/.github/workflows/ci_bindings_go.yml +++ b/.github/workflows/ci_bindings_go.yml @@ -41,14 +41,75 @@ permissions: contents: read jobs: - test: + matrix: runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - uses: actions/checkout@v4 + - id: set-matrix + name: Setup Matrix + run: | + MATRIX=$(yq -o=json -I=0 "." .github/scripts/test_go_binding/matrix.yaml | sed 's/ //g') + echo "Matrix:" + echo "$MATRIX" | jq . + echo "matrix=$MATRIX" >> $GITHUB_OUTPUT + test: + needs: [ matrix ] + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: ${{ fromJson(needs.matrix.outputs.matrix) }} steps: - uses: actions/checkout@v4 + - uses: actions/checkout@v4 + with: + repository: "apache/opendal-go-services" + path: "tools" + - name: Setup Rust toolchain + uses: ./.github/actions/setup + - name: Setup Target + env: + TARGET: ${{ matrix.build.target }} + run: rustup target add $TARGET - uses: actions/setup-go@v5 - + - uses: actions/setup-python@v5 + with: + python-version: "3.10" + - name: Setup Service + env: + OPENDAL_FEATURES: "layers-blocking,services-${{ matrix.service }}" + run: | + python -m pip install toml + python tools/.github/scripts/setup_features.py + - name: Build C Binding + working-directory: bindings/c + env: + VERSION: "latest" + SERVICE: ${{ matrix.service }} + TARGET: ${{ matrix.build.target }} + CC: ${{ matrix.build.cc }} + run: | + cargo build --target $TARGET --release + sudo apt install zstd + DIR=$GITHUB_WORKSPACE/libopendal_c_${VERSION}_${SERVICE}_$TARGET + mkdir $DIR + zstd -22 ./target/$TARGET/release/libopendal_c.so -o $DIR/libopendal_c.$TARGET.so.zst + - name: Build Go Artifact + working-directory: tools/internal/generate + env: + MATRIX: ${{ needs.matrix.outputs.matrix }} + VERSION: "latest" + run: | + go run generate.go + - name: Setup Go Workspace + env: + SERVICE: ${{ matrix.service }} + working-directory: bindings/go/tests + run: | + go work use $GITHUB_WORKSPACE/$(echo $SERVICE | sed 's/-/_/g') - name: Run tests env: - OPENDAL_TEST: "memory" - working-directory: bindings/go + OPENDAL_TEST: ${{ matrix.service }} + working-directory: bindings/go/tests/behavior_tests run: CGO_ENABLE=0 go test -v -run TestBehavior diff --git a/bindings/go/README.md b/bindings/go/README.md index 11cdbf3e31d0..52354332fed7 100644 --- a/bindings/go/README.md +++ b/bindings/go/README.md @@ -19,7 +19,7 @@ import ( "fmt" "os" - "github.com/yuchanns/opendal-go-services/memory" + "github.com/apache/opendal-go-services/memory" opendal "github.com/apache/opendal/bindings/go" ) @@ -92,6 +92,7 @@ func main() { ### Behavior Tests ```bash +cd tests/behavior_tests # Test a specific backend export OPENDAL_TEST=memory # Run all tests @@ -105,6 +106,7 @@ CGO_ENABLE=0 GOMAXPROCS=1 go test -v -run TestBehavior ### Benchmark ```bash +cd tests/behavior_tests # Benchmark a specific backend export OPENDAL_TEST=memory diff --git a/bindings/go/go.mod b/bindings/go/go.mod index 21d89c79a1fe..b05f3dfc939c 100644 --- a/bindings/go/go.mod +++ b/bindings/go/go.mod @@ -23,16 +23,6 @@ toolchain go1.22.5 require ( github.com/ebitengine/purego v0.7.1 - github.com/google/uuid v1.6.0 github.com/jupiterrider/ffi v0.1.0-beta.9 - github.com/stretchr/testify v1.9.0 - github.com/yuchanns/opendal-go-services v0.0.1 golang.org/x/sys v0.22.0 ) - -require ( - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/klauspost/compress v1.17.9 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect -) diff --git a/bindings/go/go.sum b/bindings/go/go.sum index 729e933025ba..d2f0b01a2d67 100644 --- a/bindings/go/go.sum +++ b/bindings/go/go.sum @@ -1,22 +1,6 @@ -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/ebitengine/purego v0.7.1 h1:6/55d26lG3o9VCZX8lping+bZcmShseiqlh2bnUDiPA= github.com/ebitengine/purego v0.7.1/go.mod h1:ah1In8AOtksoNK6yk5z1HTJeUkC1Ez4Wk2idgGslMwQ= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/jupiterrider/ffi v0.1.0-beta.9 h1:HCeAPTsTFgwvcfavyJwy1L2ANz0c85W+ZE7LfzjZi3A= github.com/jupiterrider/ffi v0.1.0-beta.9/go.mod h1:sOp6VJGFaYyr4APi8gwy6g20QNHv5F8Iq1CVbtC900s= -github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= -github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/yuchanns/opendal-go-services v0.0.1 h1:qeKv0mOhypQNm97g+u94DnijJK5bdEAp5pdjBGf8N7w= -github.com/yuchanns/opendal-go-services v0.0.1/go.mod h1:tw8QXHu3hzsLpiUCQ+pOIhGw7FJFumnh++rKF/BK96I= golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/bindings/go/opendal.go b/bindings/go/opendal.go index 9640e4ddcf5a..eeb7231c13f2 100644 --- a/bindings/go/opendal.go +++ b/bindings/go/opendal.go @@ -33,7 +33,7 @@ // // import ( // "github.com/apache/opendal/bindings/go -// "github.com/yuchanns/opendal-go-services/memory +// "github.com/apache/opendal-go-services/memory // ) // // func main() { diff --git a/bindings/go/benchmark_test.go b/bindings/go/tests/behavior_tests/benchmark_test.go similarity index 100% rename from bindings/go/benchmark_test.go rename to bindings/go/tests/behavior_tests/benchmark_test.go diff --git a/bindings/go/copy_test.go b/bindings/go/tests/behavior_tests/copy_test.go similarity index 100% rename from bindings/go/copy_test.go rename to bindings/go/tests/behavior_tests/copy_test.go diff --git a/bindings/go/create_dir_test.go b/bindings/go/tests/behavior_tests/create_dir_test.go similarity index 100% rename from bindings/go/create_dir_test.go rename to bindings/go/tests/behavior_tests/create_dir_test.go diff --git a/bindings/go/delete_test.go b/bindings/go/tests/behavior_tests/delete_test.go similarity index 100% rename from bindings/go/delete_test.go rename to bindings/go/tests/behavior_tests/delete_test.go diff --git a/bindings/go/tests/behavior_tests/go.mod b/bindings/go/tests/behavior_tests/go.mod new file mode 100644 index 000000000000..b6c1ff39f0da --- /dev/null +++ b/bindings/go/tests/behavior_tests/go.mod @@ -0,0 +1,37 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +module opendal_test + +go 1.22.5 + +require ( + github.com/apache/opendal-go-services/memory v0.0.0-20240719030108-74ff217cfef9 + github.com/apache/opendal/bindings/go v0.0.0-20240719044908-d9d4279b3a24 + github.com/google/uuid v1.6.0 + github.com/stretchr/testify v1.9.0 +) + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/ebitengine/purego v0.7.1 // indirect + github.com/jupiterrider/ffi v0.1.0-beta.9 // indirect + github.com/klauspost/compress v1.17.9 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + golang.org/x/sys v0.22.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/bindings/go/tests/behavior_tests/go.sum b/bindings/go/tests/behavior_tests/go.sum new file mode 100644 index 000000000000..3594204ba238 --- /dev/null +++ b/bindings/go/tests/behavior_tests/go.sum @@ -0,0 +1,26 @@ +github.com/apache/opendal-go-services/memory v0.0.0-20240719030108-74ff217cfef9 h1:tV4Xmoa5Zq2RyrygaXreayLz10C6JqTpyvMYAtdshXQ= +github.com/apache/opendal-go-services/memory v0.0.0-20240719030108-74ff217cfef9/go.mod h1:vldOQuikErKA1wfGnqvjAYB9MON/PWTuFIulMCKIQqM= +github.com/apache/opendal/bindings/go v0.0.0-20240719044908-d9d4279b3a24 h1:2fAl+WS/lZMTtP6onlrmDbb3pltf+5xNTc0Aeu9nYWE= +github.com/apache/opendal/bindings/go v0.0.0-20240719044908-d9d4279b3a24/go.mod h1:jyMN6M6h0jMDZitnjvB3KPobM+oZiESrFb3XUplLxhI= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/ebitengine/purego v0.7.1 h1:6/55d26lG3o9VCZX8lping+bZcmShseiqlh2bnUDiPA= +github.com/ebitengine/purego v0.7.1/go.mod h1:ah1In8AOtksoNK6yk5z1HTJeUkC1Ez4Wk2idgGslMwQ= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/jupiterrider/ffi v0.1.0-beta.9 h1:HCeAPTsTFgwvcfavyJwy1L2ANz0c85W+ZE7LfzjZi3A= +github.com/jupiterrider/ffi v0.1.0-beta.9/go.mod h1:sOp6VJGFaYyr4APi8gwy6g20QNHv5F8Iq1CVbtC900s= +github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= +github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/yuchanns/opendal-go-services v0.0.1 h1:qeKv0mOhypQNm97g+u94DnijJK5bdEAp5pdjBGf8N7w= +github.com/yuchanns/opendal-go-services v0.0.1/go.mod h1:tw8QXHu3hzsLpiUCQ+pOIhGw7FJFumnh++rKF/BK96I= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/bindings/go/list_test.go b/bindings/go/tests/behavior_tests/list_test.go similarity index 100% rename from bindings/go/list_test.go rename to bindings/go/tests/behavior_tests/list_test.go diff --git a/bindings/go/opendal_test.go b/bindings/go/tests/behavior_tests/opendal_test.go similarity index 97% rename from bindings/go/opendal_test.go rename to bindings/go/tests/behavior_tests/opendal_test.go index bf6e5fcbaab2..551087c5f3ec 100644 --- a/bindings/go/opendal_test.go +++ b/bindings/go/tests/behavior_tests/opendal_test.go @@ -30,16 +30,14 @@ import ( "sync" "testing" + "github.com/apache/opendal-go-services/memory" opendal "github.com/apache/opendal/bindings/go" "github.com/google/uuid" "github.com/stretchr/testify/require" - "github.com/yuchanns/opendal-go-services/aliyun_drive" - "github.com/yuchanns/opendal-go-services/memory" ) // Add more schemes for behavior tests here. var schemes = []opendal.Scheme{ - aliyun_drive.Scheme, memory.Scheme, } diff --git a/bindings/go/read_test.go b/bindings/go/tests/behavior_tests/read_test.go similarity index 100% rename from bindings/go/read_test.go rename to bindings/go/tests/behavior_tests/read_test.go diff --git a/bindings/go/rename_test.go b/bindings/go/tests/behavior_tests/rename_test.go similarity index 100% rename from bindings/go/rename_test.go rename to bindings/go/tests/behavior_tests/rename_test.go diff --git a/bindings/go/stat_test.go b/bindings/go/tests/behavior_tests/stat_test.go similarity index 100% rename from bindings/go/stat_test.go rename to bindings/go/tests/behavior_tests/stat_test.go diff --git a/bindings/go/write_test.go b/bindings/go/tests/behavior_tests/write_test.go similarity index 100% rename from bindings/go/write_test.go rename to bindings/go/tests/behavior_tests/write_test.go diff --git a/bindings/go/tests/go.work b/bindings/go/tests/go.work new file mode 100644 index 000000000000..dc66d28856c1 --- /dev/null +++ b/bindings/go/tests/go.work @@ -0,0 +1,6 @@ +go 1.22.5 + +use ( + .. + ./behavior_tests +)