Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: correct Knip configuration for conversation-rewards #11

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/knip-reporter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Knip-reporter

on:
workflow_run:
workflows: ["Knip"]
types:
- completed

jobs:
knip-reporter:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20.10.0

- name: Install toolchain
run: yarn install

- 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 }}
22 changes: 13 additions & 9 deletions .github/workflows/knip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: Knip
on:
pull_request:

permissions: write-all

jobs:
run-knip:
runs-on: ubuntu-latest
Expand All @@ -20,11 +18,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 -s 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
10 changes: 7 additions & 3 deletions knip.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import type { KnipConfig } from "knip";

const config: KnipConfig = {
entry: ["build/index.ts"],
entry: ["src/index.ts"],
project: ["src/**/*.ts"],
ignore: ["src/types/config.ts"],
ignore: ["src/data-collection/examples/*.ts", "src/configuration/common-config-type.ts"],
ignoreExportsUsedInFile: true,
ignoreDependencies: [],
ignoreDependencies: ["ts-node"],
jest: {
config: ["jest.config.ts"],
entry: ["src/**/*.test.ts"],
},
};

export default config;
10 changes: 3 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"format:prettier": "prettier --write .",
"format:cspell": "cspell **/*",
"knip": "knip",
"knip-ci": "knip --no-exit-code --reporter json",
"prepare": "husky install"
},
"keywords": [
Expand Down Expand Up @@ -52,23 +51,20 @@
"@types/jsdom": "21.1.6",
"@types/markdown-it": "13.0.7",
"@types/node": "20.11.28",
"@types/yargs": "17.0.32",
"@typescript-eslint/eslint-plugin": "6.21.0",
"@typescript-eslint/parser": "6.21.0",
"babel-jest": "^29.7.0",
"cspell": "8.3.2",
"esbuild": "0.19.12",
"eslint": "8.56.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "5.1.3",
"eslint-plugin-sonarjs": "0.23.0",
"husky": "8.0.3",
"jest": "29.7.0",
"jest-junit": "16.0.0",
"knip": "3.3.0",
"knip": "5.7.0",
"lint-staged": "15.2.2",
"npm-run-all": "4.1.5",
"prettier": "3.2.5",
"ts-node": "^10.9.2",
gitcoindev marked this conversation as resolved.
Show resolved Hide resolved
"ts-node": "10.9.2",
"typescript": "5.3.3"
},
"lint-staged": {
Expand Down
10 changes: 7 additions & 3 deletions src/github-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import { RestEndpointMethodTypes } from "@octokit/rest";
export type GitHubIssue = RestEndpointMethodTypes["issues"]["get"]["response"]["data"];
export type GitHubPullRequest = RestEndpointMethodTypes["pulls"]["get"]["response"]["data"];
export type GitHubIssueComment = RestEndpointMethodTypes["issues"]["listComments"]["response"]["data"][0];
export type GitHubLabel = RestEndpointMethodTypes["issues"]["listLabelsOnIssue"]["response"]["data"][0];
// eslint-disable-next-line @typescript-eslint/no-unused-vars
type GitHubLabel = RestEndpointMethodTypes["issues"]["listLabelsOnIssue"]["response"]["data"][0];
export type GitHubIssueEvent = RestEndpointMethodTypes["issues"]["listEvents"]["response"]["data"][0];
export type GitHubTimelineEvent = RestEndpointMethodTypes["issues"]["listEventsForTimeline"]["response"]["data"][0];
export type GitHubRepository = RestEndpointMethodTypes["repos"]["get"]["response"]["data"];
export type GitHubUser = RestEndpointMethodTypes["users"]["getByUsername"]["response"]["data"];
export type GitHubPullRequestReviewState = RestEndpointMethodTypes["pulls"]["listReviews"]["response"]["data"][0];
export type GitHubPullRequestReviewComment = RestEndpointMethodTypes["pulls"]["listReviewComments"]["response"]["data"][0];
export type GitHubPullRequestReviewComment =
RestEndpointMethodTypes["pulls"]["listReviewComments"]["response"]["data"][0];

type LinkPullRequestDetail = {
url: "https://api.github.com/repos/ubiquibot/comment-incentives/pulls/25";
Expand All @@ -19,7 +21,9 @@ type LinkPullRequestDetail = {
merged_at: "2024-02-16T19:22:01Z";
};

type SourceIssueWithPullRequest = GitHubIssue | ((GitHubPullRequest & { pull_request: LinkPullRequestDetail }) & { repository: GitHubRepository });
type SourceIssueWithPullRequest =
| GitHubIssue
| ((GitHubPullRequest & { pull_request: LinkPullRequestDetail }) & { repository: GitHubRepository });

export type GitHubLinkEvent = RestEndpointMethodTypes["issues"]["listEventsForTimeline"]["response"]["data"][0] & {
event: "connected" | "disconnected" | "cross-referenced";
Expand Down
6 changes: 4 additions & 2 deletions src/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ export async function getPullRequestReviewComments(pullParams: PullParams): Prom
return await octokit.paginate(octokit.pulls.listReviewComments.endpoint.merge(pullParams));
}

export async function getAllIssueActivity(issueParams: IssueParams) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async function getAllIssueActivity(issueParams: IssueParams) {
// @DEV: this is very useful for seeing every type of event,
// which includes the issue specification, any events, and all conversation
// that has occurred on the issue in chronological order
Expand All @@ -104,7 +105,8 @@ export async function getAllIssueActivity(issueParams: IssueParams) {
return mixedEventsAndComments;
}

export async function getTimelineUsers(issueParams: IssueParams): Promise<GitHubUser[]> {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async function getTimelineUsers(issueParams: IssueParams): Promise<GitHubUser[]> {
gitcoindev marked this conversation as resolved.
Show resolved Hide resolved
const timelineEvents = await getAllTimelineEvents(issueParams);
const users = timelineEvents.filter((event) => event.actor).map((event) => event.actor);
return [...new Set(users)];
Expand Down
Loading
Loading