This is an automated email from the ASF dual-hosted git repository.

yuchanns pushed a commit to branch ci-bindings-go-behavior-tests
in repository https://gitbox.apache.org/repos/asf/opendal.git

commit a71b394186f9b333323a15e1a359d70960b93777
Author: Hanchin Hsieh <[email protected]>
AuthorDate: Mon Apr 14 13:43:55 2025 +0800

    ci(bindings/go): include go into behavior tests
---
 .github/scripts/test_behavior/plan.py          |   6 +-
 .github/workflows/test_behavior.yml            |  16 ++-
 .github/workflows/test_behavior_binding_go.yml | 186 +++++++++++++++++++++++++
 3 files changed, 205 insertions(+), 3 deletions(-)

diff --git a/.github/scripts/test_behavior/plan.py 
b/.github/scripts/test_behavior/plan.py
index 703b97326..8adaca18f 100755
--- a/.github/scripts/test_behavior/plan.py
+++ b/.github/scripts/test_behavior/plan.py
@@ -31,7 +31,7 @@ GITHUB_DIR = SCRIPT_PATH.parent.parent
 # The project dir for opendal.
 PROJECT_DIR = GITHUB_DIR.parent
 
-LANGUAGE_BINDING = ["java", "python", "nodejs"]
+LANGUAGE_BINDING = ["java", "python", "nodejs", "go"]
 
 BIN = ["ofs"]
 
@@ -86,6 +86,8 @@ class Hint:
     binding_python: bool = field(default=False, init=False)
     # Is binding nodejs affected?
     binding_nodejs: bool = field(default=False, init=False)
+    # Is binding go affected?
+    binding_go: bool = field(default=False, init=False)
     # Is bin ofs affected?
     bin_ofs: bool = field(default=False, init=False)
     # Is integration object_store affected ?
@@ -255,7 +257,7 @@ def generate_language_binding_cases(
     # Bindings may be treated as parallel requests, so we need to disable it 
for all languages.
     cases = [v for v in cases if v["service"] != "aliyun_drive"]
 
-    # Remove hdfs cases for jav:a.
+    # Remove hdfs cases for java.
     if language == "java":
         cases = [v for v in cases if v["service"] != "hdfs"]
 
diff --git a/.github/workflows/test_behavior.yml 
b/.github/workflows/test_behavior.yml
index 0c087d24e..53c07724d 100644
--- a/.github/workflows/test_behavior.yml
+++ b/.github/workflows/test_behavior.yml
@@ -132,7 +132,21 @@ jobs:
     with:
       os: ${{ matrix.os }}
       cases: ${{ toJson(matrix.cases) }}
-  
+
+  test_binding_go:
+    name: binding_go / ${{ matrix.os }}
+    needs: [ plan ]
+    if: fromJson(needs.plan.outputs.plan).components.binding_go
+    secrets: inherit
+    strategy:
+      fail-fast: false
+      matrix:
+        include: ${{ fromJson(needs.plan.outputs.plan).binding_go }}
+    uses: ./.github/workflows/test_behavior_binding_go.yml
+    with:
+      os: ${{ matrix.os }}
+      cases: ${{ toJson(matrix.cases) }}
+
   test_bin_ofs:
     name: bin_ofs / ${{ matrix.os }}
     needs: [plan]
diff --git a/.github/workflows/test_behavior_binding_go.yml 
b/.github/workflows/test_behavior_binding_go.yml
new file mode 100644
index 000000000..cb3087195
--- /dev/null
+++ b/.github/workflows/test_behavior_binding_go.yml
@@ -0,0 +1,186 @@
+# 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.
+
+name: Behavior Test Binding Go
+
+on:
+  workflow_call:
+    inputs:
+      os:
+        required: true
+        type: string
+      cases:
+        required: true
+        type: string
+
+jobs:
+  set-build:
+    runs-on: ubuntu-latest
+    outputs:
+      build: ${{ steps.set-matrix-build.outputs.build }}
+    steps:
+      - id: set-matrix-build
+        name: Setup Matrix Build
+        run: |
+          MATRIX=$(yq -o=json -I=0 "." 
.github/scripts/test_go_binding/matrix.yaml | sed 's/ //g' | jq '[.build[] | 
select(.os == "${{ input.os }}")] | tostring')
+          echo "Matrix:"
+          echo "$MATRIX" | jq .
+          echo "build=$MATRIX" >> $GITHUB_OUTPUT
+
+  test:
+    needs: [ set-build ]
+    name: ${{ matrix.cases.service }} / ${{ matrix.cases.setup }}
+    runs-on: ${{ inputs.os }}
+    strategy:
+      fail-fast: false
+      matrix:
+        cases: ${{ fromJson(inputs.cases) }}
+        build: ${{ fromJson(needs.set-build.outputs.build) }}
+    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
+        with:
+          need-nextest: true
+          need-protoc: true
+          need-rocksdb: true
+          github-token: ${{ secrets.GITHUB_TOKEN }}
+
+      # TODO: 1password is only supported on linux
+      #
+      # Waiting for https://github.com/1Password/load-secrets-action/issues/46
+      - name: Setup 1Password Connect
+        if: runner.os == 'Linux'
+        uses: 1password/load-secrets-action/configure@v1
+        with:
+          connect-host: ${{ secrets.OP_CONNECT_HOST }}
+          connect-token: ${{ secrets.OP_CONNECT_TOKEN }}
+      - name: Setup Target (Linux/macOS)
+        if: runner.os != 'Windows'
+        env:
+          TARGET: ${{ matrix.build.target }}
+        run: rustup target add $TARGET
+      - name: Setup Target (Windows)
+        if: runner.os == 'Windows'
+        env:
+          TARGET: ${{ matrix.build.target }}
+        run: |
+          rustup target add $env:TARGET
+      - uses: actions/setup-go@v5
+        with:
+          go-version: stable
+      - uses: actions/setup-python@v5
+        with:
+          python-version: "3.10"
+      - name: Setup Service
+        env:
+          OPENDAL_FEATURES: "layers-blocking,${{ matrix.cases.feature }}"
+        run: |
+          python -m pip install toml
+          python tools/.github/scripts/setup_features.py
+      - name: Install dependencies (Linux)
+        if: ${{ matrix.build.os == 'ubuntu-latest' }}
+        run: sudo apt install zstd
+      - name: Install dependencies (macOS)
+        if: ${{ matrix.build.os == 'macos-latest' }}
+        run: brew install zstd libffi
+      - name: Install dependencies (Windows)
+        if: ${{ matrix.build.os == 'windows-latest' }}
+        uses: ilammy/msvc-dev-cmd@v1
+      - name: Build C Binding (Linux/macOS)
+        working-directory: bindings/c
+        if: runner.os != 'Windows'
+        env:
+          VERSION: "latest"
+          SERVICE: ${{ matrix.cases.service }}
+          TARGET: ${{ matrix.build.target }}
+          CC: ${{ matrix.build.cc }}
+          OS: ${{ inputs.os }}
+        run: |
+          cargo build --target $TARGET --release
+          DIR=$GITHUB_WORKSPACE/libopendal_c_${VERSION}_${SERVICE}_$TARGET
+          mkdir $DIR
+          if [ ${OS} == 'ubuntu-latest' ]; then
+            SO=so
+          else
+            SO=dylib
+          fi
+          zstd -19 ./target/$TARGET/release/libopendal_c.$SO -o 
$DIR/libopendal_c.$TARGET.$SO.zst
+      - name: Build C Binding (Windows)
+        working-directory: bindings/c
+        if: runner.os == 'Windows'
+        env:
+          VERSION: "latest"
+          SERVICE: ${{ matrix.cases.service }}
+          TARGET: ${{ matrix.build.target }}
+          CC: ${{ matrix.build.cc }}
+        run: |
+          cargo build --target $env:TARGET --release
+          
$DIR="$env:GITHUB_WORKSPACE\libopendal_c_${env:VERSION}_${env:SERVICE}_${env:TARGET}"
+          Rename-Item -Path "./target/$env:TARGET/release/opendal_c.dll" 
-NewName "libopendal_c.dll"
+          New-Item -ItemType Directory -Force -Path $DIR
+          zstd -19 "./target/${env:TARGET}/release/libopendal_c.dll" -o 
"$DIR/libopendal_c.${env:TARGET}.dll.zst"
+        - name: Build Go Artifact
+          working-directory: tools/internal/generate
+          env:
+            MATRIX: '{"build": [${{ toJson(matrix.build) }}], "service": ["${{ 
matrix.cases.service }}"]}'
+            VERSION: "latest"
+      - name: Setup Go Workspace (Linux/macOS)
+        env:
+          SERVICE: ${{ matrix.cases.service }}
+        working-directory: bindings/go/tests
+        if: runner.os != 'Windows'
+        run: |
+          go work init
+          go work use ..
+          go work use ./behavior_tests
+          go work use $GITHUB_WORKSPACE/$(echo $SERVICE | sed 's/-/_/g')
+      - name: Setup Go Workspace (Windows)
+        env:
+          SERVICE: ${{ matrix.cases.service }}
+        working-directory: bindings/go/tests
+        if: runner.os == 'Windows'
+        run: |
+          go work init
+          go work use ..
+          go work use ./behavior_tests
+          go work use $env:GITHUB_WORKSPACE/$($env:SERVICE -replace '-','_')
+      - name: Run tests (Linux/macOS)
+        env:
+          OPENDAL_TEST: ${{ matrix.cases.service }}
+          OPENDAL_FS_ROOT: runner.temp
+        working-directory: bindings/go/tests/behavior_tests
+        if: runner.os != 'Windows'
+        run: |
+          if [ ${{ matrix.build.os }} == 'macos-latest' ]; then
+            export 
DYLD_FALLBACK_LIBRARY_PATH=$DYLD_FALLBACK_LIBRARY_PATH:/opt/homebrew/opt/libffi/lib
+          fi
+          CGO_ENABLE=0 go test -v -run TestBehavior
+      - name: Run tests (Windows)
+        env:
+          OPENDAL_TEST: ${{ matrix.cases.service }}
+          OPENDAL_FS_ROOT: runner.temp
+        working-directory: bindings/go/tests/behavior_tests
+        if: runner.os == 'Windows'
+        run: |
+          $env:CGO_ENABLE = "0"
+          go test -v -run TestBehavior
+

Reply via email to