Allow copying or symlinking when building the project
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3425971. --> Reported by: [fjgarlin](https://www.drupal.org/user/2495842) Related to !414 >>> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>Maybe we don't need to do anything, or maybe we do.<br> <span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-7"><a href="https://www.drupal.org/project/gitlab_templates/issues/3397699" title="Status: Closed (fixed)">#3397699: Preserve original composer.json in the modules directory</a></span> and <span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-7"><a href="https://www.drupal.org/project/gitlab_templates/issues/3418831" title="Status: Closed (fixed)">#3418831: Test-only job</a></span> both led to the conclusion that our current building process is not ideal, as it modifies files from the project, so it's hard when we need to do <code>git diff</code> in MR-based workflows, or we have some issues with the symlinks (like when creating the <code>cspell</code> job).</p> <p>So, quoting from one of those comments:</p> <blockquote><p>We could change the approach to building the project so that the original repo folder is pristine. For example: we could create a brand new folder, bring Drupal via composer there and do the expand_composer in that other folder. We'd just need to adjust the apache webroot paths after that. It's not a quick and easy one, but it's not a super complex one either.</p></blockquote> <p>Obviously, things are NOT broken, so they might not need fixing, but doing a refactoring that makes everything tidier and avoids the mentioned side effects might be a nice to have, and if we do it in a way that is fully BC then it might be worth exploring.</p> <h4 id="summary-steps-reproduce">Steps to reproduce</h4> <p>Do a <code>git diff</code> after the composer step and you'll see that the "composer.json" file appears as changed, even tho we are preserving the pristine copy in the symlinked folder (git diff runs in the root folder).</p> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <p>Explore a different setup process.</p> <h3 id="summary-remaining-tasks">Actual solution implemented</h3> <ul> <li>Add a new variable <code>_COMPOSER_SYMLINK</code> which can be set in .gitlab-ci.yml or via form UI</li> <li>The default is 1 to preserve the existing behavior</li> <li>Set to 0 to make copies of the project's files and folders, instead of symlinks</li> </ul> <p>Details start from <a href="https://www.drupal.org/project/gitlab_templates/issues/3425971#comment-15708493">comment #5</a></p> > Related issue: [Issue #3501054](https://www.drupal.org/node/3501054) > Related issue: [Issue #3546508](https://www.drupal.org/node/3546508) > Related issue: [Issue #3418831](https://www.drupal.org/node/3418831)
issue