Skip to content

Commit d885d10

Browse files
committed
Refactor script, add wsl
1 parent 622462d commit d885d10

2 files changed

Lines changed: 110 additions & 42 deletions

File tree

.github/workflows/it-test.yml

Lines changed: 30 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ jobs:
7070

7171
- name: Run init tests on Windows
7272
if: matrix.os == 'windows-latest'
73+
id: run_init_tests_windows
74+
continue-on-error: true
7375
shell: pwsh
7476
run: |
7577
$ErrorActionPreference = "Stop"
@@ -92,55 +94,41 @@ jobs:
9294
chmod +x integration-tests/run.sh
9395
./integration-tests/run.sh
9496
95-
- name: Run tool tests
97+
- name: Run tool tests on Unix
9698
if: matrix.os != 'windows-latest'
97-
id: run_tests
98-
continue-on-error: true
99-
shell: bash
100-
run: |
101-
# Make the script executable
102-
chmod +x run-tool-tests.sh
103-
104-
# Initialize failed tools file
105-
rm -f /tmp/failed_tools.txt
106-
touch /tmp/failed_tools.txt
107-
108-
# Run tests for each tool directory
109-
for tool_dir in plugins/tools/*/; do
110-
tool_name=$(basename "$tool_dir")
111-
if [ -d "$tool_dir/test/src" ]; then
112-
echo "Running tests for $tool_name..."
113-
./run-tool-tests.sh "$tool_name" || {
114-
echo "❌ Test failed for $tool_name"
115-
echo "$tool_name" >> /tmp/failed_tools.txt
116-
}
117-
fi
118-
done
119-
120-
# Check if any tools failed
121-
if [ -s /tmp/failed_tools.txt ] && [ "$(wc -l < /tmp/failed_tools.txt)" -gt 0 ]; then
122-
echo -e "\n❌ The following tools failed their tests:"
123-
cat /tmp/failed_tools.txt
124-
echo "::error::Some tool tests failed. Please check the logs above for details."
125-
exit 1
126-
else
127-
echo "✅ All tool tests passed successfully!"
128-
fi
99+
uses: ./.github/workflows/tool-tests.yml
100+
with:
101+
shell: bash
102+
103+
- name: Run tool tests on Windows
104+
if: matrix.os == 'windows-latest'
105+
uses: ./.github/workflows/tool-tests.yml
106+
with:
107+
shell: wsl
129108

130109
- name: Check test results
131110
if: always()
132111
shell: bash
133112
run: |
134113
# Check init tests
135-
if [ "${{ steps.run_init_tests_unix.outcome }}" = "failure" ]; then
136-
echo "::error::Init tests failed"
137-
FAILED=true
138-
fi
139-
140-
# Check tool tests
141-
if [ "${{ steps.run_tests.outcome }}" = "failure" ]; then
142-
echo "::error::Tool tests failed"
143-
FAILED=true
114+
if [ "${{ matrix.os }}" = "windows-latest" ]; then
115+
if [ "${{ steps.run_init_tests_windows.outcome }}" = "failure" ]; then
116+
echo "::error::Windows init tests failed"
117+
FAILED=true
118+
fi
119+
if [ "${{ steps.run_tests_windows.outcome }}" = "failure" ]; then
120+
echo "::error::Windows tool tests failed"
121+
FAILED=true
122+
fi
123+
else
124+
if [ "${{ steps.run_init_tests_unix.outcome }}" = "failure" ]; then
125+
echo "::error::Unix init tests failed"
126+
FAILED=true
127+
fi
128+
if [ "${{ steps.run_tests_unix.outcome }}" = "failure" ]; then
129+
echo "::error::Unix tool tests failed"
130+
FAILED=true
131+
fi
144132
fi
145133
146134
# Fail if any tests failed

.github/workflows/tool-tests.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Tool Tests
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
shell:
7+
required: true
8+
type: string
9+
description: 'Shell to use (bash or wsl)'
10+
11+
jobs:
12+
tool-tests:
13+
runs-on: ${{ matrix.os }}
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set up Go
21+
uses: actions/setup-go@v5
22+
with:
23+
go-version: '1.21'
24+
cache: true
25+
26+
- name: Download CLI binaries
27+
uses: actions/download-artifact@v4
28+
with:
29+
name: cli-binaries
30+
path: .
31+
32+
- name: Select correct binary
33+
shell: bash
34+
run: |
35+
if [ "${{ matrix.os }}" = "windows-latest" ]; then
36+
# Keep the .exe extension for Windows
37+
echo "Using Windows binary with .exe extension"
38+
elif [ "${{ matrix.os }}" = "macos-latest" ]; then
39+
mv cli-v2-macos cli-v2
40+
else
41+
mv cli-v2-linux cli-v2
42+
fi
43+
44+
- name: Make binary executable
45+
if: matrix.os != 'windows-latest'
46+
run: chmod +x cli-v2
47+
48+
- name: Run tool tests
49+
id: run_tests
50+
continue-on-error: true
51+
shell: ${{ inputs.shell }}
52+
run: |
53+
# Make the script executable
54+
chmod +x run-tool-tests.sh
55+
56+
# Initialize failed tools file
57+
rm -f /tmp/failed_tools.txt
58+
touch /tmp/failed_tools.txt
59+
60+
# Run tests for each tool directory
61+
for tool_dir in plugins/tools/*/; do
62+
tool_name=$(basename "$tool_dir")
63+
if [ -d "$tool_dir/test/src" ]; then
64+
echo "Running tests for $tool_name..."
65+
./run-tool-tests.sh "$tool_name" || {
66+
echo "❌ Test failed for $tool_name"
67+
echo "$tool_name" >> /tmp/failed_tools.txt
68+
}
69+
fi
70+
done
71+
72+
# Check if any tools failed
73+
if [ -s /tmp/failed_tools.txt ] && [ "$(wc -l < /tmp/failed_tools.txt)" -gt 0 ]; then
74+
echo -e "\n❌ The following tools failed their tests:"
75+
cat /tmp/failed_tools.txt
76+
echo "::error::Some tool tests failed. Please check the logs above for details."
77+
exit 1
78+
else
79+
echo "✅ All tool tests passed successfully!"
80+
fi

0 commit comments

Comments
 (0)