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

Conversation

staabm
Copy link

@staabm staabm commented Oct 1, 2024

Fixes the windows test-failure indentified in #170 by passing the script path to SkipLintProcess include instead of passing the code as a string which get mangled by later escapeshellarg().

see php/php-src#16147 (comment) for a in-detail analysis why this did not work on windows - kudos to Christoph M. Becker for the root cause analysis.

closes #170

clxmstaab and others added 2 commits October 1, 2024 13:50
When running the tests locally, I realized that patch 146 did not actually work correctly on Windows.

This commit adds test runs against Windows in CI on a limited number of PHP versions to prevent this kind of issue going unnoticed for future PRs.

Note: the lowest PHP version I can get a running build on is PHP 5.5. This is related to SSL transport issues with Packagist with old Composer versions (which are needed for old PHP versions).
@staabm staabm marked this pull request as ready for review October 1, 2024 11:54
@staabm
Copy link
Author

staabm commented Oct 1, 2024

//cc @jrfnl this PR should fix the problem you experienced in #170

Copy link
Collaborator

@jrfnl jrfnl left a comment

Choose a reason for hiding this comment

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

@staabm That's awesome investigative work between you and @cmb69. Thank you both so much !

I've also confirmed the fix via a test run on a local Windows machine.

Unfortunately, as the project is also released as a PHAR file, the solution needs more work as realpath() doesn't work for files packaged in a PHAR. (I'm not sure about is_file())


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.

@jrfnl jrfnl added the Type: bug label Oct 1, 2024
@@ -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.

@clxmstaab clxmstaab force-pushed the simpl branch 2 times, most recently from eb58bc8 to 2b3c305 Compare October 2, 2024 07:05
$script = str_replace('<?php', '', $script);

$parameters = array('-d', 'display_errors=stderr', '-r', $script);
$parameters = array('-d', 'display_errors=stderr', '-r', $code);
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.

@staabm
Copy link
Author

staabm commented Oct 2, 2024

its hard to debug the github action stuff when every change requires an approval :-/

@jrfnl
Copy link
Collaborator

jrfnl commented Oct 2, 2024

its hard to debug the github action stuff when every change requires an approval :-/

Indeed, but that can't be helped for now. I think it's the grep which is causing the problem, but haven't had the time to properly debug this today (I did push one commit to #170 to hopefully improve things already)

My own "hack" to get around the approval thingie is to:

  • Turn on actions in my own fork
  • Comment out the branches lines for the on - push (in a separate commit which I can easily remove)
  • Often also slim down the matrix to just run the problem builds I want to focus on (and one previously passing one safeguard that I'm not breaking it)
  • And then just hack away at it with debug statements etc until I get it working (preferably in a non-PR branch so people watching don't get an email about every push)

But I doubt I'm telling you anything new ?

@staabm
Copy link
Author

staabm commented Oct 2, 2024

But I doubt I'm telling you anything new ?

I am currently looking into it ;)

staabm#1 (comment)

@staabm
Copy link
Author

staabm commented Oct 2, 2024

@jrfnl please re-approve

@staabm
Copy link
Author

staabm commented Oct 3, 2024

Since the test matrix was adjusted the required checks for the repo need to be adjusted in the repo settings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants