Skip to content

Commit

Permalink
Handle modules with no phpunit.xml file
Browse files Browse the repository at this point in the history
  • Loading branch information
joecorall committed Oct 30, 2024
1 parent 946c4f6 commit 138d5cb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ jobs:
with:
dockerfile: Dockerfile
verbose: true

- name: check valid sh
run: shellcheck **/*.sh

build-push:
needs: [lint]
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ENV DRUPAL_DIR=/var/www/drupal
ENV SIMPLETEST_DB=sqlite://localhost/default
ENV LINT=1
ENV DRUPAL_PRACTICE=1
ENV SIMPLETEST_BASE_URL=http://127.0.0.1:8282

WORKDIR $DRUPAL_DIR

Expand Down
28 changes: 12 additions & 16 deletions scripts/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ if [ "$LINT" -eq 1 ]; then
fi
fi

echo "Starting test server"
drush rs --quiet $SIMPLETEST_BASE_URL &
until curl -s "$SIMPLETEST_BASE_URL"; do true; done > /dev/null

# test
PHPUNIT_FILE=web/core/phpunit.xml.dist
if [ -v ENABLE_MODULES ]; then
composer config --no-interaction allow-plugins true
for MODULE in $ENABLE_MODULES; do
Expand All @@ -38,11 +41,7 @@ if [ -v ENABLE_MODULES ]; then
fi

DIR=$(dirname "$INFO_FILE")
if [ -f "$DIR/phpunit.xml" ]; then
PHPUNIT_FILE="$DIR/phpunit.xml"
fi
COMPOSER_JSON="$DIR/composer.json"

if [ -f "$COMPOSER_JSON" ]; then
dependencies=$(jq -r '.require | to_entries[] | "\(.key):\(.value)"' "$COMPOSER_JSON")
if [ -n "$dependencies" ]; then
Expand All @@ -59,15 +58,12 @@ if [ -v ENABLE_MODULES ]; then
fi
done

echo "Enabling $ENABLE_MODULES"
drush -y en "$ENABLE_MODULES"
echo "Running phpunit"
if [ -f "$DIR/phpunit.xml" ]; then
cp "$DIR/phpunit.xml" "$DRUPAL_DIR/web/core/"
cd "$DRUPAL_DIR/web/core"
"$DRUPAL_DIR"/vendor/bin/phpunit --debug
else
vendor/bin/phpunit -c web/core/phpunit.xml.dist --debug "$DIR"
fi
fi

echo "Starting test server"
drush rs --quiet 127.0.0.1:8282 &
until curl -s http://127.0.0.1:8282/; do true; done > /dev/null

echo "Running phpunit"
cp "$PHPUNIT_FILE" web/core/phpunit.xml
cd "$DRUPAL_DIR/web/core"
"$DRUPAL_DIR"/vendor/bin/phpunit --debug

0 comments on commit 138d5cb

Please sign in to comment.