-
Notifications
You must be signed in to change notification settings - Fork 10
58 lines (49 loc) · 1.74 KB
/
it-test.yml
File metadata and controls
58 lines (49 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
name: plugin it-test
permissions:
contents: write
on:
push:
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21'
cache: true
- name: Build CLI
run: |
go build -o cli-v2 ./cli-v2.go
chmod +x cli-v2
- name: Run plugin tests
run: |
run_test() {
local tool=$1
local jq_filter=$2
echo "Running $tool tests..."
# Store the path to the CLI
CLI_PATH="$(pwd)/cli-v2"
# Change to test directory
cd plugins/tools/$tool/test/src
# Install the plugin
"$CLI_PATH" install
# Run analysis
"$CLI_PATH" analyze --tool $tool --format sarif --output actual.sarif
# Convert absolute paths to relative paths in the output
sed -i 's|file:///home/runner/work/codacy-cli-v2/codacy-cli-v2/|file:///|g' actual.sarif
# Compare with expected output
jq --sort-keys "$jq_filter" expected.sarif > expected.sorted.json
jq --sort-keys "$jq_filter" actual.sarif > actual.sorted.json
diff expected.sorted.json actual.sorted.json
# Go back to root directory
cd ../../../../..
}
# Run Pylint tests with simple sorting
run_test "pylint" "."
# Run Semgrep tests with rules sorting
run_test "semgrep" ".runs[0].tool.driver.rules |= if . then sort_by(.id) else . end"
# Run PMD tests with rules sorting
run_test "pmd" ".runs[0].tool.driver.rules |= if . then sort_by(.id) else . end"