Skip to content

Commit 082bf7c

Browse files
committed
update ci
1 parent cb0cce4 commit 082bf7c

File tree

1 file changed

+127
-63
lines changed

1 file changed

+127
-63
lines changed

.github/workflows/ci.yml

Lines changed: 127 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -2,93 +2,157 @@ name: Build and Test
22

33
on:
44
push:
5-
branches: [ master, main ]
5+
branches: [ master ]
66
pull_request:
7-
branches: [ master, main ]
7+
branches: [ master ]
88

99
jobs:
1010
test:
11-
name: Test
12-
runs-on: ubuntu-latest
13-
11+
strategy:
12+
max-parallel: 1
13+
matrix:
14+
include:
15+
- os: ubuntu-latest
16+
go-version: '1.25'
17+
arch: x64
18+
- os: windows-latest
19+
go-version: '1.25'
20+
arch: x64
21+
- os: macos-13 # Intel-based macOS runner
22+
go-version: '1.25'
23+
arch: x64
24+
runs-on: ${{ matrix.os }}
25+
1426
steps:
15-
- name: Checkout code
16-
uses: actions/checkout@v4
27+
- uses: actions/checkout@v4
1728

18-
- name: Set up Go
29+
- name: Setup Go
1930
uses: actions/setup-go@v4
2031
with:
21-
go-version: '1.25'
22-
23-
- name: Cache Go modules
24-
uses: actions/cache@v3
25-
with:
26-
path: ~/go/pkg/mod
27-
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
28-
restore-keys: |
29-
${{ runner.os }}-go-
32+
go-version: ${{ matrix.go-version }}
3033

31-
- name: Download RTI Connector libraries
34+
- name: Install system dependencies (Linux)
35+
if: runner.os == 'Linux'
3236
run: |
33-
go run github.com/rticommunity/rticonnextdds-connector-go/cmd/download-libs@latest
37+
sudo apt-get update
38+
sudo apt-get install -y build-essential curl unzip bc
3439
35-
- name: Set library path
40+
- name: Install system dependencies (Windows)
41+
if: runner.os == 'Windows'
3642
run: |
37-
echo "LD_LIBRARY_PATH=$(pwd)/rticonnextdds-connector/lib/linux-x64:$LD_LIBRARY_PATH" >> $GITHUB_ENV
38-
39-
- name: Run tests
40-
run: go test -v ./...
41-
42-
- name: Build Telegraf (standard)
43-
run: go build ./cmd/telegraf
44-
45-
- name: Build Telegraf with DDS support
46-
run: go build -tags dds ./cmd/telegraf
47-
48-
- name: Verify DDS plugin is available
49-
run: ./telegraf --input-list | grep dds_consumer
50-
51-
- name: Test DDS configuration syntax
52-
run: ./telegraf --config plugins/inputs/dds_consumer/example_telegraf.conf --test
53-
54-
build-matrix:
55-
name: Build Matrix
56-
runs-on: ${{ matrix.os }}
57-
strategy:
58-
matrix:
59-
os: [ubuntu-latest, macos-latest, windows-latest]
60-
go-version: ['1.25']
61-
62-
steps:
63-
- name: Checkout code
64-
uses: actions/checkout@v4
65-
66-
- name: Set up Go
67-
uses: actions/setup-go@v4
68-
with:
69-
go-version: ${{ matrix.go-version }}
43+
choco install make
44+
choco install mingw
7045
7146
- name: Download RTI Connector libraries
7247
run: |
7348
go run github.com/rticommunity/rticonnextdds-connector-go/cmd/download-libs@latest
7449
75-
- name: Set library path (Linux)
50+
- name: Verify library installation (Linux)
7651
if: runner.os == 'Linux'
7752
run: |
78-
echo "LD_LIBRARY_PATH=$(pwd)/rticonnextdds-connector/lib/linux-x64:$LD_LIBRARY_PATH" >> $GITHUB_ENV
53+
ls -la rticonnextdds-connector/lib/
54+
echo "Library files in linux-x64:"
55+
ls -la rticonnextdds-connector/lib/linux-x64/ || echo "linux-x64 directory not found"
56+
57+
- name: Verify library installation (Windows)
58+
if: runner.os == 'Windows'
59+
run: |
60+
dir rticonnextdds-connector\lib\
61+
echo "Library files in win-x64:"
62+
dir rticonnextdds-connector\lib\win-x64\ || echo "win-x64 directory not found"
7963
80-
- name: Set library path (macOS)
64+
- name: Verify library installation (macOS)
8165
if: runner.os == 'macOS'
8266
run: |
83-
echo "DYLD_LIBRARY_PATH=$(pwd)/rticonnextdds-connector/lib/osx-x64:$DYLD_LIBRARY_PATH" >> $GITHUB_ENV
67+
ls -la rticonnextdds-connector/lib/
68+
echo "Library files in osx-x64:"
69+
ls -la rticonnextdds-connector/lib/osx-x64/ || echo "osx-x64 directory not found"
70+
71+
- name: Install dependencies
72+
run: |
73+
go get -v -t -d ./...
74+
go mod tidy
75+
76+
- name: Build Telegraf (Unix)
77+
if: runner.os != 'Windows'
78+
run: |
79+
echo "🔨 Building Telegraf on ${{ runner.os }}..."
80+
if ! go build -tags dds -o telegraf ./cmd/telegraf; then
81+
echo "❌ Build failed. Checking library installation..."
82+
echo "RTI Connector directory contents:"
83+
find rticonnextdds-connector -type f -name "*.so" -o -name "*.dylib" -o -name "*.dll" 2>/dev/null || echo "No library files found"
84+
echo "CGO environment:"
85+
go env CGO_ENABLED
86+
exit 1
87+
fi
88+
echo "✅ Build successful on ${{ runner.os }}"
89+
shell: bash
90+
91+
- name: Build Telegraf (Windows)
92+
if: runner.os == 'Windows'
93+
run: |
94+
Write-Host "Building Telegraf on Windows..."
95+
go build -tags dds -o telegraf.exe ./cmd/telegraf
96+
if ($LASTEXITCODE -ne 0) {
97+
Write-Host "Build failed. Checking library installation..."
98+
Write-Host "RTI Connector directory contents:"
99+
if (Test-Path "rticonnextdds-connector") {
100+
Get-ChildItem -Recurse rticonnextdds-connector -Include "*.dll", "*.lib" | Select-Object FullName
101+
} else {
102+
Write-Host "Directory not found"
103+
}
104+
Write-Host "CGO environment:"
105+
go env CGO_ENABLED
106+
exit 1
107+
}
108+
Write-Host "Build successful on Windows"
109+
shell: powershell
110+
111+
- name: Verify DDS plugin is available (Unix)
112+
if: runner.os != 'Windows'
113+
run: |
114+
echo "Verifying DDS consumer plugin is available..."
115+
./telegraf --input-list | grep dds_consumer
84116
85-
- name: Set library path (Windows)
117+
- name: Verify DDS plugin is available (Windows)
86118
if: runner.os == 'Windows'
87119
run: |
88-
echo "PATH=$(pwd)/rticonnextdds-connector/lib/win-x64;$env:PATH" >> $env:GITHUB_ENV
120+
Write-Host "Verifying DDS consumer plugin is available..."
121+
.\telegraf.exe --input-list | Select-String "dds_consumer"
122+
shell: powershell
89123

