From 6a7cbe53c0dda4a2eb400faeff62d04e99192511 Mon Sep 17 00:00:00 2001 From: Greg Harvey Date: Tue, 15 Jul 2025 12:53:47 +0200 Subject: [PATCH 1/3] Fixing errors caused by missing variable in when clause. --- roles/tests/tests_behat/tasks/main.yml | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/roles/tests/tests_behat/tasks/main.yml b/roles/tests/tests_behat/tasks/main.yml index 52c81012..9a016ec7 100644 --- a/roles/tests/tests_behat/tasks/main.yml +++ b/roles/tests/tests_behat/tasks/main.yml @@ -32,19 +32,18 @@ - behat.fail_builds - name: Run Behat command without failing build. - ansible.builtin.command: - cmd: "{{ behat.bin }} --config={{ behat.config_file }} --tags={{ behat.tags }} {{ _behat_outputs }}" - chdir: "{{ behat.working_dir }}" - register: _tests_behat_output # if we do not fail the build, we do not see the output if tests fail - failed_when: false when: - behat.outputs | length > 0 - not behat.fail_builds + block: + - name: Run Behat command. + ansible.builtin.command: + cmd: "{{ behat.bin }} --config={{ behat.config_file }} --tags={{ behat.tags }} {{ _behat_outputs }}" + chdir: "{{ behat.working_dir }}" + register: _tests_behat_output # if we do not fail the build, we do not see the output if tests fail + failed_when: false -- name: Show Behat output. - ansible.builtin.debug: - msg: "{{ _tests_behat_output.stdout }}" - when: - - _tests_behat_output is defined - - _tests_behat_output.stdout - - behat.show_results + - name: Show Behat output. + ansible.builtin.debug: + msg: "{{ _tests_behat_output.stdout }}" + when: behat.show_results From f6d7a5696c4e6e4439871fa00a6dbf5562042166 Mon Sep 17 00:00:00 2001 From: Greg Harvey Date: Wed, 16 Jul 2025 15:13:16 +0200 Subject: [PATCH 2/3] Making testing roles default to live_symlink_dest instead of deploy_path, in case of track file problems. --- roles/tests/tests_behat/defaults/main.yml | 6 +++--- roles/tests/tests_diffy/defaults/main.yml | 4 ++-- roles/tests/tests_phpcs/defaults/main.yml | 4 ++-- roles/tests/tests_phpunit/defaults/main.yml | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/roles/tests/tests_behat/defaults/main.yml b/roles/tests/tests_behat/defaults/main.yml index 6e2299b9..1f97d701 100644 --- a/roles/tests/tests_behat/defaults/main.yml +++ b/roles/tests/tests_behat/defaults/main.yml @@ -5,10 +5,10 @@ behat: verbose: false # set to true for verbose output fail_builds: true # set to false if you do not want Ansible to stop if Behat tests fail show_results: true # if `fail_builds: false` then show_results allows us to optionally show Behat test results in the Ansible output - bin: "{{ deploy_path }}/vendor/bin/behat" # location of Behat + bin: "{{ live_symlink_dest }}/vendor/bin/behat" # location of Behat # List of outputs to create, defaults to 'pretty' to STDOUT outputs: - format: pretty # options are pretty, progress or junit output: std # see docs for more information, supports output filepath or various formats - config_file: "{{ deploy_path }}/tests/behat/behat.yml" # path to config file - working_dir: "{{ deploy_path }}" # path to execute composer from + config_file: "{{ live_symlink_dest }}/tests/behat/behat.yml" # path to config file + working_dir: "{{ live_symlink_dest }}" # path to execute composer from diff --git a/roles/tests/tests_diffy/defaults/main.yml b/roles/tests/tests_diffy/defaults/main.yml index 75a08973..36ebdae6 100644 --- a/roles/tests/tests_diffy/defaults/main.yml +++ b/roles/tests/tests_diffy/defaults/main.yml @@ -6,5 +6,5 @@ diffy: main_env: dev # name of the 'good' environment to compare against (must be pre-configured in diffy) test_env: custom # name of the environment to be compared (usually diffy's default 'custom' environment) test_env_url: "" # set a base URL to use against the diffy 'custom' environment - bin: "{{ deploy_path }}/vendor/bin/diffy" # location of diffy - working_dir: "{{ deploy_path }}" # path to execute composer and related binaries from + bin: "{{ live_symlink_dest }}/vendor/bin/diffy" # location of diffy + working_dir: "{{ live_symlink_dest }}" # path to execute composer and related binaries from diff --git a/roles/tests/tests_phpcs/defaults/main.yml b/roles/tests/tests_phpcs/defaults/main.yml index 0dbaaa00..490d6679 100644 --- a/roles/tests/tests_phpcs/defaults/main.yml +++ b/roles/tests/tests_phpcs/defaults/main.yml @@ -2,8 +2,8 @@ phpcs: install: false # set to true if you want ce-deploy to attempt to composer install PHP CodeSniffer install_drupal_coder: false # set to true to install the Coder module for Drupal, which provides a Drupal standard for CodeSniffer - bin: "{{ deploy_path }}/vendor/bin/phpcs" # location of phpcs + bin: "{{ live_symlink_dest }}/vendor/bin/phpcs" # location of phpcs standard: "" # optionally set the path to an installed standard, for example "vendor/drupal/coder/coder_sniffer/Drupal" for the Coder module for Drupal extensions: "" # set optional extensions, for example for Drupal you could set "php,module,inc,theme,install" - defaults to "php,inc/php,js,css" test_paths: [] # list of paths to test against - working_dir: "{{ deploy_path }}" # path to execute composer from + working_dir: "{{ live_symlink_dest }}" # path to execute composer from diff --git a/roles/tests/tests_phpunit/defaults/main.yml b/roles/tests/tests_phpunit/defaults/main.yml index 06c52987..f7be016b 100644 --- a/roles/tests/tests_phpunit/defaults/main.yml +++ b/roles/tests/tests_phpunit/defaults/main.yml @@ -3,6 +3,6 @@ phpunit: install: false # set to true if you want ce-deploy to attempt to composer install phpunit group: unit # comma separated list of group names to run target: ../modules # directory or file to test, defaults to Drupal's modules directory - bin: "{{ deploy_path }}/vendor/bin/phpunit" # location of phpunit - tests_path: "{{ deploy_path }}/{{ webroot }}/core" # directory containing the PHPUnit 'tests' directory, defaults to Drupal's core directory - working_dir: "{{ deploy_path }}" # path to execute composer from + bin: "{{ live_symlink_dest }}/vendor/bin/phpunit" # location of phpunit + tests_path: "{{ live_symlink_dest }}/{{ webroot }}/core" # directory containing the PHPUnit 'tests' directory, defaults to Drupal's core directory + working_dir: "{{ live_symlink_dest }}" # path to execute composer from From 347b9211ff8ad2ff3cf9e1164727d1232077e636 Mon Sep 17 00:00:00 2001 From: Greg Harvey Date: Wed, 16 Jul 2025 15:15:24 +0200 Subject: [PATCH 3/3] Updating docs. --- docs/roles/_init.md | 1 + docs/roles/tests/tests_behat.md | 6 +++--- docs/roles/tests/tests_diffy.md | 4 ++-- docs/roles/tests/tests_phpcs.md | 4 ++-- docs/roles/tests/tests_phpunit.md | 6 +++--- roles/_init/README.md | 1 + roles/tests/tests_behat/README.md | 6 +++--- roles/tests/tests_diffy/README.md | 4 ++-- roles/tests/tests_phpcs/README.md | 4 ++-- roles/tests/tests_phpunit/README.md | 6 +++--- 10 files changed, 22 insertions(+), 20 deletions(-) diff --git a/docs/roles/_init.md b/docs/roles/_init.md index c1a92bc6..f9d93faa 100644 --- a/docs/roles/_init.md +++ b/docs/roles/_init.md @@ -23,6 +23,7 @@ lock_file: /tmp/ce-deploy-lock provision_lock_file: /tmp/ce-provision-lock # must match _init.lock_file in ce-provision skip_build_path_check: false # by default we're checking if track number matches keep_builds: 10 # the number of builds to keep in the build history, includes associated databases +build_cleanup_pattern: "{{ project_name }}_{{ build_type }}_build_*" # name pattern of the builds to be checked for cleanup # Application specific variables. drupal: drush_verbose_output: false diff --git a/docs/roles/tests/tests_behat.md b/docs/roles/tests/tests_behat.md index aeadd500..491759ca 100644 --- a/docs/roles/tests/tests_behat.md +++ b/docs/roles/tests/tests_behat.md @@ -14,13 +14,13 @@ behat: verbose: false # set to true for verbose output fail_builds: true # set to false if you do not want Ansible to stop if Behat tests fail show_results: true # if `fail_builds: false` then show_results allows us to optionally show Behat test results in the Ansible output - bin: "{{ deploy_path }}/vendor/bin/behat" # location of Behat + bin: "{{ live_symlink_dest }}/vendor/bin/behat" # location of Behat # List of outputs to create, defaults to 'pretty' to STDOUT outputs: - format: pretty # options are pretty, progress or junit output: std # see docs for more information, supports output filepath or various formats - config_file: "{{ deploy_path }}/tests/behat/behat.yml" # path to config file - working_dir: "{{ deploy_path }}" # path to execute composer from + config_file: "{{ live_symlink_dest }}/tests/behat/behat.yml" # path to config file + working_dir: "{{ live_symlink_dest }}" # path to execute composer from ``` diff --git a/docs/roles/tests/tests_diffy.md b/docs/roles/tests/tests_diffy.md index beb270dd..e7b646c4 100644 --- a/docs/roles/tests/tests_diffy.md +++ b/docs/roles/tests/tests_diffy.md @@ -27,8 +27,8 @@ diffy: main_env: dev # name of the 'good' environment to compare against (must be pre-configured in diffy) test_env: custom # name of the environment to be compared (usually diffy's default 'custom' environment) test_env_url: "" # set a base URL to use against the diffy 'custom' environment - bin: "{{ deploy_path }}/vendor/bin/diffy" # location of diffy - working_dir: "{{ deploy_path }}" # path to execute composer and related binaries from + bin: "{{ live_symlink_dest }}/vendor/bin/diffy" # location of diffy + working_dir: "{{ live_symlink_dest }}" # path to execute composer and related binaries from ``` diff --git a/docs/roles/tests/tests_phpcs.md b/docs/roles/tests/tests_phpcs.md index dd3f4870..457a8a38 100644 --- a/docs/roles/tests/tests_phpcs.md +++ b/docs/roles/tests/tests_phpcs.md @@ -61,11 +61,11 @@ See the installation documentation on packagist: https://packagist.org/packages/ phpcs: install: false # set to true if you want ce-deploy to attempt to composer install PHP CodeSniffer install_drupal_coder: false # set to true to install the Coder module for Drupal, which provides a Drupal standard for CodeSniffer - bin: "{{ deploy_path }}/vendor/bin/phpcs" # location of phpcs + bin: "{{ live_symlink_dest }}/vendor/bin/phpcs" # location of phpcs standard: "" # optionally set the path to an installed standard, for example "vendor/drupal/coder/coder_sniffer/Drupal" for the Coder module for Drupal extensions: "" # set optional extensions, for example for Drupal you could set "php,module,inc,theme,install" - defaults to "php,inc/php,js,css" test_paths: [] # list of paths to test against - working_dir: "{{ deploy_path }}" # path to execute composer from + working_dir: "{{ live_symlink_dest }}" # path to execute composer from ``` diff --git a/docs/roles/tests/tests_phpunit.md b/docs/roles/tests/tests_phpunit.md index bc5c64e2..8386926b 100644 --- a/docs/roles/tests/tests_phpunit.md +++ b/docs/roles/tests/tests_phpunit.md @@ -32,9 +32,9 @@ phpunit: install: false # set to true if you want ce-deploy to attempt to composer install phpunit group: unit # comma separated list of group names to run target: ../modules # directory or file to test, defaults to Drupal's modules directory - bin: "{{ deploy_path }}/vendor/bin/phpunit" # location of phpunit - tests_path: "{{ deploy_path }}/{{ webroot }}/core" # directory containing the PHPUnit 'tests' directory, defaults to Drupal's core directory - working_dir: "{{ deploy_path }}" # path to execute composer from + bin: "{{ live_symlink_dest }}/vendor/bin/phpunit" # location of phpunit + tests_path: "{{ live_symlink_dest }}/{{ webroot }}/core" # directory containing the PHPUnit 'tests' directory, defaults to Drupal's core directory + working_dir: "{{ live_symlink_dest }}" # path to execute composer from ``` diff --git a/roles/_init/README.md b/roles/_init/README.md index c1a92bc6..f9d93faa 100644 --- a/roles/_init/README.md +++ b/roles/_init/README.md @@ -23,6 +23,7 @@ lock_file: /tmp/ce-deploy-lock provision_lock_file: /tmp/ce-provision-lock # must match _init.lock_file in ce-provision skip_build_path_check: false # by default we're checking if track number matches keep_builds: 10 # the number of builds to keep in the build history, includes associated databases +build_cleanup_pattern: "{{ project_name }}_{{ build_type }}_build_*" # name pattern of the builds to be checked for cleanup # Application specific variables. drupal: drush_verbose_output: false diff --git a/roles/tests/tests_behat/README.md b/roles/tests/tests_behat/README.md index aeadd500..491759ca 100644 --- a/roles/tests/tests_behat/README.md +++ b/roles/tests/tests_behat/README.md @@ -14,13 +14,13 @@ behat: verbose: false # set to true for verbose output fail_builds: true # set to false if you do not want Ansible to stop if Behat tests fail show_results: true # if `fail_builds: false` then show_results allows us to optionally show Behat test results in the Ansible output - bin: "{{ deploy_path }}/vendor/bin/behat" # location of Behat + bin: "{{ live_symlink_dest }}/vendor/bin/behat" # location of Behat # List of outputs to create, defaults to 'pretty' to STDOUT outputs: - format: pretty # options are pretty, progress or junit output: std # see docs for more information, supports output filepath or various formats - config_file: "{{ deploy_path }}/tests/behat/behat.yml" # path to config file - working_dir: "{{ deploy_path }}" # path to execute composer from + config_file: "{{ live_symlink_dest }}/tests/behat/behat.yml" # path to config file + working_dir: "{{ live_symlink_dest }}" # path to execute composer from ``` diff --git a/roles/tests/tests_diffy/README.md b/roles/tests/tests_diffy/README.md index beb270dd..e7b646c4 100644 --- a/roles/tests/tests_diffy/README.md +++ b/roles/tests/tests_diffy/README.md @@ -27,8 +27,8 @@ diffy: main_env: dev # name of the 'good' environment to compare against (must be pre-configured in diffy) test_env: custom # name of the environment to be compared (usually diffy's default 'custom' environment) test_env_url: "" # set a base URL to use against the diffy 'custom' environment - bin: "{{ deploy_path }}/vendor/bin/diffy" # location of diffy - working_dir: "{{ deploy_path }}" # path to execute composer and related binaries from + bin: "{{ live_symlink_dest }}/vendor/bin/diffy" # location of diffy + working_dir: "{{ live_symlink_dest }}" # path to execute composer and related binaries from ``` diff --git a/roles/tests/tests_phpcs/README.md b/roles/tests/tests_phpcs/README.md index dd3f4870..457a8a38 100644 --- a/roles/tests/tests_phpcs/README.md +++ b/roles/tests/tests_phpcs/README.md @@ -61,11 +61,11 @@ See the installation documentation on packagist: https://packagist.org/packages/ phpcs: install: false # set to true if you want ce-deploy to attempt to composer install PHP CodeSniffer install_drupal_coder: false # set to true to install the Coder module for Drupal, which provides a Drupal standard for CodeSniffer - bin: "{{ deploy_path }}/vendor/bin/phpcs" # location of phpcs + bin: "{{ live_symlink_dest }}/vendor/bin/phpcs" # location of phpcs standard: "" # optionally set the path to an installed standard, for example "vendor/drupal/coder/coder_sniffer/Drupal" for the Coder module for Drupal extensions: "" # set optional extensions, for example for Drupal you could set "php,module,inc,theme,install" - defaults to "php,inc/php,js,css" test_paths: [] # list of paths to test against - working_dir: "{{ deploy_path }}" # path to execute composer from + working_dir: "{{ live_symlink_dest }}" # path to execute composer from ``` diff --git a/roles/tests/tests_phpunit/README.md b/roles/tests/tests_phpunit/README.md index bc5c64e2..8386926b 100644 --- a/roles/tests/tests_phpunit/README.md +++ b/roles/tests/tests_phpunit/README.md @@ -32,9 +32,9 @@ phpunit: install: false # set to true if you want ce-deploy to attempt to composer install phpunit group: unit # comma separated list of group names to run target: ../modules # directory or file to test, defaults to Drupal's modules directory - bin: "{{ deploy_path }}/vendor/bin/phpunit" # location of phpunit - tests_path: "{{ deploy_path }}/{{ webroot }}/core" # directory containing the PHPUnit 'tests' directory, defaults to Drupal's core directory - working_dir: "{{ deploy_path }}" # path to execute composer from + bin: "{{ live_symlink_dest }}/vendor/bin/phpunit" # location of phpunit + tests_path: "{{ live_symlink_dest }}/{{ webroot }}/core" # directory containing the PHPUnit 'tests' directory, defaults to Drupal's core directory + working_dir: "{{ live_symlink_dest }}" # path to execute composer from ```