mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-07-27 17:27:43 +00:00
fix: restore truncated Codacy_Upload job in workflow
This commit is contained in:
@@ -817,3 +817,103 @@ 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
|
||||
|
||||
Reference in New Issue
Block a user