90-
- name: Build Telegraf with DDS support
91-
run: go build -tags dds ./cmd/telegraf
124+
- name: Test DDS configuration (Unix)
125+
if: runner.os != 'Windows'
126+
run: |
127+
echo "Testing DDS configuration syntax..."
128+
./telegraf --config plugins/inputs/dds_consumer/example_telegraf.conf --test
92129
93-
- name: Verify DDS plugin is available
94-
run: ./telegraf --input-list | grep dds_consumer
130+
- name: Test DDS configuration (Windows)
131+
if: runner.os == 'Windows'
132+
run: |
133+
Write-Host "Testing DDS configuration syntax..."
134+
$libPath = Join-Path $PWD "rticonnextdds-connector\lib\win-x64"
135+
$env:PATH = "$libPath;$env:PATH"
136+
.\telegraf.exe --config plugins\inputs\dds_consumer\example_telegraf.conf --test
137+
shell: powershell
138+
139+
- name: Run basic tests (Unix)
140+
if: runner.os != 'Windows'
141+
run: |
142+
echo "Running basic tests..."
143+
if [ "${{ runner.os }}" = "Linux" ]; then
144+
export LD_LIBRARY_PATH="$(pwd)/rticonnextdds-connector/lib/linux-x64:$LD_LIBRARY_PATH"
145+
elif [ "${{ runner.os }}" = "macOS" ]; then
146+
export DYLD_LIBRARY_PATH="$(pwd)/rticonnextdds-connector/lib/osx-x64:$DYLD_LIBRARY_PATH"
147+
fi
148+
go test -tags dds -v ./plugins/inputs/dds_consumer/...
149+
shell: bash
150+
151+
- name: Run basic tests (Windows)
152+
if: runner.os == 'Windows'
153+
run: |
154+
Write-Host "Running basic tests..."
155+
$libPath = Join-Path $PWD "rticonnextdds-connector\lib\win-x64"
156+
$env:PATH = "$libPath;$env:PATH"
157+
go test -tags dds -v ./plugins/inputs/dds_consumer/...
158+
shell: powershell

0 commit comments

Comments
 (0)