Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Host a working version #1

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,5 @@ Thumbs.db

# Ignore built ts files
__tests__/runner/*
lib/**/*
lib/**/*

3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ inputs:
standard:
description: 'Code style standard name (PEAR, ) or path to a phpcs.xml file'
required: false
fail_on_errors:
description: 'Whether action should fail on errors or not, default to true (fails)'
required: false
fail_on_warnings:
description: 'Whether action should fail on warnings or not, default to true (fails)'
required: false
Expand Down
36,809 changes: 10,287 additions & 26,522 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/get-changed-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export async function getChangedFiles(): Promise<ChangedFiles> {
const globs = pattern.length ? pattern.split(',') : ['**.php'];
const isMatch = picomatch(globs);
console.log('Filter patterns:', globs, isMatch('src/test.php'));
const payload = github.context.payload as Webhooks.WebhookPayloadPullRequest;
const payload = github.context.payload as Webhooks.EventPayloads.WebhookPayloadPullRequest;

/*
getting them from Git
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ async function run(): Promise<void> {
}
}

run();
void run();
8 changes: 5 additions & 3 deletions src/run-on-blame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export async function runOnBlame(files: string[]): Promise<void> {
core.getInput('phpcs_path', { required: true })
);

const dontFailOnError =
core.getInput('fail_on_errors') == 'false' ||
core.getInput('fail_on_errors') === 'off';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really great to use double negatives in variable names, but given that dontFailOnWarning already exists, meh.
Although given that this is later only used as !dontFailOnError I think it's actually better to simply name it failOnError.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree but the original author already had this, I only intended to add a "copy" which works the same as the warning option.

const dontFailOnWarning =
core.getInput('fail_on_warnings') == 'false' ||
core.getInput('fail_on_warnings') === 'off';
Expand All @@ -26,8 +29,6 @@ export async function runOnBlame(files: string[]): Promise<void> {
}

// blame files and output relevant errors
const payload = github.context
.payload as Webhooks.WebhookPayloadPullRequest;
// get email of author of first commit in PR
const authorEmail = execFileSync(
'git',
Expand Down Expand Up @@ -58,7 +59,8 @@ export async function runOnBlame(files: string[]): Promise<void> {
// fail
if (message.type === 'WARNING' && !dontFailOnWarning)
core.setFailed(message.message);
else if (message.type === 'ERROR') core.setFailed(message.message);
else if (message.type === 'ERROR' && !dontFailOnError)
core.setFailed(message.message);
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/run-on-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ export function runOnCompleteFiles(files: string[]): number {
const standard = core.getInput('standard');
if (standard) args.push(`--standard=${standard}`);

const failOnError = core.getInput('fail_on_errors');
if (failOnError == 'false' || failOnError === 'off') {
args.push('--runtime-set ignore_errors_on_exit 1');
}
const failOnWarning = core.getInput('fail_on_warnings');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Such consistency by the original author...

if (failOnWarning == 'false' || failOnWarning === 'off') {
args.push('--runtime-set ignore_warnings_on_exit 1');
Expand Down
Binary file added staticphar/phpcs.phar
Binary file not shown.