@@ -26,33 +26,14 @@ jobs:
2626
2727 - name : Run plugin tests
2828 run : |
29- run_test() {
30- local tool=$1
31- local jq_filter=$2
32- echo "Running $tool tests..."
33- # Store the path to the CLI
34- CLI_PATH="$(pwd)/cli-v2"
35- # Change to test directory
36- cd plugins/tools/$tool/test/src
37- # Install the plugin
38- "$CLI_PATH" install
39- # Run analysis
40- "$CLI_PATH" analyze --tool $tool --format sarif --output actual.sarif
41- # Convert absolute paths to relative paths in the output
42- sed -i 's|file:///home/runner/work/codacy-cli-v2/codacy-cli-v2/|file:///|g' actual.sarif
43- # Compare with expected output
44- jq --sort-keys "$jq_filter" expected.sarif > expected.sorted.json
45- jq --sort-keys "$jq_filter" actual.sarif > actual.sorted.json
46- diff expected.sorted.json actual.sorted.json
47- # Go back to root directory
48- cd ../../../../..
49- }
50-
51- # Run Pylint tests with simple sorting
52- run_test "pylint" "."
53-
54- # Run Semgrep tests with rules sorting
55- run_test "semgrep" ".runs[0].tool.driver.rules |= if . then sort_by(.id) else . end"
56-
57- # Run PMD tests with rules sorting
58- run_test "pmd" ".runs[0].tool.driver.rules |= if . then sort_by(.id) else . end"
29+ # Make the script executable
30+ chmod +x run-tool-tests.sh
31+
32+ # Run tests for each tool directory
33+ for tool_dir in plugins/tools/*/; do
34+ tool_name=$(basename "$tool_dir")
35+ if [ -d "$tool_dir/test/src" ]; then
36+ echo "Running tests for $tool_name..."
37+ ./run-tool-tests.sh "$tool_name"
38+ fi
39+ done
0 commit comments