Skip to content

Commit

Permalink
fix errors with GitHub API
Browse files Browse the repository at this point in the history
  • Loading branch information
auguwu committed May 29, 2023
1 parent 5905088 commit 72f8efb
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
components: clippy
- uses: auguwu/clippy-action@1.1.0
with:
token: ${{secrets.GITHUB_TOKEN}}
token: ${{secrets.GITHUB_TOKEN}}
```
## License
Expand Down
2 changes: 1 addition & 1 deletion build/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@augu/clippy-action",
"description": "🐻‍❄️📦 GitHub action to run Clippy, an up-to-date and modern version of actions-rs/clippy",
"version": "1.1.0",
"version": "1.1.1",
"private": true,
"main": "build/main.js",
"author": "Noel Towa <cutie@floofy.dev>",
Expand Down
50 changes: 31 additions & 19 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,12 @@ async function main() {
}

// Create a check
const now = new Date().toISOString();
const {
data: { id }
} = await client.request('POST /repos/{owner}/{repo}/check-runs', {
owner: context.repo.owner,
repo: context.repo.repo,

started_at: now,
name: 'Clippy',
head_sha: context.payload.pull_request !== undefined ? context.payload.pull_request.head.sha : context.sha,
status: 'in_progress'
Expand All @@ -64,23 +62,37 @@ async function main() {
check_run_id: id,
owner: context.repo.owner,
repo: context.repo.repo,

started_at: now,
completed_at: new Date().toISOString(),
output: {
title: 'Clippy Result',
summary: `Clippy exited with code ${exitCode}`,
annotations: annotations.map((anno) => ({
annotation_level: anno.level === 'error' ? ('failure' as const) : ('warning' as const),
path: anno.file!,
start_line: anno.startLine!,
end_line: anno.endLine!,
start_column: anno.startColumn,
end_column: anno.endColumn,
raw_details: anno.rendered,
message: anno.title!
}))
}
conclusion: exitCode === 0 ? 'success' : 'failure',
output:
exitCode === 0
? {
title: 'Clippy Result',
summary: 'Clippy ran successfully!',
annotations: annotations.map((anno) => ({
annotation_level: anno.level === 'error' ? ('failure' as const) : ('warning' as const),
path: anno.file!,
start_line: anno.startLine!,
end_line: anno.endLine!,
start_column: anno.startColumn,
end_column: anno.endColumn,
raw_details: anno.rendered,
message: anno.title!
}))
}
: {
title: 'Clippy failed',
summary: `Running \`cargo clippy\` failed with exit code ${exitCode}`,
annotations: annotations.map((anno) => ({
annotation_level: anno.level === 'error' ? ('failure' as const) : ('warning' as const),
path: anno.file!,
start_line: anno.startLine!,
end_line: anno.endLine!,
start_column: anno.startColumn,
end_column: anno.endColumn,
raw_details: anno.rendered,
message: anno.title!
}))
}
});

info(`Clippy exited with code ${exitCode}`);
Expand Down

0 comments on commit 72f8efb

Please sign in to comment.