Problem/Motivation
In drupalci.yml we currently copy and edit core's commit-code-check.sh file and then run it.
This means we can't run this easily locally. So if there is problem with the script we can only know if it fails or if we check the drupalci output. So miss problems like this #3342120: Fix PHPStan violations (happened because PHPStan code checks stopped running…)
Steps to reproduce
Proposed resolution
run drupalci on this issue and save the edited version commit-code-check.sh then commit it
can drupalci.yml to just run the committed version
Stop using commit-code-check.sh in favor of a handful of simple commands that A) are a lot easier to debug on DrupalCI, B) can also be run locally quite easily.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #31 | 3343430-31.patch | 1.12 KB | tedbow |
| #27 | 3343430-26_plus_3342120.patch | 32.82 KB | wim leers |
| #27 | interdiff.txt | 24.28 KB | wim leers |
| #26 | 3343430-26.patch | 8.67 KB | wim leers |
| #26 | interdiff.txt | 732 bytes | wim leers |
Issue fork automatic_updates-3343430
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
wim leersWell well … as promised during yesterday's meeting, I looked into solving this challenge in core. So I found @phenaproxima's #3314100: Make it possible for contrib modules to reuse core's commit-code-check.sh which is blocked on #3314151: Fix cspell use: specify globRoot and always pass --root to cspell. So I spent yesterday solving that.
In doing so, I discovered Drupal core had not been running PHPStan/cspell/… either!
I reported that very late in my day yesterday and overnight it was fixed in #3343495: Fix commit-code-check.sh on DrupalCI.
Now that is out of the way, AU's script is failing in a different way:
@omkar.podey is investigating this at #3341224-14: Always catch \Throwable, not \Exception, and pass the old exception when re-throwing..
Comment #5
wim leersComment #6
wim leersI left out the juiciest bit in #4:
→ the problems in #4 are just the early ones, PHPSTan eventually runs forever and that's really the problem here.
I don't see yet how #3343495: Fix commit-code-check.sh on DrupalCI could cause this.
Still investigating over at #3341224: Always catch \Throwable, not \Exception, and pass the old exception when re-throwing.…
Comment #7
wim leersUpdate:
set -xevhelps us understand this:— https://dispatcher.drupalci.org/job/drupal8_contrib_patches/145897/console
→ it appears that
phpcsis not installed? That seems odd.also: I was wrong in #6: that output shows pretty clearly that
phpstanfinishes just fine; the next thing to run isphpcs, and that's what fails/runs forever! Somehow 😳 So that could be explained by the above. Although it's then pretty mysterious why the error would have be swallowed prior to theset -xev…🕵️♀️
Comment #8
wim leersWhile breaking my head over this, here's an alternative attempted work-around…
Comment #9
wim leersThat worked for
phpcsandphpstan, but not yetcspellandeslint. Adding debug output…Comment #10
wim leersAh, so
/var/www/html/coreis not thecoresubdirectory of core…Comment #11
wim leersMore debug output. This is very confusing.
Comment #12
wim leersUpdating status per #3341224-16: Always catch \Throwable, not \Exception, and pass the old exception when re-throwing..
Comment #13
wim leersLooks like
cdresults are lost in this context … so let's put it all in a single line instead then.Comment #14
wim leersIn the proposed resolution, we would have committed a copy of
commit-code-check.shthat hardcodes DrupalCI's absolute paths, so it still would not have worked locally…Besides, no module is even remotely as big as Drupal core. So the many optimizations in that script to only check the files that have changed is really premature optimization/unjustifiable complexity.
So … we can make this 💯 times simpler.
Comment #15
wim leersComment #16
wim leers#15 works.
phpcsand finds a violation that is indeed a problem that landed yesterday in #3334994: Add new InstalledPackagesList which does not rely on Composer API to get package info, but we didn't notice because DrupalCI was broken 👍phpstanviolations that #3342120: Fix PHPStan violations (happened because PHPStan code checks stopped running…) is fixing. 👍drupalci.ymlfile — this is the sole thing that probably needs double-checking — running the same command locally definitely detects a wrongly formatted routes YAML file!Need confirmation that we want to go this direction. Only
cspelldictionary and thedrupalci.ymlproblems remain to be solved, other than that this is already ready!Comment #17
wim leersDiscussed with @tedbow and @phenaproxima. They're on board! 🥳
Let's finish this.
Comment #18
wim leers30 minutes searching for this … 😬
cspell's DX can be improved quite a bit still…Comment #19
wim leersYay, many more failures now — #15 was not yet scanning the entire module!
Thanks to https://github.com/streetsidesoftware/cspell/pull/966, we can easily make
cspelldiscover our dictionary 👍Comment #20
wim leerspcre.iniandREADME.md, neither of which will go into core anyway--no-progresssocspell's output is not ridiculously overwhelming and detailed.Comment #21
wim leersMoved it all into a script:
scripts/commit-code-check.sh. And calling that. So that delivers on @tedbow's original hope/vision 😊Comment #22
wim leersMake
--drupalciflag work andchmod a+x.Comment #23
wim leersWhoops, that
$FINAL_STATUSwas not yet being respected.Comment #24
wim leersSimplify by introducing a few bash functions, that also allows for much better consistency!
Comment #25
wim leers#24 looks like this:

Comment #26
wim leersFix the
phpcsviolation that landed last night.Comment #27
wim leersMerging in #3342120: Fix PHPStan violations (happened because PHPStan code checks stopped running…) by doing
curl https://git.drupalcode.org/project/automatic_updates/-/merge_requests/708.diff | git apply -3v && git ci -nam "Yash's phpstan fixes"and generating a new patch — this should be green 🤓Comment #28
wim leersLooks like @yash still has some work cut out for him!
Please commit #26 first right now, so that @yash.rode can continue in #3342120: Fix PHPStan violations (happened because PHPStan code checks stopped running…) tomorrow :)
(If you prefer, you could choose to disable the
phpstanchecking by commenting that one line in there, but I think that's not really helping us.)For the committer:
This is really how we run tests.
Everything else is for:
- documentation
- supporting a
--drupalciflag, just like core's script- setting up variables for colored output, just like core's script
- existing the script with a computed "final status" just like the core script
- discovering the core directory
… but with far less repetition thanks to
print_seprator,print_titleandprint_resultshelper functionsComment #30
tedbow@Wim Leers 🙏🙏🙏🙏🙏🙏🙏🙏
I committed this with the phpstan part commented out but just pushed a change to #3342120: Fix PHPStan violations (happened because PHPStan code checks stopped running…) that uncomments this
Comment #31
tedbowWorking on possible follow-upJoke, feel free to ignore😜Comment #32
wim leersThat is one weird follow-up 🤣 Where are you going with that?!
Comment #33
wim leersExtracted some of the key simplifications this has compared to core's script into a core patch: #3343919: Simplify commit-code-check.sh: reduce repetition.
Comment #34
wim leersThis was blocking the path to core for sure!