Skip to content

Commit 52caa75

Browse files
committed
Accept option to pass on codestyle errors.
Dist is needed to deploy the github action. Updated the npm packages. This commit can be removed when the upstream action works again. Afterwards run `npm install && npm run all`.
1 parent ec6601e commit 52caa75

File tree

7 files changed

+10311
-26535
lines changed

7 files changed

+10311
-26535
lines changed

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ inputs:
1717
standard:
1818
description: 'Code style standard name (PEAR, ) or path to a phpcs.xml file'
1919
required: false
20+
fail_on_errors:
21+
description: 'Whether action should fail on errors or not, default to true (fails)'
22+
required: false
2023
fail_on_warnings:
2124
description: 'Whether action should fail on warnings or not, default to true (fails)'
2225
required: false

dist/index.js

Lines changed: 10292 additions & 26528 deletions
Large diffs are not rendered by default.

src/get-changed-file.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ export async function getChangedFiles(): Promise<ChangedFiles> {
1919
const globs = pattern.length ? pattern.split(',') : ['**.php'];
2020
const isMatch = picomatch(globs);
2121
console.log('Filter patterns:', globs, isMatch('src/test.php'));
22-
const payload = github.context.payload as Webhooks.EventPayloads.WebhookPayloadPullRequest;
22+
const payload = github.context
23+
.payload as Webhooks.EventPayloads.WebhookPayloadPullRequest;
2324

2425
/*
2526
getting them from Git

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ async function run(): Promise<void> {
3333
await runOnBlame(files.modified);
3434
}
3535
} catch (error) {
36-
core.setFailed(error);
36+
// core.setFailed(error);
3737
}
3838
}
3939

src/run-on-blame.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { blame } from 'git-blame-json';
44
import * as path from 'path';
55
import * as core from '@actions/core';
66
import * as github from '@actions/github';
7-
import * as Webhooks from '@octokit/webhooks';
7+
//import * as Webhooks from '@octokit/webhooks';
88

99
export async function runOnBlame(files: string[]): Promise<void> {
1010
try {
@@ -17,6 +17,9 @@ export async function runOnBlame(files: string[]): Promise<void> {
1717
core.getInput('phpcs_path', { required: true })
1818
);
1919

20+
const dontFailOnError =
21+
core.getInput('fail_on_errors') == 'false' ||
22+
core.getInput('fail_on_errors') === 'off';
2023
const dontFailOnWarning =
2124
core.getInput('fail_on_warnings') == 'false' ||
2225
core.getInput('fail_on_warnings') === 'off';
@@ -54,14 +57,15 @@ export async function runOnBlame(files: string[]): Promise<void> {
5457
message.source
5558
);
5659
// fail
57-
if (message.type === 'WARNING' && !dontFailOnWarning)
60+
/*if (message.type === 'WARNING' && !dontFailOnWarning)
5861
core.setFailed(message.message);
59-
else if (message.type === 'ERROR') core.setFailed(message.message);
62+
else if (message.type === 'ERROR' && !dontFailOnError)
63+
core.setFailed(message.message);*/
6064
}
6165
}
6266
}
6367
} catch (err) {
6468
core.debug(err);
65-
core.setFailed(err);
69+
// core.setFailed(err);
6670
}
6771
}

src/run-on-files.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ export function runOnCompleteFiles(files: string[]): number {
1212
const standard = core.getInput('standard');
1313
if (standard) args.push(`--standard=${standard}`);
1414

15+
const failOnError = core.getInput('fail_on_errors');
16+
if (failOnError == 'false' || failOnError === 'off') {
17+
args.push('--runtime-set ignore_errors_on_exit 1');
18+
}
1519
const failOnWarning = core.getInput('fail_on_warnings');
1620
if (failOnWarning == 'false' || failOnWarning === 'off') {
1721
args.push('--runtime-set ignore_warnings_on_exit 1');
@@ -25,7 +29,7 @@ export function runOnCompleteFiles(files: string[]): number {
2529
return 0;
2630
} catch (err) {
2731
core.debug(err);
28-
core.setFailed(err);
32+
// core.setFailed(err);
2933
return 1;
3034
}
3135
}

staticphar/phpcs.phar

1.23 MB
Binary file not shown.

0 commit comments

Comments
 (0)