Loading .deploy_composer_files_to_server.yml +17 −16 Original line number Diff line number Diff line .upload_composer_files: &upload_composer_files | if [ -d "$CI_PROJECT_DIR/$COMPOSER_ARTIFACTS_DIR" ]; then rsync $RSYNC_ADMIN_PARAMS $RSYNC_PARAMS -e "ssh $SSH_OPTS" $CI_PROJECT_DIR/$COMPOSER_ARTIFACTS_DIR $DEPLOY_HOST_PATH/$COMPOSER_SERVER_DIR; fi # COMPOSER_DEPLOY_PATHS is a space‑separated list of "src:dest" for mapping in $COMPOSER_DEPLOY_PATHS; do src="${mapping%%:*}" dest="${mapping#*:}" .upload_cms_files: &upload_cms_files | if [ -d "$CI_PROJECT_DIR/$CMS_ARTIFACTS_DIR" ]; then rsync $RSYNC_ADMIN_PARAMS $RSYNC_PARAMS -e "ssh $SSH_OPTS" $CI_PROJECT_DIR/$CMS_ARTIFACTS_DIR $DEPLOY_HOST_PATH/$CMS_SERVER_DIR; if [ -d "$CI_PROJECT_DIR/$src" ]; then rsync $RSYNC_ADMIN_PARAMS $RSYNC_PARAMS -e "ssh $SSH_OPTS" "$CI_PROJECT_DIR/$src" "$DEPLOY_HOST_PATH/$dest" else echo "Skipping '$src' because directory does not exist in CI_PROJECT_DIR" fi done .deploy_composer_files_to_server: extends: .before_deploy_code variables: RSYNC_PARAMS: '--delete' COMPOSER_ARTIFACTS_DIR: vendor/ COMPOSER_SERVER_DIR: vendor/ CMS_ARTIFACTS_DIR: www/cms/ CMS_SERVER_DIR: ${DOC_ROOT_NAME}/cms/ dependencies: - build_composer - setup_environment_vars variables: RSYNC_PARAMS: '--delete' # Default: only deploy vendor/ # format: "local/path/:remote/path/" (space‑separated for multiple) COMPOSER_DEPLOY_PATHS: >- vendor/:vendor/ www/cms/:$DOC_ROOT_NAME/cms/ script: - *upload_composer_files - *upload_cms_files only: refs: - beta Loading tests/integration/extract_scripts.py +0 −6 Original line number Diff line number Diff line Loading @@ -9,7 +9,6 @@ Writes shell scripts to OUTPUT_DIR (default /tmp/generated): deploy_doc_root_to_server_with_delete.sh — from .deploy_doc_root_to_server_with_delete (extends .deploy_folder_to_server) deploy_js_files_to_server.sh — from .deploy_js_files_to_server script: upload_composer_files.sh — from .deploy_composer_files_to_server.yml anchor upload_cms_files.sh — from .deploy_composer_files_to_server.yml anchor """ import os import sys Loading Loading @@ -99,11 +98,6 @@ def main(output_dir): f.write(composer['.upload_composer_files']) print(f'Written {path}') path = os.path.join(output_dir, 'upload_cms_files.sh') with open(path, 'w') as f: f.write(composer['.upload_cms_files']) print(f'Written {path}') if __name__ == '__main__': main(sys.argv[1] if len(sys.argv) > 1 else '/tmp/generated') tests/integration/tests/deploy_cms_files_to_server.batsdeleted 100644 → 0 +0 −59 Original line number Diff line number Diff line #!/usr/bin/env bats load 'helpers' load '/usr/local/lib/bats-support/load' load '/usr/local/lib/bats-assert/load' setup() { reset_recipient export CMS_ARTIFACTS_DIR="www/cms/" setup_env export CMS_SERVER_DIR="${DOC_ROOT_NAME}/cms/" } # .deploy_composer_files_to_server: rsync www/cms/ artifacts to server @test "deploy cms: rsync exits successfully" { run run_deploy_cms assert_success } @test "deploy cms: cms files exist on recipient" { # module.php is not in recipient-seed — it can only appear if the deploy ran run_deploy_cms run ssh_root test -f "$PROJECT_ROOT/${DOC_ROOT_NAME}/cms/module.php" assert_success } @test "deploy cms: deployed files are owned by webmaster:webmaster" { run_deploy_cms run ssh_root stat -c "%U:%G" "$PROJECT_ROOT/${DOC_ROOT_NAME}/cms/module.php" assert_success assert_output "webmaster:webmaster" } @test "deploy cms: stale cms file is removed with --delete" { # recipient-seed has www/cms/stale-cms-file.html; local www/cms/ does not run ssh_root test -f "$PROJECT_ROOT/${DOC_ROOT_NAME}/cms/stale-cms-file.html" assert_success run_deploy_cms run ssh_root test -f "$PROJECT_ROOT/${DOC_ROOT_NAME}/cms/stale-cms-file.html" assert_failure } @test "deploy cms: no-op when CMS_ARTIFACTS_DIR does not exist locally" { export CMS_ARTIFACTS_DIR="nonexistent-dir/" setup_env export CMS_SERVER_DIR="${DOC_ROOT_NAME}/cms/" run run_deploy_cms assert_success # module.php is only in project/www/cms/ — if it appears, the deploy ran when it shouldn't have run ssh_root test -f "$PROJECT_ROOT/${DOC_ROOT_NAME}/cms/module.php" assert_failure } tests/integration/tests/deploy_composer_files_to_server.bats +30 −6 Original line number Diff line number Diff line Loading @@ -6,8 +6,7 @@ load '/usr/local/lib/bats-assert/load' setup() { reset_recipient export COMPOSER_ARTIFACTS_DIR="vendor/" export COMPOSER_SERVER_DIR="vendor/" export COMPOSER_DEPLOY_PATHS="vendor/:vendor/" setup_env } Loading Loading @@ -46,8 +45,8 @@ setup() { assert_failure } @test "deploy composer: no-op when COMPOSER_ARTIFACTS_DIR does not exist locally" { export COMPOSER_ARTIFACTS_DIR="nonexistent-dir/" @test "deploy composer: no-op when src does not exist locally" { export COMPOSER_DEPLOY_PATHS="nonexistent-dir/:vendor/" setup_env run run_deploy_composer Loading Loading @@ -77,8 +76,8 @@ setup() { assert_output "webmaster:webmaster" } @test "deploy composer: custom COMPOSER_SERVER_DIR places files under alternate path" { export COMPOSER_SERVER_DIR="lib/" @test "deploy composer: custom dest places files under alternate path" { export COMPOSER_DEPLOY_PATHS="vendor/:lib/" setup_env run run_deploy_composer Loading @@ -87,3 +86,28 @@ setup() { run ssh_root test -f "$PROJECT_ROOT/lib/autoload.php" assert_success } @test "deploy composer: multiple paths deploy both vendor and cms" { export COMPOSER_DEPLOY_PATHS="vendor/:vendor/ www/cms/:${DOC_ROOT_NAME}/cms/" setup_env run_deploy_composer run ssh_root test -f "$PROJECT_ROOT/vendor/acme/Foo.php" assert_success run ssh_root test -f "$PROJECT_ROOT/${DOC_ROOT_NAME}/cms/module.php" assert_success } @test "deploy composer: stale cms file is removed when deploying cms path" { export COMPOSER_DEPLOY_PATHS="vendor/:vendor/ www/cms/:${DOC_ROOT_NAME}/cms/" setup_env run ssh_root test -f "$PROJECT_ROOT/${DOC_ROOT_NAME}/cms/stale-cms-file.html" assert_success run_deploy_composer run ssh_root test -f "$PROJECT_ROOT/${DOC_ROOT_NAME}/cms/stale-cms-file.html" assert_failure } tests/integration/tests/helpers.bash +0 −5 Original line number Diff line number Diff line Loading @@ -80,11 +80,6 @@ run_deploy_js() { (cd "$CI_PROJECT_DIR" && bash "$GENERATED_DIR/deploy_js_files_to_server.sh") } # Run upload_cms_files.sh with CWD=CI_PROJECT_DIR. run_deploy_cms() { (cd "$CI_PROJECT_DIR" && bash "$GENERATED_DIR/upload_cms_files.sh") } # Reset the recipient to a flat (no www/ subdirectory) seed state before each test. reset_recipient_flat() { rsync -ap --delete --chown=webmaster:webmaster \ Loading Loading
.deploy_composer_files_to_server.yml +17 −16 Original line number Diff line number Diff line .upload_composer_files: &upload_composer_files | if [ -d "$CI_PROJECT_DIR/$COMPOSER_ARTIFACTS_DIR" ]; then rsync $RSYNC_ADMIN_PARAMS $RSYNC_PARAMS -e "ssh $SSH_OPTS" $CI_PROJECT_DIR/$COMPOSER_ARTIFACTS_DIR $DEPLOY_HOST_PATH/$COMPOSER_SERVER_DIR; fi # COMPOSER_DEPLOY_PATHS is a space‑separated list of "src:dest" for mapping in $COMPOSER_DEPLOY_PATHS; do src="${mapping%%:*}" dest="${mapping#*:}" .upload_cms_files: &upload_cms_files | if [ -d "$CI_PROJECT_DIR/$CMS_ARTIFACTS_DIR" ]; then rsync $RSYNC_ADMIN_PARAMS $RSYNC_PARAMS -e "ssh $SSH_OPTS" $CI_PROJECT_DIR/$CMS_ARTIFACTS_DIR $DEPLOY_HOST_PATH/$CMS_SERVER_DIR; if [ -d "$CI_PROJECT_DIR/$src" ]; then rsync $RSYNC_ADMIN_PARAMS $RSYNC_PARAMS -e "ssh $SSH_OPTS" "$CI_PROJECT_DIR/$src" "$DEPLOY_HOST_PATH/$dest" else echo "Skipping '$src' because directory does not exist in CI_PROJECT_DIR" fi done .deploy_composer_files_to_server: extends: .before_deploy_code variables: RSYNC_PARAMS: '--delete' COMPOSER_ARTIFACTS_DIR: vendor/ COMPOSER_SERVER_DIR: vendor/ CMS_ARTIFACTS_DIR: www/cms/ CMS_SERVER_DIR: ${DOC_ROOT_NAME}/cms/ dependencies: - build_composer - setup_environment_vars variables: RSYNC_PARAMS: '--delete' # Default: only deploy vendor/ # format: "local/path/:remote/path/" (space‑separated for multiple) COMPOSER_DEPLOY_PATHS: >- vendor/:vendor/ www/cms/:$DOC_ROOT_NAME/cms/ script: - *upload_composer_files - *upload_cms_files only: refs: - beta Loading
tests/integration/extract_scripts.py +0 −6 Original line number Diff line number Diff line Loading @@ -9,7 +9,6 @@ Writes shell scripts to OUTPUT_DIR (default /tmp/generated): deploy_doc_root_to_server_with_delete.sh — from .deploy_doc_root_to_server_with_delete (extends .deploy_folder_to_server) deploy_js_files_to_server.sh — from .deploy_js_files_to_server script: upload_composer_files.sh — from .deploy_composer_files_to_server.yml anchor upload_cms_files.sh — from .deploy_composer_files_to_server.yml anchor """ import os import sys Loading Loading @@ -99,11 +98,6 @@ def main(output_dir): f.write(composer['.upload_composer_files']) print(f'Written {path}') path = os.path.join(output_dir, 'upload_cms_files.sh') with open(path, 'w') as f: f.write(composer['.upload_cms_files']) print(f'Written {path}') if __name__ == '__main__': main(sys.argv[1] if len(sys.argv) > 1 else '/tmp/generated')
tests/integration/tests/deploy_cms_files_to_server.batsdeleted 100644 → 0 +0 −59 Original line number Diff line number Diff line #!/usr/bin/env bats load 'helpers' load '/usr/local/lib/bats-support/load' load '/usr/local/lib/bats-assert/load' setup() { reset_recipient export CMS_ARTIFACTS_DIR="www/cms/" setup_env export CMS_SERVER_DIR="${DOC_ROOT_NAME}/cms/" } # .deploy_composer_files_to_server: rsync www/cms/ artifacts to server @test "deploy cms: rsync exits successfully" { run run_deploy_cms assert_success } @test "deploy cms: cms files exist on recipient" { # module.php is not in recipient-seed — it can only appear if the deploy ran run_deploy_cms run ssh_root test -f "$PROJECT_ROOT/${DOC_ROOT_NAME}/cms/module.php" assert_success } @test "deploy cms: deployed files are owned by webmaster:webmaster" { run_deploy_cms run ssh_root stat -c "%U:%G" "$PROJECT_ROOT/${DOC_ROOT_NAME}/cms/module.php" assert_success assert_output "webmaster:webmaster" } @test "deploy cms: stale cms file is removed with --delete" { # recipient-seed has www/cms/stale-cms-file.html; local www/cms/ does not run ssh_root test -f "$PROJECT_ROOT/${DOC_ROOT_NAME}/cms/stale-cms-file.html" assert_success run_deploy_cms run ssh_root test -f "$PROJECT_ROOT/${DOC_ROOT_NAME}/cms/stale-cms-file.html" assert_failure } @test "deploy cms: no-op when CMS_ARTIFACTS_DIR does not exist locally" { export CMS_ARTIFACTS_DIR="nonexistent-dir/" setup_env export CMS_SERVER_DIR="${DOC_ROOT_NAME}/cms/" run run_deploy_cms assert_success # module.php is only in project/www/cms/ — if it appears, the deploy ran when it shouldn't have run ssh_root test -f "$PROJECT_ROOT/${DOC_ROOT_NAME}/cms/module.php" assert_failure }
tests/integration/tests/deploy_composer_files_to_server.bats +30 −6 Original line number Diff line number Diff line Loading @@ -6,8 +6,7 @@ load '/usr/local/lib/bats-assert/load' setup() { reset_recipient export COMPOSER_ARTIFACTS_DIR="vendor/" export COMPOSER_SERVER_DIR="vendor/" export COMPOSER_DEPLOY_PATHS="vendor/:vendor/" setup_env } Loading Loading @@ -46,8 +45,8 @@ setup() { assert_failure } @test "deploy composer: no-op when COMPOSER_ARTIFACTS_DIR does not exist locally" { export COMPOSER_ARTIFACTS_DIR="nonexistent-dir/" @test "deploy composer: no-op when src does not exist locally" { export COMPOSER_DEPLOY_PATHS="nonexistent-dir/:vendor/" setup_env run run_deploy_composer Loading Loading @@ -77,8 +76,8 @@ setup() { assert_output "webmaster:webmaster" } @test "deploy composer: custom COMPOSER_SERVER_DIR places files under alternate path" { export COMPOSER_SERVER_DIR="lib/" @test "deploy composer: custom dest places files under alternate path" { export COMPOSER_DEPLOY_PATHS="vendor/:lib/" setup_env run run_deploy_composer Loading @@ -87,3 +86,28 @@ setup() { run ssh_root test -f "$PROJECT_ROOT/lib/autoload.php" assert_success } @test "deploy composer: multiple paths deploy both vendor and cms" { export COMPOSER_DEPLOY_PATHS="vendor/:vendor/ www/cms/:${DOC_ROOT_NAME}/cms/" setup_env run_deploy_composer run ssh_root test -f "$PROJECT_ROOT/vendor/acme/Foo.php" assert_success run ssh_root test -f "$PROJECT_ROOT/${DOC_ROOT_NAME}/cms/module.php" assert_success } @test "deploy composer: stale cms file is removed when deploying cms path" { export COMPOSER_DEPLOY_PATHS="vendor/:vendor/ www/cms/:${DOC_ROOT_NAME}/cms/" setup_env run ssh_root test -f "$PROJECT_ROOT/${DOC_ROOT_NAME}/cms/stale-cms-file.html" assert_success run_deploy_composer run ssh_root test -f "$PROJECT_ROOT/${DOC_ROOT_NAME}/cms/stale-cms-file.html" assert_failure }
tests/integration/tests/helpers.bash +0 −5 Original line number Diff line number Diff line Loading @@ -80,11 +80,6 @@ run_deploy_js() { (cd "$CI_PROJECT_DIR" && bash "$GENERATED_DIR/deploy_js_files_to_server.sh") } # Run upload_cms_files.sh with CWD=CI_PROJECT_DIR. run_deploy_cms() { (cd "$CI_PROJECT_DIR" && bash "$GENERATED_DIR/upload_cms_files.sh") } # Reset the recipient to a flat (no www/ subdirectory) seed state before each test. reset_recipient_flat() { rsync -ap --delete --chown=webmaster:webmaster \ Loading