- Issue created by @jonathan1055
- First commit to issue fork.
- 🇬🇧United Kingdom jonathan1055
You got there before me.
Tested locally and it works as expected.I suggest for extra safety we also add
| head -1
afterwards. I know that having two "type:" would be invalid config, but we should avoid generating a badbuild.env
even in that scenario. I have made this suggestion in the MR. - 🇬🇧United Kingdom jonathan1055
Updated IS.
For info, the change that caused this is in the tagged 1.6.10 release, but the default-ref is still 1.6.9, so most of Contrib will not be affected.
See https://git.drupalcode.org/project/gitlab_templates/-/commits/1.6.x-late... - 🇬🇧United Kingdom longwave UK
I wondered about adding the same thing after I did the initial fix, I think it's a good idea. I was trying to see if there was a way of doing it directly in
sed
buthead
is easier to understand anyway. - 🇬🇧United Kingdom longwave UK
In fact let's be bold and mark this RTBC as we both agree on the solution here.
- 🇬🇧United Kingdom jonathan1055
Is it valid yml to have a space after the keyword, before the colon? I know we don't do that much but I think it might be allowed.
- 🇬🇧United Kingdom longwave UK
Probably we shouldn't use regex at all, as there still could be false positives if we ever use nested structures in the YAML, or heredocs, or anything similar.
MR!306 uses a pure PHP solution instead which works for me inside
drupalci/php-8.3-ubuntu-apache:production
. - 🇬🇧United Kingdom jonathan1055
Nice idea, but I would suggest it's a little bit over-the-top to use php to parse the yml file to get just this one key. I think that the regex version is fine for now, it is simple and if we take the first "type:" found it will nearly always be the required value. On the times when this does not, we already have the override capability to set the variable
PROJECT_TYPE
in the project's .gitlab-ci.yml. If I hadn't asked the question in #10 then you would probably have left it at RTBC and not started the second MR :-) - 🇬🇧United Kingdom jonathan1055
Actually I have realized that we don't already cater for overriding the project type, only the project name. So I have pushed a change to MR305 for this - essentially just swapping round the two clauses to allow for a condition on the else too.
https://git.drupalcode.org/project/gitlab_templates/-/merge_requests/305... - 🇬🇧United Kingdom jonathan1055
Tested MR305 with a normal .info.yml file. The project name and project type are derived correctly.
https://git.drupalcode.org/issue/scheduler-3445052/-/pipelines/364767Tested with extra type: in a comment and a second type: keyword.
https://git.drupalcode.org/issue/scheduler-3445052/-/commit/77fdc469e936...
The yml is invalid (as shown by eslint) but the composer job still does not create a bad build.env
https://git.drupalcode.org/issue/scheduler-3445052/-/pipelines/364793Tested with an override in the UI form - worked as expected, the form value is shown in the composer log
https://git.drupalcode.org/issue/scheduler-3445052/-/pipelines/364801 - 🇬🇧United Kingdom longwave UK
longwave → changed the visibility of the branch 3492927-php-solution to hidden.
- 🇬🇧United Kingdom longwave UK
Alright, let's just go with the hardened regex. The suggested changes look good to me.
- First commit to issue fork.
-
fjgarlin →
committed b7e9bd18 on main authored by
longwave →
Issue #3492927 by longwave, jonathan1055: Fix regex when parsing info....
-
fjgarlin →
committed b7e9bd18 on main authored by
longwave →
- 🇪🇸Spain fjgarlin
Merged. Thanks both for working on this and reviewing/testing.
- 🇬🇧United Kingdom jonathan1055
Now that MR305 has been merged can we close MR306 ?