Skip to content

Commit

Permalink
Cleanly disabled [web-root]/.ht.router.php scaffolding + added to CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ambient-Impact committed May 25, 2024
1 parent 09139f3 commit 9057809
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
11 changes: 0 additions & 11 deletions .do/build/composer.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
#!/bin/bash

# We need to remove this since it's not used in production but it is needed for
# running PHPUnit functional tests in CI. Trying to conditionally remove it via
# 'composer config --unset extra.drupal-scaffold.file-mapping."[web-root]/.htaccess"'
# or multiple such variations with various characters in the last key escaped
# seem to have no effect, despite the fact that fetching the config by leaving
# out '--unset' works correctly.
#
# @todo Figure out why running the above command doesn't remove the key, add it
# back to the scaffold, and remove this command.
rm /workspace/web/.ht.router.php

# Dump optimized Composer autoloader using APCu for production.
#
# @see https://getcomposer.org/doc/articles/autoloader-optimization.md
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,27 @@ jobs:
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

# This file is set in our composer.json to not be scaffolded by default
# since it's not needed in production and local dev environments. However,
# it's not possible to run:
#
# composer config --unset \
# extra.drupal-scaffold.file-mapping."[web-root]/.ht.router.php"
#
# because Composer will ignore more than 3 nesting levels passed to the
# config command by design. Thankfully, it's possible to get the full
# JSON contents of the file-mapping key, which we can then modify with jq
# and set regardless of nesting level.
#
# @see https://getcomposer.org/doc/03-cli.md#modifying-extra-values
# Documentation states a max nesting level of 3.
#
# @see https://jqlang.github.io/jq/manual/
- name: Scaffold .ht.router.php for PHPUnit tests
run: composer config extra.drupal-scaffold.file-mapping --json \
$(composer config extra.drupal-scaffold.file-mapping | \
jq --compact-output 'del(."[web-root]/.ht.router.php")')

- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@
"[project-root]/.gitattributes": {
"append": "drupal_scaffold/gitattributes_append.txt"
},
"[web-root]/.ht.router.php": false,
"[web-root]/.htaccess": {
"prepend": "drupal_scaffold/htaccess_prepend.txt",
"append": "drupal_scaffold/htaccess_append.txt"
Expand Down

0 comments on commit 9057809

Please sign in to comment.