From cd8bbdbb97adf2b31c89e52f5956351bf9c433b7 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Sun, 8 Oct 2023 09:46:03 +0100 Subject: [PATCH] build-configs(update) --- .gitignore | 114 ++++++++++++++---------------------------- docker-compose.yaml | 1 + justfile | 67 ------------------------- phpcs.xml.dist | 4 +- phpstan.neon.dist | 2 +- run | 118 ++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 159 insertions(+), 147 deletions(-) delete mode 100644 justfile create mode 100755 run diff --git a/.gitignore b/.gitignore index e8b9513..6227464 100644 --- a/.gitignore +++ b/.gitignore @@ -1,79 +1,39 @@ -# Ignore directories generated by Composer -/bin -/drush/contrib/ -/vendor/ -/web/core/ -/web/modules/contrib/ -/web/themes/contrib/ -/web/profiles/contrib/ -/web/libraries/ +# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs. -# Ignore composer.lock as this is template project -/composer.lock +.editorconfig +.env +.gitattributes +vendor/ +web/.csslintrc +web/.eslintignore +web/.eslintrc.json +web/.ht.router.php +web/.htaccess +web/INSTALL.txt +web/README.md +web/autoload.php +web/core/ +web/example.gitignore +web/index.php +web/modules/README.txt +web/modules/contrib/ +web/profiles/README.txt +web/robots.txt +web/sites/*/files/ +web/sites/*/private/ +web/sites/*/services*.yml +web/sites/*/settings*.php +web/sites/README.txt +web/sites/default/default.services.yml +web/sites/default/default.settings.php +web/sites/development.services.yml +web/sites/example.settings.local.php +web/sites/example.sites.php +web/sites/simpletest/ +web/themes/README.txt +web/themes/contrib/ +web/update.php +web/web.config -# Ignore sensitive information -/web/sites/*/settings*.php -/web/sites/*/services*.yml - -# Ignore Drupal's file directory -/web/sites/*/files/ - -# Ignore scaffold files -/.editorconfig -/.gitattributes -/web/.csslintrc -/web/.eslintignore -/web/.eslintrc.json -/web/.gitignore -/web/.ht.router.php -/web/.htaccess -/web/INSTALL.txt -/web/README.md -/web/README.txt -/web/autoload.php -/web/example.gitignore -/web/index.php -/web/modules/README.txt -/web/profiles/README.txt -/web/robots.txt -/web/sites/README.txt -/web/sites/default/default.services.yml -/web/sites/default/default.settings.php -/web/sites/development.services.yml -/web/sites/example.settings.local.php -/web/sites/example.sites.php -/web/themes/README.txt -/web/update.php -/web/web.config - -# Ignore SimpleTest multi-site environment -/web/sites/simpletest - -# Ignore IDE files -.idea/ -.vscode/ - -# Ignore .env files as they are personal -/.env - -# Ignore DB dumps -*.sql -*.sql.gz -*.mysql -*.mysql.gz - -# Ignore Lando overrides -.lando.local.yml - -# Ignore Lando Solr config -/.lando/solr - -# Ignore temp files -/.phpunit.result.cache - -# Ignore ddev configuration folders -.ddev/.global_commands/ -.ddev/commands/ -.ddev/homeadditions/ -.ddev/providers/ -.ddev/xhprof/ +# Docker +/docker-compose.override.yml diff --git a/docker-compose.yaml b/docker-compose.yaml index 0961d4a..fa1f56c 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -70,6 +70,7 @@ services: volumes: db-data: {} + networks: web: external: true diff --git a/justfile b/justfile deleted file mode 100644 index d43ad25..0000000 --- a/justfile +++ /dev/null @@ -1,67 +0,0 @@ -# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs. - - -default: - @just --list - -# Start the project -start: - cp -v --no-clobber .env.example .env - docker compose up -d - -# Stop the project -stop: - docker compose down - -composer *args: - just _exec php composer {{ args }} - -alias phpunit := test - -test *args: - just _exec php phpunit --colors=always {{ args }} - -test-watch *args: - nodemon --ext "*" --watch "." --exec "just test || exit 1" --ignore */sites/simpletest - -drush *args: - just _exec php drush {{ args }} - -install *args: - just _exec php drush site:install -y {{ args }} - - - - -# Enable or disable Git hooks -git-hooks command: - #!/usr/bin/env bash - set -euo pipefail - - case "{{ command }}" in - "on") - echo "Enabling Git hooks..." - git config core.hooksPath .githooks - ;; - "off") - echo "Disabling Git hooks..." - git config --unset core.hooksPath - ;; - *) - echo "Error: Invalid argument. Must be either 'on' or 'off'" - ;; - esac - - -_exec +args: - docker compose exec -T {{ args }} - -_run service command *args: - docker compose run \ - --entrypoint {{ command }} \ - --no-deps \ - --rm \ - -T \ - {{ service }} {{ args }} - -# vim: ft=just diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 81bd8ac..5613bdb 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -9,7 +9,7 @@ - + @@ -28,4 +28,4 @@ - + diff --git a/phpstan.neon.dist b/phpstan.neon.dist index bec183f..f2d48e1 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -6,4 +6,4 @@ parameters: - *Test.php - *TestBase.php paths: - - src + diff --git a/run b/run new file mode 100755 index 0000000..642e8a1 --- /dev/null +++ b/run @@ -0,0 +1,118 @@ +#!/usr/bin/env bash + +# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs. + +set -eu + +# Run automated tests as part of the Continuous Integration (CI) pipeline. +function ci:test { + lint:dockerfile + + docker compose version + + docker network create traefik_proxy + + cp --no-clobber .env.example .env + + docker compose build --progress plain + + docker compose up --detach + docker compose logs + + composer install --quiet --no-progress + + test --testdox + + quality +} + +# Run a command within the php container. +function cmd { + docker compose exec php "${@}" +} + +function coding-standards { + cmd phpcs "${@}" +} + +function composer { + _exec php composer "${@}" +} + +function drush { + _exec php drush "${@}" +} + +function git-hooks:off { + git config --unset core.hooksPath +} + +function git-hooks:on { + git config core.hooksPath .githooks +} + +# Display a list of all available commands. +function help { + printf "%s [args]\n\nTasks:\n" "${0}" + + compgen -A function | grep -v "^_" | cat -n + + printf "\nExtended help:\n Each task has comments for general usage\n" +} + +function lint:dockerfile { + docker container run --rm -i \ + hadolint/hadolint hadolint --ignore DL3008 --ignore DL3059 -t style "${@}" - < Dockerfile +} + +function quality { + coding-standards + static-analysis +} + +function start { + cp -v --no-clobber .env.example .env + + docker compose up -d +} + +function static-analysis { + cmd phpstan --memory-limit=-1 --no-progress "${@}" +} + +function stop { + docker compose down +} + +function test { + _exec php phpunit --colors=always "${@}" +} + +function test:commit { + test --testdox --testsuite functional + test --testdox --testsuite kernel + test --testdox --testsuite unit + + quality +} + +function _exec { + docker compose exec -T "${@}" +} + +function _run { + local service="${1}" + local command="${2}" + + docker compose run \ + --entrypoint "${command}" \ + --no-deps \ + --rm \ + -T \ + "${service}" "${@}" +} + +TIMEFORMAT=$'\nTask completed in %3lR' +time "${@:-help}" + +# vim: ft=bash