feat: sync Sonar rule suppressions across SonarCloud, Codacy, and local builds

This commit is contained in:
Miha Kralj
2026-01-26 15:57:45 -08:00
parent 480715f66f
commit 4652df360f
3 changed files with 91 additions and 101 deletions
-100
View File
@@ -817,103 +817,3 @@ jobs:
# ==============================================================================
Codacy_Upload:
needs: [ReSharper_Analysis, Snyk_Scan, Semgrep_Scan, Sonar_Analysis, Codacy_Rule_Sync]
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
actions: read
if: always()
steps:
- name: Check for Codacy token
id: check_token
env:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
run: |
if [ -z "${CODACY_PROJECT_TOKEN:-}" ]; then
echo "CODACY_PROJECT_TOKEN not set. Skipping Codacy uploads."
echo "skip=true" >> "$GITHUB_OUTPUT"
else
echo "skip=false" >> "$GITHUB_OUTPUT"
fi
- name: Download SARIF artifacts
if: steps.check_token.outputs.skip != 'true'
uses: actions/download-artifact@v4
with:
pattern: sarif-*
path: sarif
- name: Download Coverage Reports
if: steps.check_token.outputs.skip != 'true'
uses: actions/download-artifact@v4
with:
name: coverage-reports
path: coverage-merged
- name: List artifacts
if: steps.check_token.outputs.skip != 'true'
run: |
echo "SARIF files:"
find sarif -name "*.sarif" -type f -maxdepth 4 -print -exec ls -lh {} \; || true
echo ""
echo "Coverage files:"
ls -la coverage-merged || true
- name: Install Codacy CLI v2
if: steps.check_token.outputs.skip != 'true'
run: |
set -euo pipefail
# Install Codacy CLI using official bootstrap script
echo "Installing Codacy CLI v2..."
sudo curl -Ls https://raw.githubusercontent.com/codacy/codacy-cli-v2/main/codacy-cli.sh -o /usr/local/bin/codacy-cli
sudo chmod +x /usr/local/bin/codacy-cli
# Script will fetch binary if needed
codacy-cli version
- name: Upload SARIF files to Codacy
if: steps.check_token.outputs.skip != 'true'
env:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
run: |
set -euo pipefail
shopt -s nullglob globstar
files=(sarif/**/*.sarif)
if [ ${#files[@]} -eq 0 ]; then
echo "No SARIF files found. Nothing to upload."
exit 0
fi
echo "Uploading ${#files[@]} SARIF file(s) to Codacy with commit: ${COMMIT_UUID}"
for sarif_file in "${files[@]}"; do
echo "--- Uploading: $sarif_file ---"
# Using short flags per codacy-cli-v2 docs:
# -s: SARIF file path
# -c: commit UUID
# -t: project token
codacy-cli upload \
-s "$sarif_file" \
-c "$COMMIT_UUID" \
-t "$CODACY_PROJECT_TOKEN" \
|| echo "WARNING: failed to upload $sarif_file"
done
- name: Upload Coverage to Codacy
if: steps.check_token.outputs.skip != 'true'
env:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
run: |
set -euo pipefail
curl -Ls https://coverage.codacy.com/get.sh -o codacy-coverage.sh
chmod +x codacy-coverage.sh
if [ -f "coverage-merged/Cobertura.xml" ]; then
./codacy-coverage.sh report -r "coverage-merged/Cobertura.xml"
else
echo "Cobertura.xml not found. Skipping coverage upload."
fi