Repository navigation
feat(cli): add GitHub integration that publishes lint results - #94
Closed
luoling8192 wants to merge 1 commit into
Closed
luoling8192 wants to merge 1 commit into
luoling8192 wants to merge 1 commit into
Conversation
`alint integrations github <file>` reads saved JSON output and publishes it to GitHub. It adds a check run with line annotations, one summary comment on the pull request, and a job summary. The check run fails only when a diagnostic is an error. Each run rewrites the same summary comment. `output inspect` and the new command share one reader for saved output. Co-authored-by: Neko Ayaka <neko@ayaka.moe> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
|
The publication logic moved to a separate action, as the owner requested: https://github.com/alint-dev/setup. This PR is not necessary. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A repository that runs
alintin CI must write its own script to show the result on a pull request. LobeHub wrote such a script for its monorepo. This PR adds the same capability to the CLI, so each repository can use one command.alint integrations github <file>reads saved--format jsonoutput and publishes it to GitHub:alintwith one line annotation for each diagnostic.This PR is independent. It does not add
suggestionblocks. A diagnostic has no replacement text and no exact range today, so that needs a change to the rule contract first.Change map
integrations/githubfindings.tsis pure.api.tsowns the network calls.github.tsowns the command and the environment.output-inspect/run-resultinspect.tsowned the reader and the validation of saved output.output inspectand the new command read saved output the same way. The messages and exit codes ofoutput inspectdid not change.GitHub Pull Requestssection.pnpm docs:updatesynchronizedpackages/cli/README.md.Behavior
failurewhen a diagnostic is an error,neutralwhen there are only warnings, andsuccesswhen there are no findings.0after it publishes the result, also when the result has errors. The check run reports the errors, so the job does not fail a second time. It returns2when it cannot read the file or GitHub rejects a request.pull_request.head.shafromGITHUB_EVENT_PATH.GITHUB_SHAis the temporary merge commit there, and a check run on that commit does not show on the pull request.ALINT_GITHUB_SHAandALINT_GITHUB_PULL_REQUESTselect the commit and the pull request for other events. These are environment variables and not options, because the argument parser converts a commit that has only digits to a number.evidence.suggestion, which declarative rules and@alint-js/plugin-jsrules set.GITHUB_API_URLandGITHUB_SERVER_URLselect the API and the link host, so GitHub Enterprise Server works without more configuration.Boundaries and risks
findings.test.tsgithub.test.tswith 120 diagnostics2with the GitHub error.github.test.tswith a 403 response. The README states the limit.Verification
pnpm -F @alint-js/cli exec vitest run src/cli/commands/integrations/github src/cli/cli.test.ts: 124 tests passed. The new tests call the CLI against a local HTTP server and do not use mocks.pnpm -F @alint-js/cli exec vitest run: 423 passed, 4 failed. The 4 failures are ingit.test.ts,lint/dirty.test.ts, andstop-gate.test.ts. They also fail onmainon macOS because the temporary directory is a symbolic link (/varand/private/var).pnpm typecheck: passed afterpnpm -r run build.pnpm lint: passed.Follow-up
--dirty, so CI does not needgit reset --mixed <merge-base>to lint only the changes of a pull request.suggestionblocks.🤖 Generated with Claude Code