Skip to content

Commit 88b3c1e

Browse files
committed
Refactor script
1 parent d48f7af commit 88b3c1e

2 files changed

Lines changed: 15 additions & 55 deletions

File tree

.github/actions/tool-tests/action.yml

Lines changed: 10 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,22 @@
11
name: 'Tool Tests'
2-
description: 'Run tool tests with specified shell'
3-
4-
inputs:
5-
shell:
6-
description: 'Shell to use (bash or pwsh)'
7-
required: true
8-
default: 'bash'
2+
description: 'Run tool tests'
93

104
runs:
115
using: "composite"
126
steps:
13-
- name: Run tool tests on Windows
14-
if: inputs.shell == 'pwsh'
15-
shell: pwsh
16-
run: |
17-
Get-ChildItem -Path "plugins/tools" -Directory | ForEach-Object {
18-
$toolDir = $_.FullName
19-
$testDir = Join-Path $toolDir "test"
20-
if (Test-Path $testDir) {
21-
Write-Host "Running tests for $testDir..."
22-
& ./integration-tests/run.ps1 $testDir
23-
if ($LASTEXITCODE -ne 0) {
24-
Add-Content -Path "failed_tests.txt" -Value $testDir
25-
}
26-
}
27-
}
28-
29-
# Check if any tests failed
30-
if (Test-Path "failed_tests.txt" -PathType Leaf) {
31-
Write-Host "The following tests failed:"
32-
Get-Content "failed_tests.txt"
33-
exit 1
34-
}
35-
36-
- name: Run tool tests on Unix
37-
if: inputs.shell == 'bash'
7+
- name: Run tool tests
388
shell: bash
9+
env:
10+
CODACY_API_TOKEN: ${{ env.CODACY_API_TOKEN }}
3911
run: |
40-
chmod +x integration-tests/run.sh
12+
chmod +x run-tool-tests.sh
4113
echo "" > failed_tests.txt
4214
43-
for tool_dir in plugins/tools/*/test; do
44-
if [ -d "$tool_dir" ]; then
45-
echo "Running tests for $tool_dir..."
46-
if ! ./integration-tests/run.sh "$tool_dir"; then
47-
echo "$tool_dir" >> failed_tests.txt
48-
fi
15+
for tool_dir in plugins/tools/*/; do
16+
tool_name=$(basename "$tool_dir")
17+
echo "Running tests for $tool_name..."
18+
if ! ./run-tool-tests.sh "$tool_name"; then
19+
echo "$tool_name" >> failed_tests.txt
4920
fi
5021
done
5122

.github/workflows/it-test.yml

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,45 +68,38 @@ jobs:
6868
if: matrix.os != 'windows-latest'
6969
run: chmod +x cli-v2
7070

71-
- name: Run init tests on Windows native
71+
- name: Run init tests on Windows
7272
if: matrix.os == 'windows-latest'
7373
id: run_init_tests_windows
74-
continue-on-error: true
7574
shell: pwsh
75+
env:
76+
CODACY_API_TOKEN: ${{ secrets.CODACY_API_TOKEN }}
7677
run: |
7778
$ErrorActionPreference = "Stop"
7879
& ./integration-tests/run.ps1
7980
if ($LASTEXITCODE -ne 0) {
8081
Write-Error "Integration tests failed with exit code $LASTEXITCODE"
8182
exit $LASTEXITCODE
8283
}
83-
env:
84-
CODACY_API_TOKEN: ${{ secrets.CODACY_API_TOKEN }}
8584
8685
- name: Run init tests on Unix
8786
if: matrix.os != 'windows-latest'
8887
id: run_init_tests_unix
89-
continue-on-error: true
9088
shell: bash
9189
env:
9290
CODACY_API_TOKEN: ${{ secrets.CODACY_API_TOKEN }}
9391
run: |
9492
chmod +x integration-tests/run.sh
9593
./integration-tests/run.sh
9694
97-
- name: Run tool tests on Windows
98-
if: matrix.os == 'windows-latest'
99-
id: run_tool_tests_windows_wsl
100-
uses: ./.github/actions/tool-tests
101-
with:
102-
shell: pwsh
103-
10495
- name: Run tool tests on Unix
10596
if: matrix.os != 'windows-latest'
10697
id: run_tool_tests_unix
10798
uses: ./.github/actions/tool-tests
10899
with:
109100
shell: bash
101+
env:
102+
CODACY_API_TOKEN: ${{ secrets.CODACY_API_TOKEN }}
110103

111104
- name: Check test results
112105
if: always()
@@ -120,10 +113,6 @@ jobs:
120113
echo "::error::Windows init tests failed"
121114
FAILED=true
122115
fi
123-
if [ "${{ steps.run_tool_tests_windows.outcome }}" = "failure" ]; then
124-
echo "::error::Windows tool tests failed"
125-
FAILED=true
126-
fi
127116
else
128117
if [ "${{ steps.run_init_tests_unix.outcome }}" = "failure" ]; then
129118
echo "::error::Unix init tests failed"

0 commit comments

Comments
 (0)