Skip to content

Commit

Permalink
Release v1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
svartalf committed Sep 27, 2019
1 parent adea964 commit e6ca070
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 14 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.2] - 2019-09-27

### Added

- Action will fail if clippy exits with a non-zero code
- Clippy output is added to the Action logs (JSON format)

### Fixed

- Usually used `-- -D warnings` parameter in the `args` input will not break Action execution

## [1.0.1] - 2019-09-27

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion dist/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,6 +1,6 @@
{
"name": "rust-clippy-check",
"version": "1.0.1",
"version": "1.0.2",
"private": false,
"description": "Run clippy and annotate the diff with errors and warnings",
"main": "lib/main.js",
Expand Down
1 change: 0 additions & 1 deletion src/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ export class CheckRunner {
break;
}

console.log(contents);
this.annotations.push(CheckRunner.makeAnnotation(contents));
}

Expand Down
33 changes: 22 additions & 11 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,31 @@ export async function run(actionInput: input.Input): Promise<void> {
}
});

let args: string[] = ['clippy'];
// `--message-format=json` should just right after the `cargo clippy`
// because usually people are adding the `-- -D warnings` at the end
// of arguments and it will mess up the output.
let args: string[] = ['clippy', '--message-format=json'];
if (actionInput.toolchain) {
args.push(`+${actionInput.toolchain}`);
}
args = args.concat(actionInput.args);
args.push('--message-format=json');

let runner = new CheckRunner();
await program.call(args, {
silent: true,
ignoreReturnCode: true,
failOnStdErr: false,
listeners: {
stdline: (line) => {
runner.tryPush(line);
let clippyExitCode: number = 0;
try {
core.startGroup('Executing cargo clippy (JSON output)');
clippyExitCode = await program.call(args, {
ignoreReturnCode: true,
failOnStdErr: false,
listeners: {
stdline: (line) => {
runner.tryPush(line);
}
}
}
});
});
} finally {
core.endGroup();
}

await runner.executeCheck({
token: actionInput.token,
Expand All @@ -71,6 +78,10 @@ export async function run(actionInput: input.Input): Promise<void> {
clippy: clippyVersion,
}
});

if (clippyExitCode !== 0) {
throw new Error(`Clippy had exited with the ${clippyExitCode} exit code`);
}
}

async function main(): Promise<void> {
Expand Down

0 comments on commit e6ca070

Please sign in to comment.