Skip to content

Commit

Permalink
Update jscpd.yml (#11742)
Browse files Browse the repository at this point in the history
* Update jscpd.yml

* Update 33acrossBidAdapter.js

* Update jscpd.yml

* Update jscpd.yml

* Update jscpd.yml

* Update jscpd.yml

* Update jscpd.yml

* Update jscpd.yml

* Update jscpd.yml

* Update jscpd.yml

* Update jscpd.yml

* Update jscpd.yml

* Update jscpd.yml

* Update jscpd.yml

* Update jscpd.yml

* Update jscpd.yml
  • Loading branch information
patmmccann committed Jun 9, 2024
1 parent 1211c5c commit 990e4e8
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 5 deletions.
59 changes: 55 additions & 4 deletions .github/workflows/jscpd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ jobs:
- name: Get the diff
run: git diff origin/master...HEAD --name-only > changed_files.txt

- name: Filter JavaScript files
run: |
grep -E '\.js$' changed_files.txt | grep -v 'spec.js' > js_files.txt || true
- name: List generated files (debug)
run: ls -l

Expand All @@ -56,3 +52,58 @@ jobs:
with:
name: unfiltered-jscpd-report
path: ./jscpd-report.json

- name: Filter jscpd report for changed files
run: |
if [ ! -f ./jscpd-report.json ]; then
echo "jscpd-report.json not found"
exit 1
fi
echo "Filtering jscpd report for changed files..."
CHANGED_FILES=$(jq -R -s -c 'split("\n")[:-1]' changed_files.txt)
echo "Changed files: $CHANGED_FILES"
jq --argjson changed_files "$CHANGED_FILES" '
.duplicates | map(select(
(.firstFile?.name as $fname | $changed_files | any(. == $fname)) or
(.secondFile?.name as $sname | $changed_files | any(. == $sname))
))
' ./jscpd-report.json > filtered-jscpd-report.json
cat filtered-jscpd-report.json
- name: Check if filtered jscpd report exists
id: check_filtered_report
run: |
if [ -s ./filtered-jscpd-report.json ]; then
echo "filtered_report_exists=true" >> $GITHUB_ENV
else
echo "filtered_report_exists=false" >> $GITHUB_ENV
fi
- name: Upload filtered jscpd report
if: env.filtered_report_exists == 'true'
uses: actions/upload-artifact@v4
with:
name: filtered-jscpd-report
path: ./filtered-jscpd-report.json

- name: Post GitHub comment
if: env.filtered_report_exists == 'true'
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const filteredReport = JSON.parse(fs.readFileSync('filtered-jscpd-report.json', 'utf8'));
let comment = "Whoa there, partner! 🌵🤠 We wrangled some duplicated code in your PR:\n\n";
filteredReport.forEach(duplication => {
const firstFile = duplication.firstFile.name;
const secondFile = duplication.secondFile.name;
const lines = duplication.lines;
comment += `- \`${firstFile}\` has ${lines} duplicated lines with \`${secondFile}\`\n`;
});
comment += "\nReducing code duplication by importing common functions from a library not only makes our code cleaner but also easier to maintain. Keep up the great work! 🚀";
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: comment
});
2 changes: 1 addition & 1 deletion modules/33acrossBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
import {BANNER, VIDEO} from '../src/mediaTypes.js';
import {isSlotMatchingAdUnitCode} from '../libraries/gptUtils/gptUtils.js';

// **************************** UTILS *************************** //
// **************************** UTILS ************************** //
const BIDDER_CODE = '33across';
const BIDDER_ALIASES = ['33across_mgni'];
const END_POINT = 'https://ssc.33across.com/api/v1/hb';
Expand Down

0 comments on commit 990e4e8

Please sign in to comment.