diff --git a/.github/workflows/knip-reporter.yml b/.github/workflows/knip-reporter.yml new file mode 100644 index 0000000..cf58ea8 --- /dev/null +++ b/.github/workflows/knip-reporter.yml @@ -0,0 +1,38 @@ +name: Knip-reporter + +on: + workflow_run: + workflows: ["Knip"] + types: + - completed + +jobs: + knip-reporter: + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v4 + with: + name: knip-results + run-id: ${{ github.event.workflow_run.id }} + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Read pr number + id: pr-number + uses: juliangruber/read-file-action@v1 + with: + path: ./pr-number.txt + trim: true + + - name: Report knip results to pull request + if: ${{ github.event.workflow_run.conclusion != 'success' }} + uses: gitcoindev/knip-reporter@main + with: + verbose: true + comment_id: ${{ github.workflow }}-reporter + command_script_name: knip-ci + annotations: true + ignore_results: false + json_input: true + json_input_file_name: knip-results.json + pull_request_number: ${{ steps.pr-number.outputs.content }} + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/knip.yml b/.github/workflows/knip.yml index 4673f99..809976b 100644 --- a/.github/workflows/knip.yml +++ b/.github/workflows/knip.yml @@ -3,8 +3,6 @@ name: Knip on: pull_request: -permissions: write-all - jobs: run-knip: runs-on: ubuntu-latest @@ -24,11 +22,17 @@ jobs: - name: Install toolchain run: yarn install - - name: Report knip results to pull request - uses: Codex-/knip-reporter@v2 + - name: Store PR number + run: echo ${{ github.event.number }} > pr-number.txt + + - name: Run Knip + run: yarn knip || yarn knip --reporter json > knip-results.json + + - name: Upload knip result + if: failure() + uses: actions/upload-artifact@v4 with: - verbose: true - comment_id: ${{ github.workflow }}-reporter - command_script_name: knip-ci - annotations: true - ignore_results: false + name: knip-results + path: | + knip-results.json + pr-number.txt diff --git a/knip.ts b/knip.ts index a749511..662485d 100644 --- a/knip.ts +++ b/knip.ts @@ -1,11 +1,15 @@ import type { KnipConfig } from "knip"; const config: KnipConfig = { - entry: ["build/index.ts"], + entry: ["src/index.ts", "src/services/*.ts"], project: ["src/**/*.ts"], ignore: ["src/types/config.ts"], ignoreExportsUsedInFile: true, - ignoreDependencies: [], + ignoreDependencies: ["ts-node", "node-fetch", "eslint-config-prettier", "eslint-plugin-prettier", "@types/jest", "@types/node-fetch"], + jest: { + config: ["jest.config.ts"], + entry: ["tests/*.ts"], + }, }; export default config;