77 push :
88
99jobs :
10- pylint- test :
10+ test :
1111 runs-on : ubuntu-latest
12- steps :
13- - name : Checkout code
14- uses : actions/checkout@v4
15-
16- - name : Set up Go
17- uses : actions/setup-go@v5
18- with :
19- go-version : ' 1.21'
20- cache : true
21-
22- - name : Build CLI
23- run : |
24- go build -o cli-v2 ./cli-v2.go
25- chmod +x cli-v2
12+ strategy :
13+ matrix :
14+ tool : [pylint, semgrep]
15+ fail-fast : false
2616
27- - name : Run Pylint plugin tests
28- run : |
29- # Store the path to the CLI
30- CLI_PATH="$(pwd)/cli-v2"
31- # Change to test directory
32- cd plugins/tools/pylint/test/src
33- # Install the plugin
34- "$CLI_PATH" install
35- # Run analysis
36- "$CLI_PATH" analyze --tool pylint --format sarif --output actual.sarif
37- # Convert absolute paths to relative paths in the output
38- sed -i 's|file:///home/runner/work/codacy-cli-v2/codacy-cli-v2/|file:///|g' actual.sarif
39- # Compare with expected output
40- jq --sort-keys . expected.sarif > expected.sorted.json
41- jq --sort-keys . actual.sarif > actual.sorted.json
42- diff expected.sorted.json actual.sorted.json
43-
44- semgrep-test :
45- runs-on : ubuntu-latest
4617 steps :
4718 - name : Checkout code
4819 uses : actions/checkout@v4
@@ -58,19 +29,24 @@ jobs:
5829 go build -o cli-v2 ./cli-v2.go
5930 chmod +x cli-v2
6031
61- - name : Run Semgrep plugin tests
32+ - name : Run ${{ matrix.tool }} plugin tests
6233 run : |
6334 # Store the path to the CLI
6435 CLI_PATH="$(pwd)/cli-v2"
6536 # Change to test directory
66- cd plugins/tools/semgrep /test/src
37+ cd plugins/tools/${{ matrix.tool }} /test/src
6738 # Install the plugin
6839 "$CLI_PATH" install
6940 # Run analysis
70- "$CLI_PATH" analyze --tool semgrep --format sarif --output actual.sarif
41+ "$CLI_PATH" analyze --tool ${{ matrix.tool }} --format sarif --output actual.sarif
7142 # Convert absolute paths to relative paths in the output
7243 sed -i 's|file:///home/runner/work/codacy-cli-v2/codacy-cli-v2/|file:///|g' actual.sarif
7344 # Compare with expected output
74- jq --sort-keys '.runs[0].tool.driver.rules |= if . then sort_by(.id) else . end' expected.sarif > expected.sorted.json
75- jq --sort-keys '.runs[0].tool.driver.rules |= if . then sort_by(.id) else . end' actual.sarif > actual.sorted.json
45+ if [ "${{ matrix.tool }}" = "pylint" ]; then
46+ jq --sort-keys . expected.sarif > expected.sorted.json
47+ jq --sort-keys . actual.sarif > actual.sorted.json
48+ else
49+ jq --sort-keys '.runs[0].tool.driver.rules |= if . then sort_by(.id) else . end' expected.sarif > expected.sorted.json
50+ jq --sort-keys '.runs[0].tool.driver.rules |= if . then sort_by(.id) else . end' actual.sarif > actual.sorted.json
51+ fi
7652 diff expected.sorted.json actual.sorted.json
0 commit comments