Skip to content

Commit

Permalink
Merge branch 'develop' into ocrvs-7848
Browse files Browse the repository at this point in the history
  • Loading branch information
naftis authored Nov 11, 2024
2 parents 073aedd + 99534e5 commit 4a9a668
Show file tree
Hide file tree
Showing 5 changed files with 201 additions and 201 deletions.
53 changes: 29 additions & 24 deletions .github/workflows/lint-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,27 +152,30 @@ jobs:
run: |
cat << 'EOF' > knip-reporter.js
const reporter = function (options) {
const totalIssues = Object.values(options.issues).reduce(
(acc, issueRecords) =>
acc + Object.values(issueRecords).reduce(
(acc2, issuesInFile) => acc2 + Object.keys(issuesInFile).length,
0
),
const totalIssues = Object.entries(options.counters).reduce(
(acc, [key, value]) => {
if (options.report[key]) {
return acc + value
}
return acc
},
0
);
console.log(JSON.stringify({ totalIssues }));
};
export default reporter;
)
console.log(JSON.stringify({ totalIssues }))
}
export default reporter
EOF
- name: Run knip on base branch
id: knip_base
run: |
OUTPUT=$(npx knip --no-exit-code --exports --reporter=./knip-reporter.js)
JSON=$(echo "$OUTPUT" | grep -o '{.*}')
total_issues=$(echo "$JSON" | jq '.totalIssues')
echo "Total Issues: $total_issues"
echo "Found $total_issues issue(s) on base branch."
echo "Setting $total_issues issue(s) as max limit for PR branch."
echo "maxIssues=${total_issues}" >> $GITHUB_OUTPUT
echo "Max issues = $maxIssues"
- name: Checkout the PR branch
uses: actions/checkout@v2
Expand All @@ -185,18 +188,20 @@ jobs:
run: |
cat << 'EOF' > knip-reporter.js
const reporter = function (options) {
const totalIssues = Object.values(options.issues).reduce(
(acc, issueRecords) =>
acc + Object.values(issueRecords).reduce(
(acc2, issuesInFile) => acc2 + Object.keys(issuesInFile).length,
0
),
const totalIssues = Object.entries(options.counters).reduce(
(acc, [key, value]) => {
if (options.report[key]) {
return acc + value
}
return acc
},
0
);
console.log(JSON.stringify({ totalIssues }));
};
export default reporter;
)
console.log(JSON.stringify({ totalIssues }))
}
export default reporter
EOF
- name: Run knip on PR branch
run: |
npx knip --max-issues=${{ steps.knip_base.outputs.maxIssues }} --exports --reporter=./knip-reporter.js
run: npx knip --max-issues=${{ steps.knip_base.outputs.maxIssues }} --exports --reporter=./knip-reporter.js
Loading

0 comments on commit 4a9a668

Please sign in to comment.