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

DX: Improve QA process #7366

Merged
merged 7 commits into from Nov 2, 2023
Merged

Conversation

Wirone
Copy link
Member

@Wirone Wirone commented Oct 10, 2023

Run tests and Fixer with higher granularity (do not repeat same steps on same runtime). The value of this approach:

  • explicit information about it in CI widget within PR: no need to click through jobs to see which step failed
  • faster feedback about CS violations: no need to wait for tests (~6 minutes) to see code styling issues (~1 minute)

Previously PR contained also:

BEFORE (~10m):

image

AFTER (~8m):

image

Gain: CI time reduced ~20% + more explicit summary.

@Wirone Wirone added the topic/ci Github Actions, tooling label Oct 10, 2023
@Wirone Wirone self-assigned this Oct 10, 2023
@Wirone Wirone marked this pull request as draft October 10, 2023 22:22
@Wirone Wirone force-pushed the codito/improve-qa-process branch 2 times, most recently from 390c5d9 to c58e279 Compare October 10, 2023 22:53
@coveralls
Copy link

coveralls commented Oct 10, 2023

Coverage Status

coverage: 94.604%. remained the same when pulling 8ea7900 on Wirone:codito/improve-qa-process into c93c733 on PHP-CS-Fixer:master.

@Wirone Wirone marked this pull request as ready for review October 10, 2023 23:08
.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
Copy link
Member

@keradus keradus left a comment

Choose a reason for hiding this comment

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

due to raised concerns, I find this approach testing less things than current CI is doing.

@Wirone Wirone requested a review from keradus October 26, 2023 15:19
@keradus keradus dismissed their stale review October 26, 2023 15:21

new review required

.github/workflows/ci.yml Outdated Show resolved Hide resolved
job-description: 'with lowest deps'
job-description: 'tests with Symfony ^5'
run-tests: 'yes'
execute-flex-with-symfony-version: '^5' # explicit check for Symfony 5.x compatibility
Copy link
Member

Choose a reason for hiding this comment

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

likely "7.4 tests with Sf^5" and "7.4 tests with lowest-deps" can be merged

yes, test will be less atomic. one will open log and see why it failed

Copy link
Member

Choose a reason for hiding this comment

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

I am a bit struggling now, and wondering about "split of responsibilities" vs "run the few tasks on same machine".

IE - PHP 7.4, we have:

  • 7.4 test Sf 5
  • 7.4 tests with lowest deps (missing now)
  • 7.4 fixer with lowest deps
  • 7.4 fixer with phpdoc2code
  • 7.4 fixer with Sf ^5

First proposal:

  • 7.4 tests with lowest deps + Sf 5 explicitly
  • 7.4 fixer with lowest deps + Sf 5 explicitly + phpdoc2code

2nd proposal (for discussion):
approx 15s is for each job to build PHP and install composer deps. Why not having single - 7.4 with lowest deps + Sf 5 explicitly + fixer phpdoc2code, fixer, tests
?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because it's cumbersome to look inside the job every time to see what actually failed. When you have complete list of checks in the PR, you clearly see on the list what succeeded and what failed. Personally I prefer wider list of atomic checks than condensed jobs with multiple checks inside.

Copy link
Member

Choose a reason for hiding this comment

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

there are 20 jobs. we could reduce to ~7job, so 13x15s ~~ 3mins :D

honestly, see no value of keeping "lowest deps" and "sf5" separately

Copy link
Member Author

Choose a reason for hiding this comment

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

The actual value is that tests (~6min) are run before Fixer (~1min), so you effectively get feedback about CS violations few minutes later than you could. There's no point in waiting few minutes for something that you could get earlier and fix it even before tests are finished.

Copy link
Member

Choose a reason for hiding this comment

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

we stop all jobs when any of them fails, right? eg we stop PHPUnit in-progress task, when fixer check will fail?

if so, I'm OK with that proposal to run them in parallel, as separated jobs

Copy link
Member Author

@Wirone Wirone Nov 2, 2023

Choose a reason for hiding this comment

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

No, we don't stop jobs when any of them fails, but why should we? The point of this is exactly the opposite: to know that tests are passing, even if there are CS violations, and vice versa. Currently we wait with CS check for tests to complete, which makes the job longer, but also is not developer friendly - imagine scenario:

  • developer pushes branch
  • tests are failing
  • developer fixes tests and pushes branch
  • CS check is failing
  • developer must fix the branch again and push it again, which means 3 pipeline runs (can be 2).

This feedback cycle is suboptimal, with my approach you have explicit info about both: tests and CS check. Seeing both failed developer can fix both, with one feedback cycle.

Copy link
Member

Choose a reason for hiding this comment

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

I'm actually eager to have a cascatde and terminate jobs ASAP, for any CI. if we go, let say, SCA->Utests, I do not need to run tests if SCA is failing. Dev need to come back to local env and do fixes. and they should not push code if they didn't test it locally.

if we run every check always, we waste CPU. It's OK to have a test pyramid stopping on failure.

Copy link
Member

Choose a reason for hiding this comment

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

(OK to externalise this discussion out of PR scope)

Copy link
Member Author

Choose a reason for hiding this comment

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

It would have mattered if we paid for CI runners, but we use free ones and cascading it like you described wouldn't make much sense. It would be pretty the same as it was before this PR, with Fixer and tests as the steps in the same job (but in reversed order) - stop on first fail. In my opinion dev should run composer qa before push that would mostly lead to green pipeline, but everyone sometime forget to run it or is super sure everything is alright, just to be surprised in the CI 😉. In this context, I personally would like to get full feedback, not only first failures.

It really would have been different when $$$ should be considered, then requirements and KPIs would be different, leading to different implementation. In this particular case there's no point in queueing jobs that don't technically require it (can work in parallel).

.github/workflows/ci.yml Outdated Show resolved Hide resolved
@Wirone Wirone marked this pull request as draft November 2, 2023 13:24
@Wirone Wirone force-pushed the codito/improve-qa-process branch 2 times, most recently from e31c6bc to cef0fb5 Compare November 2, 2023 14:05
@Wirone
Copy link
Member Author

Wirone commented Nov 2, 2023

@keradus FYI: at this point I just only rebased my branch and resolved conflicts, I'll address comments from the review later.

It does not make sense to run tests and Fixer on each matrix' combination. We should explicitly run these only when really needed, without repeating same steps on same runtime.
Both tests and Fixer are run twice:
- on Symfony ^5 components with `--prefer-lowest` flag for Composer deps
- on highest deps available for this PHP version

Native type checks are run along with regular Fixer checks because they take only few seconds and there's no need to extract it to separate job - this wouldn't be optimisation.
@Wirone Wirone marked this pull request as ready for review November 2, 2023 15:40
.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
@keradus
Copy link
Member

keradus commented Nov 2, 2023

tons of good work, thanks!

@keradus keradus merged commit 16f8514 into PHP-CS-Fixer:master Nov 2, 2023
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic/ci Github Actions, tooling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants