diff --git a/.github/scripts/test_go_binding/matrix.yaml b/.github/scripts/test_go_binding/matrix.yaml index b64fa19b6a21..f7a35444135a 100644 --- a/.github/scripts/test_go_binding/matrix.yaml +++ b/.github/scripts/test_go_binding/matrix.yaml @@ -26,6 +26,10 @@ build: goos: "darwin" goarch: "arm64" os: "macos-latest" + - target: "x86_64-pc-windows-msvc" + cc: "cl.exe" + goos: "windows" + goarch: "amd64" + os: "windows-latest" service: - "fs" - diff --git a/.github/workflows/ci_bindings_go.yml b/.github/workflows/ci_bindings_go.yml index 2264e18fa9e6..6c55bf0bedbb 100644 --- a/.github/workflows/ci_bindings_go.yml +++ b/.github/workflows/ci_bindings_go.yml @@ -30,6 +30,7 @@ on: - "core/**" - "bindings/c/**" - "bindings/go/**" + - ".github/scripts/test_go_binding/matrix.yaml" - ".github/workflows/ci_bindings_go.yml" workflow_dispatch: @@ -82,10 +83,17 @@ jobs: path: "tools" - name: Setup Rust toolchain uses: ./.github/actions/setup - - name: Setup Target + - name: Setup Target (Linux/Mac) + 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 @@ -101,11 +109,15 @@ jobs: - name: Install dependencies (Linux) if: ${{ matrix.build.os == 'ubuntu-latest' }} run: sudo apt install zstd - - name: Install dependencies (macOS) + - name: Install dependencies (MacOS) if: ${{ matrix.build.os == 'macos-latest' }} run: brew install zstd libffi - - name: Build C Binding + - 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.service }} @@ -113,7 +125,7 @@ jobs: CC: ${{ matrix.build.cc }} OS: ${{ matrix.build.os }} run: | - cargo build --target $TARGET --release + cargo build --target $TARGET --release DIR=$GITHUB_WORKSPACE/libopendal_c_${VERSION}_${SERVICE}_$TARGET mkdir $DIR if [ ${OS} == 'ubuntu-latest' ]; then @@ -122,6 +134,21 @@ jobs: SO=dylib fi zstd -19 ./target/$TARGET/release/libopendal_c.$SO -o $DIR/libopendal_c.$TARGET.$SO.zst + - name: Build and Package (Windows) + working-directory: bindings/c + if: runner.os == 'Windows' + env: + VERSION: "latest" + SERVICE: ${{ matrix.service }} + TARGET: ${{ matrix.build.target }} + CC: ${{ matrix.build.cc }} + OS: ${{ matrix.build.os }} + 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: @@ -138,13 +165,24 @@ jobs: go work use .. go work use ./behavior_tests go work use $GITHUB_WORKSPACE/$(echo $SERVICE | sed 's/-/_/g') - - name: Run tests + - name: Run tests (Linux/MacOS) env: OPENDAL_TEST: ${{ matrix.service }} OPENDAL_FS_ROOT: "/tmp/opendal/" 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.service }} + OPENDAL_FS_ROOT: "/tmp/opendal/" + working-directory: bindings/go/tests/behavior_tests + if: runner.os == 'Windows' + run: | + $env:CGO_ENABLE = "0" + go test -v -run TestBehavior +