Skip to content

Commit

Permalink
ci(bindings/go): support Darwin
Browse files Browse the repository at this point in the history
Signed-off-by: Hanchin Hsieh <[email protected]>
  • Loading branch information
yuchanns committed Nov 19, 2024
1 parent 53c7122 commit d5b0969
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
7 changes: 6 additions & 1 deletion .github/scripts/test_go_binding/matrix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@
# 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"
os: "ubuntu-latest"
- target: "aarch64-apple-darwin"
cc: "clang"
goos: "darwin"
goarch: "arm64"
os: "macos-latest"
service:
- "fs"

25 changes: 20 additions & 5 deletions .github/workflows/ci_bindings_go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
test:
needs: [ matrix ]
runs-on: ${{ matrix.os }}
runs-on: ${{ matrix.build.os }}
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
Expand Down Expand Up @@ -98,23 +98,34 @@ jobs:
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: Build C Binding
working-directory: bindings/c
env:
VERSION: "latest"
SERVICE: ${{ matrix.service }}
TARGET: ${{ matrix.build.target }}
CC: ${{ matrix.build.cc }}
OS: ${{ matrix.build.os }}
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
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 Go Artifact
working-directory: tools/internal/generate
env:
MATRIX: ${{ needs.matrix.outputs.matrix }}
MATRIX: '{"build": [${{ toJson(matrix.build) }}], "service": ["${{ matrix.service }}"]}'
VERSION: "latest"
run: |
go run generate.go
Expand All @@ -132,4 +143,8 @@ jobs:
OPENDAL_TEST: ${{ matrix.service }}
OPENDAL_FS_ROOT: "/tmp/opendal/"
working-directory: bindings/go/tests/behavior_tests
run: CGO_ENABLE=0 go test -v -run TestBehavior
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
1 change: 0 additions & 1 deletion bindings/go/tests/behavior_tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ go 1.22.5

require (
github.com/apache/opendal-go-services/fs v0.1.3
github.com/apache/opendal-go-services/memory v0.1.3
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
Expand Down
2 changes: 0 additions & 2 deletions bindings/go/tests/behavior_tests/opendal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,13 @@ import (
"testing"

"github.com/apache/opendal-go-services/fs"
"github.com/apache/opendal-go-services/memory"
opendal "github.com/apache/opendal/bindings/go"
"github.com/google/uuid"
"github.com/stretchr/testify/require"
)

// Add more schemes for behavior tests here.
var schemes = []opendal.Scheme{
memory.Scheme,
fs.Scheme,
}

Expand Down

0 comments on commit d5b0969

Please sign in to comment.