Skip to content

Commit

Permalink
Update jscpd.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
patmmccann authored Jun 8, 2024
1 parent ebe1320 commit a8327e6
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions .github/workflows/jscpd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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<<EOF" >> $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

0 comments on commit a8327e6

Please sign in to comment.