Skip to content

Commit e707bfe

Browse files
committed
ci(bindings/go): add support for testing in windows
Hanchin Hsieh <[email protected]>
1 parent b943a51 commit e707bfe

File tree

2 files changed

+47
-5
lines changed

2 files changed

+47
-5
lines changed

.github/scripts/test_go_binding/matrix.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ build:
2626
goos: "darwin"
2727
goarch: "arm64"
2828
os: "macos-latest"
29+
- target: "x86_64-pc-windows-msvc"
30+
cc: "cl.exe"
31+
goos: "windows"
32+
goarch: "amd64"
33+
os: "windows-latest"
2934
service:
3035
- "fs"
3136

.github/workflows/ci_bindings_go.yml

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ on:
3131
- "bindings/c/**"
3232
- "bindings/go/**"
3333
- ".github/workflows/ci_bindings_go.yml"
34+
- ".github/scripts/test_go_binding/matrix.yaml"
3435
workflow_dispatch:
3536

3637
concurrency:
@@ -82,10 +83,17 @@ jobs:
8283
path: "tools"
8384
- name: Setup Rust toolchain
8485
uses: ./.github/actions/setup
85-
- name: Setup Target
86+
- name: Setup Target (Linux/macOS)
87+
if: runner.os != 'Windows'
8688
env:
8789
TARGET: ${{ matrix.build.target }}
8890
run: rustup target add $TARGET
91+
- name: Setup Target (Windows)
92+
if: runner.os == 'Windows'
93+
env:
94+
TARGET: ${{ matrix.build.target }}
95+
run: |
96+
rustup target add $env:TARGET
8997
- uses: actions/setup-go@v5
9098
with:
9199
go-version: stable
@@ -104,16 +112,20 @@ jobs:
104112
- name: Install dependencies (macOS)
105113
if: ${{ matrix.build.os == 'macos-latest' }}
106114
run: brew install zstd libffi
107-
- name: Build C Binding
115+
- name: Install dependencies (Windows)
116+
if: ${{ matrix.build.os == 'windows-latest' }}
117+
uses: ilammy/msvc-dev-cmd@v1
118+
- name: Build C Binding (Linux/macOS)
108119
working-directory: bindings/c
120+
if: runner.os != 'Windows'
109121
env:
110122
VERSION: "latest"
111123
SERVICE: ${{ matrix.service }}
112124
TARGET: ${{ matrix.build.target }}
113125
CC: ${{ matrix.build.cc }}
114126
OS: ${{ matrix.build.os }}
115127
run: |
116-
cargo build --target $TARGET --release
128+
cargo build --target $TARGET --release
117129
DIR=$GITHUB_WORKSPACE/libopendal_c_${VERSION}_${SERVICE}_$TARGET
118130
mkdir $DIR
119131
if [ ${OS} == 'ubuntu-latest' ]; then
@@ -122,6 +134,21 @@ jobs:
122134
SO=dylib
123135
fi
124136
zstd -19 ./target/$TARGET/release/libopendal_c.$SO -o $DIR/libopendal_c.$TARGET.$SO.zst
137+
- name: Build C Binding (Windows)
138+
working-directory: bindings/c
139+
if: runner.os == 'Windows'
140+
env:
141+
VERSION: "latest"
142+
SERVICE: ${{ matrix.service }}
143+
TARGET: ${{ matrix.build.target }}
144+
CC: ${{ matrix.build.cc }}
145+
OS: ${{ matrix.build.os }}
146+
run: |
147+
cargo build --target $env:TARGET --release
148+
$DIR="$env:GITHUB_WORKSPACE\libopendal_c_${env:VERSION}_${env:SERVICE}_${env:TARGET}"
149+
Rename-Item -Path "./target/$env:TARGET/release/opendal_c.dll" -NewName "libopendal_c.dll"
150+
New-Item -ItemType Directory -Force -Path $DIR
151+
zstd -19 "./target/${env:TARGET}/release/libopendal_c.dll" -o "$DIR/libopendal_c.${env:TARGET}.dll.zst"
125152
- name: Build Go Artifact
126153
working-directory: tools/internal/generate
127154
env:
@@ -138,13 +165,23 @@ jobs:
138165
go work use ..
139166
go work use ./behavior_tests
140167
go work use $GITHUB_WORKSPACE/$(echo $SERVICE | sed 's/-/_/g')
141-
- name: Run tests
168+
- name: Run tests (Linux/macOS)
142169
env:
143170
OPENDAL_TEST: ${{ matrix.service }}
144-
OPENDAL_FS_ROOT: "/tmp/opendal/"
171+
OPENDAL_FS_ROOT: runner.temp
145172
working-directory: bindings/go/tests/behavior_tests
173+
if: runner.os != 'Windows'
146174
run: |
147175
if [ ${{ matrix.build.os }} == 'macos-latest' ]; then
148176
export DYLD_FALLBACK_LIBRARY_PATH=$DYLD_FALLBACK_LIBRARY_PATH:/opt/homebrew/opt/libffi/lib
149177
fi
150178
CGO_ENABLE=0 go test -v -run TestBehavior
179+
- name: Run tests (Windows)
180+
env:
181+
OPENDAL_TEST: ${{ matrix.service }}
182+
OPENDAL_FS_ROOT: runner.temp
183+
working-directory: bindings/go/tests/behavior_tests
184+
if: runner.os == 'Windows'
185+
run: |
186+
$env:CGO_ENABLE = "0"
187+
go test -v -run TestBehavior

0 commit comments

Comments
 (0)