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

Output PHP_CodeSniffer autofix diff in CI #45

Merged
merged 4 commits into from
May 21, 2024
Merged

Output PHP_CodeSniffer autofix diff in CI #45

merged 4 commits into from
May 21, 2024

Conversation

mvorisek
Copy link
Contributor

Make constributions easier by providing easy to read autofix diff.

@greg0ire
Copy link
Member

Can you please demonstrate the result on another repository?

.github/workflows/coding-standards.yml Outdated Show resolved Hide resolved
.github/workflows/coding-standards.yml Outdated Show resolved Hide resolved
@mvorisek
Copy link
Contributor Author

Can you please demonstrate the result on another repository?

Here mvorisek/sql-formatter#1 is a PR demonstrating the behaviour.

The cs2pr behaviour is kept and newly an autofixable diff is output into the GHA CI - https://github.com/mvorisek/sql-formatter/actions/runs/9133275839/job/25116393429?pr=1#step:5:17. Such diff is very useful.

@mvorisek mvorisek requested a review from greg0ire May 17, 2024 19:41
@greg0ire
Copy link
Member

I'm skeptical: when there are autofixable errors, then people should manually apply that diff… they should IMO just run vendor/bin/phpcbf. I don't see in what cases seeing this diff can be useful.

@mvorisek
Copy link
Contributor Author

I'm skeptical: when there are autofixable errors, then people should manually apply that diff… they should IMO just run vendor/bin/phpcbf. I don't see in what cases seeing this diff can be useful.

Altrough I made many Doctrine contributions already, for smaller contributions, I do not have phpcs very often installed. The "text output of cs2pr" is sometimes hard to understand so I would really, really appreciate if the diff can be shown, as the diff is very easy to understand what changes should be done in order to make CI happy.

@greg0ire
Copy link
Member

greg0ire commented May 17, 2024

I do not have phpcs very often installed.

How is that possible? Do you clone the repository every time? Or do you nuke your vendor directory after each contribution? It's one composer install away… Anyway, ideally contributors would run git hooks before pushing and that job should never go red. I really prefer to push them towards running checks locally instead of adding notifications for PRs with failing builds to my inbox.

@mvorisek
Copy link
Contributor Author

I do not have phpcs very often installed.

How is that possible? Do you clone the repository every time? Or do you nuke your vendor directory after each contribution? It's one composer install away… Anyway, ideally contributors would run git hooks before pushing and that job should never go red. I really prefer to push them towards running checks locally instead of adding notifications for PRs with failing builds to my inbox.

There are thousand reasons. Changes might be done using GH web IDE, from enviroments /wo composer, local PHP version might be too low (for ex. in my work we use still PHP 7.4 on some Windows machines), ...

In anycase, I run into these situations myself, thus I propose this CI improvement which I find useful.

Copy link
Member

@greg0ire greg0ire left a comment

Choose a reason for hiding this comment

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

The code looks good, I'd like to get input by other Doctrine maintainers about the usefulness. My very personal opinion is that we should encourage people not to rely on the CI for checks so as to get as few notifications about PRs with failing builds as possible.

@ostrolucky
Copy link
Member

doesn't this double execution time?

@mvorisek
Copy link
Contributor Author

mvorisek commented May 17, 2024

doesn't this double execution time?

Even /wo cache the execution is fast - ~6 secs for Doctrine DBAL, ~9 secs for Doctrine ORM.

@ostrolucky
Copy link
Member

does it make sense to do --no-colors for diff output?

@SenseException
Copy link
Member

does it make sense to do --no-colors for diff output?

Wouldn't colors leave a bunch of console-color noise like [30m in the output?

@mvorisek
Copy link
Contributor Author

does it make sense to do --no-colors for diff output?

I agree colored output it better for UX - I commited the change, here is an example: https://github.com/mvorisek/sql-formatter/actions/runs/9135074458/job/25121808121?pr=1#step:6:17

@greg0ire greg0ire added the enhancement New feature or request label May 19, 2024
@ostrolucky ostrolucky merged commit 36c5f05 into doctrine:main May 21, 2024
@mvorisek mvorisek deleted the output-cs-diff branch May 21, 2024 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants