- Issue created by @jonathan1055
- 🇬🇧United Kingdom jonathan1055I know that we coud say that if any custom before_script were to change the working directory then it ought to restore it too. But that is extra effort for the developer, they either have to know where to set the directory, or store it in a variable for use at the end. It is far simpler and very easy for the templates to make sure each script: starts in the required working directory. 
- Merge request !327#3503966 Ensure that each script starts in expected directory → (Merged) created by jonathan1055
- 🇬🇧United Kingdom jonathan1055I've pushed the initial changes For info, I checked and none of the following need any specific directory, but I still prefer to have the cdas the very first line in thescript:
 *check-composer-end-code
 *show-environment-variables
 *setup-webserver
 *simpletest-db
 *show-context*amend-core-requirements-next-majoralready saves and restores the current directory.Summary of changesAdded default cd $CI_PROJECT_DIR && pwdto- .composer-base
- pages:
- composer-lint:
- phpcs:
- upgrade status:
- cspell
- .phpunit-base
- test-only changes:
 Changed from relative to absolute- stylelint: has relative cd $_WEB_ROOT so made this absolute $CI_PROJECT_DIR/$_WEB_ROOT
- .nightwatch-base has relative cd $_WEB_ROOT so changed this to absolute $CI_PROJECT_DIR/$_WEB_ROOT
 Not changed (except for adding pwd)- .phpstan-base already has cd $CI_PROJECT_DIR/$_WEB_ROOT/modules/custom/$CI_PROJECT_NAME
- eslint: already has cd $CI_PROJECT_DIR/$_WEB_ROOT/modules/custom/$CI_PROJECT_NAME
 In main-d7 did the same - added to default to .composer-base, phpcs, .phpunit-base, test-only changes Ready for testing and feedback 
- 🇬🇧United Kingdom jonathan1055I've tested this MR on Scheduler 
 https://git.drupalcode.org/issue/scheduler-3445052/-/pipelines/415134
 Thecd && pwdall seem fine in the log. It has all the jobs except Nightwatch and Upgrade Status.
- 🇪🇸Spain fjgarlinDownstream pipelines: https://git.drupalcode.org/issue/gitlab_templates-3503966/-/pipelines/41... The changes look good. RTBC. 
- 🇬🇧United Kingdom jonathan1055To make sure, I have just added cd .. && echo "directory changed" && pwdto everybefore_script:in this test.
 https://git.drupalcode.org/issue/scheduler-3445052/-/pipelines/415668
 The logs show the change, but everything ran OK.This improvement will help with the custom before_script work, that's why I switched to progressing this issue first. 
- 
            
              fjgarlin →
             committed 24835a04 on main authored by 
            
              jonathan1055 →
            
Issue #3503966 by jonathan1055, fjgarlin: Make sure each script: starts... 
 
- 
            
              fjgarlin →
             committed 24835a04 on main authored by 
            
              jonathan1055 →
            
- 🇬🇧United Kingdom jonathan1055I have found a small error in the commit from this MR, there is a double $$in the 'test-only chnages'
 The job still runs fine, it just shows an error in the log. This is no worse than before, because if anyone had changed the working directory in a test-only changes before_script they would already have had to reset it.I have fixed it in MR331 in 📌 Create environment variable for the project's own folder Active and I think this will be fine to wait and do it here. I don't think we need to fix it immediately and make another default release, because it won't be long until this is done. It would be nice to get a phpunit test job in each of the GTD branches, then we can have a BEFORE_SCRIPT_ACTIONSkey to somehow trigger a 'test-only changes' job. That might need some ingenuity as that job only works on MRs. But we can solve that when we get there.
- 🇪🇸Spain fjgarlinOh, I saw the commit fixing it in the other issue but I thought that it was part of that MR only, I didn't realize it came from here. I'll merge the other one soon anyway, and if I get a RTBC on this one 🐛 Tags contained in manual rebase of issue fork triggers pipelines Active , I can even make a new release. 
- Automatically closed - issue fixed for 2 weeks with no activity.