diff --git a/.gitignore b/.gitignore
index 5f7b4f8..ce74cdf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,50 +1,40 @@
-# This file contains default .gitignore rules. To use it, copy it to .gitignore,
-# and it will cause files like your settings.php and user-uploaded files to be
-# excluded from Git version control. This is a common strategy to avoid
-# accidentally including private information in public repositories and patch
-# files.
-#
-# Because .gitignore can be specific to your site, this file has a different
-# name; updating Drupal core will not override your custom .gitignore file.
+# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
-# Ignore core when managing all of a project's dependencies with Composer
-# including Drupal core.
-/web/
-!/web/modules/custom/
+.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 dependencies that are managed with Composer.
-# Generally you should only ignore the root vendor directory. It's important
-# that core/assets/vendor and any other vendor directories within contrib or
-# custom module, theme, etc., are not ignored unless you purposely do so.
-/vendor/
-# Ignore configuration files that may contain sensitive information.
-/web/*/settings*.php
-/web/*/services*.yml
+.dir-env/
-# Ignore paths that contain user-generated content.
-/web/*/files
-/web/*/private
-
-# Ignore multi-site test environment.
-/web/simpletest
-
-# If you prefer to store your .gitignore file in the sites/ folder, comment
-# or delete the previous settings and uncomment the following ones, instead.
-
-# Ignore configuration files that may contain sensitive information.
-# */settings*.php
-
-# Ignore paths that contain user-generated content.
-# */files
-# */private
-
-# Ignore multi-site test environment.
-# simpletest
-
-# Nix.
-/.direnv/
-
-/.editorconfig
-/.gitattributes
-/.phpunit.result.cache
diff --git a/.tmux b/.tmux
index 6131250..3356311 100755
--- a/.tmux
+++ b/.tmux
@@ -1,7 +1,5 @@
#!/usr/bin/env bash
-# Based on https://github.com/opdavies/dotfiles/blob/main/bin/t.
-
set -o errexit
set -o nounset
@@ -9,21 +7,21 @@ session_name="${1:-atdc}"
session_path="${2:-$(pwd)}"
if tmux has-session -t="${session_name}" 2> /dev/null; then
- tmux attach -t "${session_name}"
- exit
+ tmux attach -t "${session_name}" ||
+ tmux switch-client -t "${session_name}"
fi
tmux new-session -d -s "${session_name}" -n vim -c "${session_path}"
-# 1. Main window: Vim, server, shell
+# 1. Main window: Vim.
tmux send-keys -t "${session_name}:vim" "nvim" Enter
tmux split-pane -t "${session_name}:vim" -h -c "${session_path}" -p 40
-tmux send-keys -t "${session_name}:vim.right" "php -S 0.0.0.0:9000 -t web" Enter
-tmux split-pane -t "${session_name}:vim" -c "${session_path}" -v
-tmux send-keys -t "${session_name}:vim.bottom-right" "./run test && watch-changes web/modules/custom ./run test" Enter
+tmux send-keys -t "${session_name}:vim.right" "./run start" Enter
# 2. General shell use.
tmux new-window -t "${session_name}" -c "${session_path}"
tmux switch-client -t "${session_name}:vim.left" ||
tmux attach -t "${session_name}:vim.left"
+
+# vim: ft=bash
diff --git a/build.yaml b/build.yaml
new file mode 100644
index 0000000..419e152
--- /dev/null
+++ b/build.yaml
@@ -0,0 +1,12 @@
+name: atdc
+type: drupal
+language: php
+
+flake:
+ devshell:
+ packages:
+ - php82
+ - php82Packages.composer
+
+experimental:
+ createTmuxStartupFile: true
diff --git a/flake.lock b/flake.lock
index ec727d9..939f23d 100644
--- a/flake.lock
+++ b/flake.lock
@@ -72,16 +72,16 @@
},
"nixpkgs_2": {
"locked": {
- "lastModified": 1703200384,
- "narHash": "sha256-q5j06XOsy0qHOarsYPfZYJPWbTbc8sryRxianlEPJN0=",
+ "lastModified": 1706371002,
+ "narHash": "sha256-dwuorKimqSYgyu8Cw6ncKhyQjUDOyuXoxDTVmAXq88s=",
"owner": "NixOS",
"repo": "nixpkgs",
- "rev": "0b3d618173114c64ab666f557504d6982665d328",
+ "rev": "c002c6aa977ad22c60398daaa9be52f2203d0006",
"type": "github"
},
"original": {
"owner": "NixOS",
- "ref": "nixos-23.11",
+ "ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
diff --git a/flake.nix b/flake.nix
index c7efebc..2481116 100644
--- a/flake.nix
+++ b/flake.nix
@@ -1,7 +1,9 @@
+# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
+
{
inputs = {
devshell.url = "github:numtide/devshell";
- nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
+ nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = inputs@{ flake-parts, ... }:
@@ -12,7 +14,10 @@
perSystem = { config, self', inputs', pkgs, system, ... }: {
devshells.default = {
- packages = with pkgs; [ "php82" "php82Packages.composer" ];
+ packages = with pkgs; [
+ "php82"
+ "php82Packages.composer"
+ ];
};
};
};
diff --git a/phpcs.xml.dist b/phpcs.xml.dist
index 19bc6e5..9912848 100644
--- a/phpcs.xml.dist
+++ b/phpcs.xml.dist
@@ -1,13 +1,15 @@
+
+
PHPCS configuration file for atdc.
- web/modules/custom
-
+
-
-
+
+
+
@@ -26,5 +28,4 @@
-
-
+
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index 6a03a98..f1eddd0 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -1,6 +1,6 @@
parameters:
ignoreErrors:
-
- message: "#^Method Drupal\\\\example\\\\Controller\\\\BlogPageController\\:\\:create\\(\\) should return static\\(Drupal\\\\example\\\\Controller\\\\BlogPageController\\) but returns Drupal\\\\example\\\\Controller\\\\BlogPageController\\.$#"
+ message: "#^Method Drupal\\\\atdc\\\\Controller\\\\BlogPageController\\:\\:create\\(\\) should return static\\(Drupal\\\\atdc\\\\Controller\\\\BlogPageController\\) but returns Drupal\\\\atdc\\\\Controller\\\\BlogPageController\\.$#"
count: 1
- path: web/modules/custom/example/src/Controller/BlogPageController.php
+ path: web/modules/custom/atdc/src/Controller/BlogPageController.php
diff --git a/phpstan.neon.dist b/phpstan.neon.dist
index 9f2e38e..8a1dc84 100644
--- a/phpstan.neon.dist
+++ b/phpstan.neon.dist
@@ -1,7 +1,9 @@
-parameters:
- level: 5
- paths:
- - web/modules/custom/example
+# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
-includes:
- - phpstan-baseline.neon
+parameters:
+ level:
+ excludePaths:
+ - *Test.php
+ - *TestBase.php
+ paths:
+
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index fe237de..179546d 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -1,14 +1,37 @@
-
+
+
-
+
+
+
+
+
+
+
+
-
- ./web/modules/**
+
+ ./web/modules/custom/**/tests/**/Functional
+
+
+ ./web/modules/custom/**/tests/**/Kernel
+
+
+ ./web/modules/custom/**/tests/**/Unit
diff --git a/run b/run
index 652a577..4f786ac 100755
--- a/run
+++ b/run
@@ -1,9 +1,63 @@
#!/usr/bin/env bash
-set -o errexit
-set -o nounset
+# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
-PATH=${PATH}:./vendor/bin
+set -o errexit
+set -o pipefail
+
+# If we're running in CI we need to disable TTY allocation for docker compose
+# commands that enable it by default, such as exec and run.
+TTY="${TTY:-}"
+if [[ ! -t 1 ]]; then
+ TTY="-T"
+fi
+
+# 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 {
@@ -14,10 +68,67 @@ function help {
printf "\nExtended help:\n Each task has comments for general usage\n"
}
-# Run PHPUnit tests.
-function test {
- paratest --group lessons "${@}"
+# Install Drupal.
+function install {
+ drush site:install -y "${@}"
}
+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 || true
+
+ 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 ${TTY} "${@}"
+}
+
+function _run {
+ local service="${1}"
+ local command="${2}"
+
+ docker compose run \
+ --entrypoint "${command}" \
+ --no-deps \
+ --rm \
+ ${TTY} \
+ "${service}" "${@}"
+}
+
+# Include any local tasks.
+[[ -e run.local ]] && source run.local
+
TIMEFORMAT=$'\nTask completed in %3lR'
time "${@:-help}"
+
+# vim: ft=bash
diff --git a/run.local b/run.local
new file mode 100755
index 0000000..d9a6948
--- /dev/null
+++ b/run.local
@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+
+function start {
+ php -S 0.0.0.0:9000 -t web
+}
+
+function test {
+ phpunit --colors=always "${@}"
+}
+
+# vim: ft=bash