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

SkipLintProcess: Pass script by file-name instead of code #178

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
17 changes: 15 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ jobs:
path: ./parallel-lint.phar

test:
name: Run tests on PHP ${{ matrix.php }}
runs-on: ubuntu-latest
name: Run tests on PHP ${{ matrix.php }} (${{ matrix.os }})
runs-on: "${{ matrix.os }}"
continue-on-error: ${{ matrix.php == '8.4' }}
needs:
- bundle
Expand All @@ -114,6 +114,19 @@ jobs:
- '8.2'
- '8.3'
- '8.4'
os:
- 'ubuntu-latest'

include:
# Also run the tests against Windows on a few PHP versions.
- php: '5.5'
os: 'windows-latest'
- php: '7.0'
os: 'windows-latest'
- php: '8.0'
os: 'windows-latest'
- php: '8.3'
os: 'windows-latest'

steps:
- name: Checkout code
Expand Down
7 changes: 2 additions & 5 deletions src/Process/SkipLintProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,12 @@ class SkipLintProcess extends PhpProcess
public function __construct(PhpExecutable $phpExecutable, array $filesToCheck)
{
$scriptPath = __DIR__ . '/../../bin/skip-linting.php';
Copy link
Collaborator

@jrfnl jrfnl Oct 1, 2024

Choose a reason for hiding this comment

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

Brain fart (untested): changing this line to the below and removing the call to realpath() might fix the issue with the PHAR ?

Suggested change
$scriptPath = __DIR__ . '/../../bin/skip-linting.php';
$scriptPath = dirname(dirname(__DIR__)) . '/bin/skip-linting.php';

Copy link
Author

Choose a reason for hiding this comment

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

$script = file_get_contents($scriptPath);

if (!$script) {
if (!is_file($scriptPath)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if (!is_file($scriptPath)) {
if (!@is_file($scriptPath)) {

I think it would make sense to silence a potential warning coming from is_file() as the exception being thrown makes the warning redundant.

throw new RuntimeException("skip-linting.php script not found in '$scriptPath'.");
}

$script = str_replace('<?php', '', $script);

$parameters = array('-d', 'display_errors=stderr', '-r', $script);
$parameters = array('-d', 'display_errors=stderr', '-f', realpath($scriptPath));
parent::__construct($phpExecutable, $parameters, implode(PHP_EOL, $filesToCheck));
Copy link
Author

Choose a reason for hiding this comment

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

btw: I wonder why this skip-linting logic is implemented via subprocess at all. I think parallel-lint would be faster when it just invokes the logic directly.

but thats a story for a future PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I've been wondering the same, but that was before my time, so will need some history digging (in the old repo) to see if we can figure out the reason. If there is none, I'd welcome a change for this.

}

Expand Down
Loading