diff --git a/.github/workflows/jscpd.yml b/.github/workflows/jscpd.yml index 70559675861..47d6eef4528 100644 --- a/.github/workflows/jscpd.yml +++ b/.github/workflows/jscpd.yml @@ -50,27 +50,12 @@ jobs: - name: List generated files (debug) run: ls -l - - name: Parse jscpd report and set output - id: parse-report + - name: Filter jscpd report for changed files run: | if [ ! -f ./jscpd-report.json ]; then echo "jscpd-report.json not found" exit 1 fi - DUPLICATIONS=$(jq '.duplicates | length' ./jscpd-report.json) - if [ "$DUPLICATIONS" -gt 0 ]; then - COMMENT="Found $DUPLICATIONS duplications in the codebase:\n\n" - while read -r file; do - COMMENT+=$(jq -r --arg file "$file" '.duplicates[] | select(.firstFile == $file or .secondFile == $file) | "- `\(.firstFile):\(.lines[0])-\(.lines[1])` duplicated in `\(.secondFile):\(.lines[0])-\(.lines[1])`"' ./jscpd-report.json) - done < js_files.txt - if [ -z "$COMMENT" ]; then - echo "No duplications found in changed files." - exit 0 - fi - echo "comment<> $GITHUB_ENV - echo "$COMMENT" >> $GITHUB_ENV - echo "EOF" >> $GITHUB_ENV - exit 1 - else - echo "No duplications found." - fi + echo "Filtering jscpd report for changed files..." + jq -r '.duplicates[] | select(.firstFile as $file | $file | index(inputs)) or select(.secondFile as $file | $file | index(inputs))' ./jscpd-report.json js_files.txt > filtered-jscpd-report.json + cat filtered-jscpd-report.json