-
Notifications
You must be signed in to change notification settings - Fork 11
123 lines (104 loc) · 3.43 KB
/
go-test.yml
File metadata and controls
123 lines (104 loc) · 3.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# Copyright 2025 The PECOS Developers
#
# Licensed 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
#
# https://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: Go test
env:
TRIGGER_ON_PR_PUSH: true # Set to true to enable triggers on PR pushes
RUSTFLAGS: -C debuginfo=0
RUST_BACKTRACE: 1
on:
push:
branches: [ "main", "master", "development", "dev" ]
pull_request:
branches: [ "main", "master", "development", "dev" ]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
go-test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
go-version: ["stable"] # Latest stable (experimental bindings)
steps:
- uses: actions/checkout@v6
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go-version }}
- name: Set up Rust
run: rustup show
- name: Cache Rust
uses: Swatinem/rust-cache@v2
with:
workspaces: go/pecos-go-ffi
- name: Set up Visual Studio environment on Windows
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64
- name: Build Rust FFI library (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
cd go/pecos-go-ffi
cargo build --release
- name: Build Rust FFI library (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
# On macOS, prevent Homebrew library paths from being used during linking
if [[ "${{ runner.os }}" == "macOS" ]]; then
# CRITICAL: Prevent Homebrew library paths from being used during linking
# This fixes the "@rpath/libunwind.1.dylib" runtime error on macOS
# Reference: https://github.com/rust-lang/rust/issues/135372
unset LIBRARY_PATH
unset LD_LIBRARY_PATH
unset DYLD_LIBRARY_PATH
unset DYLD_FALLBACK_LIBRARY_PATH
unset PKG_CONFIG_PATH
export LIBRARY_PATH=/usr/lib
echo "RUSTFLAGS: $RUSTFLAGS"
fi
cd go/pecos-go-ffi
cargo build --release
- name: Run Go tests (Unix)
if: runner.os != 'Windows'
run: |
cd go/pecos
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${{ github.workspace }}/target/release \
DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:${{ github.workspace }}/target/release \
go test -v
- name: Run Go tests (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$env:PATH = "${{ github.workspace }}\target\release;$env:PATH"
cd go/pecos
go test -v
- name: Check Go formatting
run: |
cd go/pecos
if [ -n "$(gofmt -l .)" ]; then
echo "Formatting issues found:"
gofmt -l .
exit 1
fi
echo "All Go code is properly formatted."
- name: Run Go vet
run: |
cd go/pecos
go vet ./...