Skip to content

Commit f1c6aeb

Browse files
authored
add knip reports check to CI (#930)
Signed-off-by: Kashish Mittal <kmittal@redhat.com>
1 parent 488852f commit f1c6aeb

17 files changed

Lines changed: 39 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,24 @@ jobs:
9292

9393
- name: prettier
9494
run: yarn prettier:check
95+
96+
- name: read knip-reports flag from bcp.json
97+
id: bcp
98+
run: |
99+
echo "Checking for bcp.json in workspace: workspaces/${{ matrix.workspace }}"
100+
if [ -f bcp.json ]; then
101+
echo "Reading knip-reports flag..."
102+
KNIP_REPORTS=$(jq -r '.["knip-reports"]' bcp.json)
103+
echo "knip-reports value: $KNIP_REPORTS"
104+
echo "knip_reports=$KNIP_REPORTS" >> $GITHUB_OUTPUT
105+
else
106+
echo "bcp.json not found. Defaulting knip_reports to false."
107+
echo "knip_reports=false" >> $GITHUB_OUTPUT
108+
fi
109+
110+
- name: check knip reports
111+
if: ${{ steps.bcp.outputs.knip_reports == 'true' }}
112+
run: yarn build:knip-reports --ci
95113

96114
- name: check api reports and generate API reference
97115
run: yarn build:api-reports:only --ci

CONTRIBUTING.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ The `redhat-developer/rhdh-plugins` repository is designed as a collaborative sp
3131
- [Types of PRs](#types-of-prs)
3232
- [Dependency Updates](#dependency-updates)
3333
- [Security Fixes](#security-fixes)
34+
- [Opt-in to Knip Reports Check](#opt-in-to-knip-reports-check)
3435

3536
## License
3637

@@ -325,3 +326,8 @@ This repository uses [Renovate](https://docs.renovatebot.com/) to automatically
325326
326327
- PRs can also be opened for security alerts. These PRs are distinguishable with a `[security]`suffix in its title and will also have a `security` label.
327328
329+
### Opt-in to Knip Reports Check
330+
331+
Plugin owners can opt in to Knip reports check in CI by creating a `bcp.json` file in the root of their workspace (`workspaces/${WORKSPACE}/.auto-version-bump`) and adding `"knip-reports": true`. This ensures that knip reports in your workspace stay up to date.
332+
333+
[Knip](https://knip.dev/) is a tool that helps with clean-up and maintenance by identifying unused dependencies within workspaces. Regularly reviewing and addressing these reports can significantly improve code quality and reduce bloat.

workspaces/adoption-insights/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"build:api-reports": "yarn build:api-reports:only",
1616
"build:api-reports:only": "backstage-repo-tools api-reports -o ae-wrong-input-file-type,ae-undocumented --validate-release-tags",
1717
"build-image": "yarn workspace backend build-image",
18+
"build:knip-reports": "backstage-repo-tools knip-reports",
1819
"clean": "backstage-cli repo clean",
1920
"test": "backstage-cli repo test",
2021
"test:all": "backstage-cli repo test --coverage",

workspaces/ai-integrations/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"build:all": "backstage-cli repo build --all",
1717
"build:api-reports": "yarn build:api-reports:only --tsc",
1818
"build:api-reports:only": "backstage-repo-tools api-reports -o ae-wrong-input-file-type,ae-undocumented --validate-release-tags",
19+
"build:knip-reports": "backstage-repo-tools knip-reports",
1920
"clean": "backstage-cli repo clean",
2021
"test": "backstage-cli repo test",
2122
"test:all": "backstage-cli repo test --coverage",

workspaces/bulk-import/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"build:all": "backstage-cli repo build --all",
1313
"build:api-reports": "yarn build:api-reports:only",
1414
"build:api-reports:only": "backstage-repo-tools api-reports -o ae-wrong-input-file-type,ae-undocumented --validate-release-tags",
15+
"build:knip-reports": "backstage-repo-tools knip-reports",
1516
"clean": "backstage-cli repo clean",
1617
"test": "backstage-cli repo test",
1718
"test:all": "backstage-cli repo test --coverage",

workspaces/global-floating-action-button/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"build:all": "backstage-cli repo build --all",
1313
"build:api-reports": "yarn build:api-reports:only --tsc",
1414
"build:api-reports:only": "backstage-repo-tools api-reports -o ae-wrong-input-file-type,ae-undocumented --validate-release-tags",
15+
"build:knip-reports": "backstage-repo-tools knip-reports",
1516
"clean": "backstage-cli repo clean",
1617
"test": "backstage-cli repo test",
1718
"test:all": "backstage-cli repo test --coverage",

workspaces/global-header/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"build:all": "backstage-cli repo build --all",
1616
"build:api-reports": "yarn build:api-reports:only --tsc",
1717
"build:api-reports:only": "backstage-repo-tools api-reports -o ae-wrong-input-file-type,ae-undocumented --validate-release-tags",
18+
"build:knip-reports": "backstage-repo-tools knip-reports",
1819
"clean": "backstage-cli repo clean",
1920
"test": "backstage-cli repo test",
2021
"test:all": "backstage-cli repo test --coverage",

workspaces/homepage/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"build:api-reports": "yarn build:api-reports:only --tsc",
1616
"build:api-reports:only": "backstage-repo-tools api-reports -o ae-wrong-input-file-type,ae-undocumented --validate-release-tags",
1717
"build-image": "yarn workspace backend build-image",
18+
"build:knip-reports": "backstage-repo-tools knip-reports",
1819
"clean": "backstage-cli repo clean",
1920
"test": "backstage-cli repo test",
2021
"test:all": "backstage-cli repo test --coverage",

workspaces/lightspeed/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"build:all": "backstage-cli repo build --all",
1616
"build:api-reports": "yarn build:api-reports:only",
1717
"build:api-reports:only": "backstage-repo-tools api-reports -o ae-wrong-input-file-type,ae-undocumented --validate-release-tags",
18+
"build:knip-reports": "backstage-repo-tools knip-reports",
1819
"clean": "backstage-cli repo clean",
1920
"test": "backstage-cli repo test",
2021
"test:all": "backstage-cli repo test --coverage",

workspaces/marketplace/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"build:api-reports": "yarn build:api-reports:only --tsc",
1717
"build:api-reports:only": "backstage-repo-tools api-reports -o ae-wrong-input-file-type,ae-undocumented --validate-release-tags",
1818
"build-image": "yarn workspace backend build-image",
19+
"build:knip-reports": "backstage-repo-tools knip-reports",
1920
"clean": "backstage-cli repo clean",
2021
"test": "backstage-cli repo test --detectOpenHandles",
2122
"test:all": "backstage-cli repo test --coverage --detectOpenHandles",

0 commit comments

Comments
 (0)