@@ -34,9 +34,19 @@ cd "$TOOL_DIR"
3434" $CLI_PATH " analyze --tool $TOOL_NAME --format sarif --output actual.sarif
3535
3636# Convert absolute paths to relative paths in the output
37- # Handle both path formats: with and without extra codacy-cli-v2
38- sed -i ' s|file:///home/runner/work/codacy-cli-v2/|file:///|g' actual.sarif
39- sed -i ' s|file:///Users/runner/work/codacy-cli-v2/|file:///|g' actual.sarif
37+ if [[ " $OSTYPE " == " darwin" * ]]; then
38+ # macOS
39+ sed -i ' ' ' s|file:///Users/runner/work/codacy-cli-v2/|file:///|g' actual.sarif
40+ elif [[ " $OSTYPE " == " msys" * ]] || [[ " $OSTYPE " == " cygwin" * ]]; then
41+ # Windows (Git Bash or Cygwin)
42+ sed -i ' s|file:///D:/a/codacy-cli-v2/|file:///|g' actual.sarif
43+ sed -i ' s|file:///C:/Users/runner/work/codacy-cli-v2/|file:///|g' actual.sarif
44+ # Convert Windows paths to forward slashes
45+ sed -i ' s|\\|/|g' actual.sarif
46+ else
47+ # Linux
48+ sed -i ' s|file:///home/runner/work/codacy-cli-v2/|file:///|g' actual.sarif
49+ fi
4050
4151# Debug information
4252echo " Current directory: $( pwd) "
@@ -48,10 +58,24 @@ jq --sort-keys 'if .runs[0].tool.driver.rules == null then . else .runs[0].tool.
4858jq --sort-keys ' if .runs[0].tool.driver.rules == null then . else .runs[0].tool.driver.rules |= sort_by(.id) end' actual.sarif > actual.sorted.json
4959
5060# Normalize paths in both files
51- sed -i ' s|"/home/runner/work/codacy-cli-v2/|"/|g' expected.sorted.json
52- sed -i ' s|"/Users/runner/work/codacy-cli-v2/|"/|g' expected.sorted.json
53- sed -i ' s|"/home/runner/work/codacy-cli-v2/|"/|g' actual.sorted.json
54- sed -i ' s|"/Users/runner/work/codacy-cli-v2/|"/|g' actual.sorted.json
61+ if [[ " $OSTYPE " == " darwin" * ]]; then
62+ # macOS
63+ sed -i ' ' ' s|"/Users/runner/work/codacy-cli-v2/|"/|g' expected.sorted.json
64+ sed -i ' ' ' s|"/Users/runner/work/codacy-cli-v2/|"/|g' actual.sorted.json
65+ elif [[ " $OSTYPE " == " msys" * ]] || [[ " $OSTYPE " == " cygwin" * ]]; then
66+ # Windows (Git Bash or Cygwin)
67+ sed -i ' s|"/D:/a/codacy-cli-v2/|"/|g' expected.sorted.json
68+ sed -i ' s|"/C:/Users/runner/work/codacy-cli-v2/|"/|g' expected.sorted.json
69+ sed -i ' s|"/D:/a/codacy-cli-v2/|"/|g' actual.sorted.json
70+ sed -i ' s|"/C:/Users/runner/work/codacy-cli-v2/|"/|g' actual.sorted.json
71+ # Convert Windows paths to forward slashes
72+ sed -i ' s|\\|/|g' expected.sorted.json
73+ sed -i ' s|\\|/|g' actual.sorted.json
74+ else
75+ # Linux
76+ sed -i ' s|"/home/runner/work/codacy-cli-v2/|"/|g' expected.sorted.json
77+ sed -i ' s|"/home/runner/work/codacy-cli-v2/|"/|g' actual.sorted.json
78+ fi
5579
5680# Run diff and capture its exit code
5781if ! diff expected.sorted.json actual.sorted.json; then
0 commit comments