Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
Allow setting a title for the created check run (#11)
Browse files Browse the repository at this point in the history
* Allow setting a title for the created check run

This change allows a workflow to contain multiple clippy-check
invocations that execute in parallel, by giving each run a unique name.

Previously, any clippy invocations running in parallel would race
against each other, and annotations would only reported for the first to
hit `createCheck(...)`.
  • Loading branch information
garyttierney authored and svartalf committed Oct 29, 2019
1 parent b6e81c9 commit 4eb61a7
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,14 @@ jobs:
| `toolchain` | | Rust toolchain to use; override or system default toolchain will be used if omitted | string | |
| `args` | | Arguments for the `cargo clippy` command | string | |
| `use-cross` | | Use [`cross`](https://github.com/rust-embedded/cross) instead of `cargo` | bool | false |

| `name` | | Name of the created GitHub check. If running this action multiple times, each run must have a unique name. | string | clippy |

For extra details about the `toolchain`, `args` and `use-cross` inputs,
see [`cargo` Action](https://github.com/actions-rs/cargo#inputs) documentation.

**NOTE**: if your workflow contains multiple instances of the `clippy-check` action you will need to give each invocation a unique name, using the `name` property described above.
Check runs must have a unique name, and this prevents a later check run overriding a previous one within the same workflow.

## Limitations

Due to [token permissions](https://help.github.com/en/articles/virtual-environments-for-github-actions#token-permissions),
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ inputs:
use-cross:
description: Use cross instead of cargo
default: false
name:
description: Display name of the created GitHub check. Must be unique across several actions-rs/clippy-check invocations.
default: clippy

runs:
using: 'node12'
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface Input {
toolchain?: string,
args: string[],
useCross: boolean,
name: string,
}

export function get(): Input {
Expand All @@ -21,11 +22,13 @@ export function get(): Input {
toolchain = toolchain.slice(1);
}
const useCross = input.getInputBool('use-cross');
const name = input.getInput('name');

return {
token: input.getInput('token', {required: true}),
args: args,
useCross: useCross,
toolchain: toolchain || undefined
toolchain: toolchain || undefined,
name
}
}
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export async function run(actionInput: input.Input): Promise<void> {

await runner.executeCheck({
token: actionInput.token,
name: 'clippy',
name: actionInput.name,
owner: github.context.repo.owner,
repo: github.context.repo.repo,
head_sha: github.context.sha,
Expand Down

0 comments on commit 4eb61a7

Please sign in to comment.