Skip to content

Commit

Permalink
Merge pull request #7948 from opencrvs/fix/knip-error-swallowed
Browse files Browse the repository at this point in the history
Fix/knip error swallowed
  • Loading branch information
makelicious authored Nov 11, 2024
2 parents 3c6cc37 + 02a96b6 commit 99534e5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 25 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
2 changes: 1 addition & 1 deletion packages/gateway/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"gen:schema:watch": "nodemon --quiet --on-change-only -e graphql -i src/graphql/schema.graphql -x 'yarn gen:schema'",
"gen:types:watch": "nodemon --quiet --on-change-only -w src/graphql/schema.graphql -x 'yarn gen:types'",
"open:cov": "yarn test && opener coverage/index.html",
"lint": "eslint -c .eslintrc.js --fix ./src"
"lint": "eslint -c .eslintrc.js --fix ./src --max-warnings=0"
},
"dependencies": {
"@elastic/elasticsearch": "8.13.1",
Expand Down

0 comments on commit 99534e5

Please sign in to comment.