diff --git a/ee/config/feature_flags/beta/workspaces_shallow_clone_project.yml b/ee/config/feature_flags/beta/workspaces_shallow_clone_project.yml new file mode 100644 index 0000000000000000000000000000000000000000..d8e96cb15d02c540dbac0c0050e5ef03857bc023 --- /dev/null +++ b/ee/config/feature_flags/beta/workspaces_shallow_clone_project.yml @@ -0,0 +1,9 @@ +--- +name: workspaces_shallow_clone_project +feature_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/543982 +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/194906 +rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/550330 +milestone: '18.2' +group: group::remote development +type: beta +default_enabled: false diff --git a/ee/lib/remote_development/files.rb b/ee/lib/remote_development/files.rb index e36ca2cd7d638c877bdc6389ed0ce8332870e332..f53acd1233a7fb7c53cfffa0808ac6bbeb6b16f1 100644 --- a/ee/lib/remote_development/files.rb +++ b/ee/lib/remote_development/files.rb @@ -65,6 +65,11 @@ def self.internal_poststart_command_clone_project_script read_file("workspace_operations/create/internal_poststart_command_clone_project.sh") end + # @return [String] content of the file + def self.internal_poststart_command_clone_unshallow_script + read_file("workspace_operations/create/internal_poststart_command_clone_unshallow.sh") + end + #################################### # Please keep this list alphabetized #################################### @@ -75,6 +80,7 @@ def self.internal_poststart_command_clone_project_script DEFAULT_DEVFILE_YAML = default_devfile_yaml GIT_CREDENTIAL_STORE_SCRIPT = git_credential_store_script INTERNAL_POSTSTART_COMMAND_CLONE_PROJECT_SCRIPT = internal_poststart_command_clone_project_script + INTERNAL_POSTSTART_COMMAND_CLONE_UNSHALLOW_SCRIPT = internal_poststart_command_clone_unshallow_script INTERNAL_POSTSTART_COMMAND_START_VSCODE_SCRIPT = internal_poststart_command_start_vscode_script INTERNAL_POSTSTART_COMMAND_SLEEP_UNTIL_WORKSPACE_IS_RUNNING_SCRIPT = internal_poststart_command_sleep_until_workspace_is_running_script @@ -91,6 +97,7 @@ def self.all_expected_file_constants :DEFAULT_DEVFILE_YAML, :GIT_CREDENTIAL_STORE_SCRIPT, :INTERNAL_POSTSTART_COMMAND_CLONE_PROJECT_SCRIPT, + :INTERNAL_POSTSTART_COMMAND_CLONE_UNSHALLOW_SCRIPT, :INTERNAL_POSTSTART_COMMAND_START_VSCODE_SCRIPT, :INTERNAL_POSTSTART_COMMAND_SLEEP_UNTIL_WORKSPACE_IS_RUNNING_SCRIPT, :INTERNAL_POSTSTART_COMMAND_START_SSHD_SCRIPT, @@ -102,7 +109,7 @@ def self.all_expected_file_constants # @return [void] def self.reload_constants! - expected_count = 9 # Update this count if you add/remove constants + expected_count = 10 # Update this count if you add/remove constants raise "File constants count mismatch!" unless all_expected_file_constants.count == expected_count all_expected_file_constants.each do |const_name| diff --git a/ee/lib/remote_development/workspace_operations/create/create_constants.rb b/ee/lib/remote_development/workspace_operations/create/create_constants.rb index f271cd6a3fe6de2b90f7b2f4b9a38e336f693e82..74f58ac1e4c80e98743076ef9de055a70a035a45 100644 --- a/ee/lib/remote_development/workspace_operations/create/create_constants.rb +++ b/ee/lib/remote_development/workspace_operations/create/create_constants.rb @@ -19,6 +19,7 @@ module CreateConstants LEGACY_RUN_POSTSTART_COMMANDS_SCRIPT_NAME = "gl-run-poststart-commands.sh" NAMESPACE_PREFIX = "gl-rd-ns" PROJECT_CLONING_SUCCESSFUL_FILE_NAME = ".gl_project_cloning_successful" + CLONE_DEPTH_OPTION = "--depth 10" RUN_AS_USER = 5001 RUN_INTERNAL_BLOCKING_POSTSTART_COMMANDS_SCRIPT_NAME = "gl-run-internal-blocking-poststart-commands.sh" RUN_NON_BLOCKING_POSTSTART_COMMANDS_SCRIPT_NAME = "gl-run-non-blocking-poststart-commands.sh" diff --git a/ee/lib/remote_development/workspace_operations/create/desired_config/kubernetes_poststart_hook_command.sh b/ee/lib/remote_development/workspace_operations/create/desired_config/kubernetes_poststart_hook_command.sh index 792e1cad5d3a5396d862b7ab42329b6da7abc45d..ac5fbfb80ef9b0b0dd7a15dbdf750f3c101b5595 100644 --- a/ee/lib/remote_development/workspace_operations/create/desired_config/kubernetes_poststart_hook_command.sh +++ b/ee/lib/remote_development/workspace_operations/create/desired_config/kubernetes_poststart_hook_command.sh @@ -3,6 +3,7 @@ mkdir -p "${GL_WORKSPACE_LOGS_DIR}" ln -sf "${GL_WORKSPACE_LOGS_DIR}" /tmp +# shellcheck disable=SC2129 # We area using redirects with a command block as this warning proposes to do. It must be a false positive from the subsequent lines which handle stdout and stderr seprately. { echo "$(date -Iseconds): ----------------------------------------" echo "$(date -Iseconds): Running poststart commands for workspace..." @@ -14,8 +15,13 @@ ln -sf "${GL_WORKSPACE_LOGS_DIR}" /tmp "%s" 1>>"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log" 2>>"${GL_WORKSPACE_LOGS_DIR}/poststart-stderr.log" { + echo "$(date -Iseconds): Finished running internal blocking poststart commands script." echo "$(date -Iseconds): ----------------------------------------" echo "$(date -Iseconds): Running non-blocking poststart commands script..." } >> "${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log" "%s" 1>>"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log" 2>>"${GL_WORKSPACE_LOGS_DIR}/poststart-stderr.log" & + +{ + echo "$(date -Iseconds): Finished running non-blocking poststart commands script." +} >> "${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log" diff --git a/ee/lib/remote_development/workspace_operations/create/desired_config/scripts_configmap_appender.rb b/ee/lib/remote_development/workspace_operations/create/desired_config/scripts_configmap_appender.rb index fe83e18f90875a3a84d4c3f63bbf790a96023542..b9889b637de4feec9db1613932be8e0bd790836c 100644 --- a/ee/lib/remote_development/workspace_operations/create/desired_config/scripts_configmap_appender.rb +++ b/ee/lib/remote_development/workspace_operations/create/desired_config/scripts_configmap_appender.rb @@ -130,8 +130,10 @@ def self.get_poststart_command_script_content(poststart_command_ids:) # See https://github.com/eclipse-che/che/issues/23404#issuecomment-2787779571 # for more context. <<~SH + echo "$(date -Iseconds): ----------------------------------------" echo "$(date -Iseconds): Running #{WORKSPACE_SCRIPTS_VOLUME_PATH}/#{poststart_command_id}..." #{WORKSPACE_SCRIPTS_VOLUME_PATH}/#{poststart_command_id} || true + echo "$(date -Iseconds): Finished running #{WORKSPACE_SCRIPTS_VOLUME_PATH}/#{poststart_command_id}." SH end.join end diff --git a/ee/lib/remote_development/workspace_operations/create/internal_poststart_command_clone_project.sh b/ee/lib/remote_development/workspace_operations/create/internal_poststart_command_clone_project.sh index fe61c361fd28c59148f3bf17be0ce13e7c4502eb..6480bc1ac63cea01fc2de82fe597b72f9422e3e8 100644 --- a/ee/lib/remote_development/workspace_operations/create/internal_poststart_command_clone_project.sh +++ b/ee/lib/remote_development/workspace_operations/create/internal_poststart_command_clone_project.sh @@ -8,7 +8,8 @@ echo "$(date -Iseconds): Cloning project if necessary..." # If the file does not exist, clone the project. if [ -f "%s" ] then - echo "$(date -Iseconds): Project cloning was already successful" + echo "$(date -Iseconds): Project cloning was already successful, because '%s' file already exists" + echo "$(date -Iseconds): ----------------------------------------" exit 0 fi @@ -20,8 +21,11 @@ then rm -rf "%s" fi -echo "$(date -Iseconds): Cloning project" -git clone --branch "%s" "%s" "%s" +clone_depth_option="%s" +depth_msg="${clone_depth_option:+ with \"${clone_depth_option}\" option}" + +echo "$(date -Iseconds): Cloning project${depth_msg}" +git clone $clone_depth_option --branch "%s" "%s" "%s" exit_code=$? # Once cloning is successful, create the file which is used in the check above. @@ -30,10 +34,12 @@ if [ "${exit_code}" -eq 0 ] then echo "$(date -Iseconds): Project cloning successful" touch "%s" - echo "$(date -Iseconds): Updated file to indicate successful project cloning" + echo "$(date -Iseconds): Updated '%s' file to indicate successful project cloning" + echo "$(date -Iseconds): Successfully finished cloning project." else echo "$(date -Iseconds): Project cloning failed with exit code: ${exit_code}" >&2 + echo "$(date -Iseconds): Failed to clone project, exit code was ${exit_code}" fi -echo "$(date -Iseconds): Finished cloning project if necessary." +echo "$(date -Iseconds): ----------------------------------------" exit "${exit_code}" diff --git a/ee/lib/remote_development/workspace_operations/create/internal_poststart_command_clone_unshallow.sh b/ee/lib/remote_development/workspace_operations/create/internal_poststart_command_clone_unshallow.sh new file mode 100644 index 0000000000000000000000000000000000000000..4f8d7c1db61a0fad51681b916c8e7d6aa4f7c162 --- /dev/null +++ b/ee/lib/remote_development/workspace_operations/create/internal_poststart_command_clone_unshallow.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +echo "$(date -Iseconds): ----------------------------------------" +echo "$(date -Iseconds): Spawning background process to unshallow repo if necessary..." + +if [ ! -f "%s" ]; then + echo "$(date -Iseconds): Project cloning previously failed. Unshallow skipped" + echo "$(date -Iseconds): ----------------------------------------" + exit 0 +fi + +# shellcheck disable=SC2164 # We assume that 'clone_dir' must exist if 'project_cloning_successful_file' exists +cd "%s" + +if [ "$(git rev-parse --is-shallow-repository)" != "true" ]; then + echo "$(date -Iseconds): Repository is not shallow, skipping unshallow" + echo "$(date -Iseconds): ----------------------------------------" + exit 0 +fi + +echo "$(date -Iseconds): Repository is shallow, proceeding with unshallow" +UNSHALLOW_LOG_FILE="${GL_WORKSPACE_LOGS_DIR}/clone-unshallow.log" + +echo "$(date -Iseconds): Starting unshallow in background, with output written to ${UNSHALLOW_LOG_FILE}" +{ + echo "$(date -Iseconds): ----------------------------------------" + echo "$(date -Iseconds): Starting unshallow in background" + if git fetch --unshallow --progress 2>&1; then + echo "$(date -Iseconds): Unshallow completed successfully" + else + echo "$(date -Iseconds): Unshallow failed with exit code $?" + fi + echo "$(date -Iseconds): ----------------------------------------" +} >> "${UNSHALLOW_LOG_FILE}" & + +echo "$(date -Iseconds): Finished spawning background process to unshallow repo." +echo "$(date -Iseconds): ----------------------------------------" +exit 0 diff --git a/ee/lib/remote_development/workspace_operations/create/internal_poststart_command_sleep_until_workspace_is_running.sh b/ee/lib/remote_development/workspace_operations/create/internal_poststart_command_sleep_until_workspace_is_running.sh index a4dc9035c950ac9627a38df0391ecff558828be8..578ca14bc35e34356303d3fb21be0547c8b11823 100644 --- a/ee/lib/remote_development/workspace_operations/create/internal_poststart_command_sleep_until_workspace_is_running.sh +++ b/ee/lib/remote_development/workspace_operations/create/internal_poststart_command_sleep_until_workspace_is_running.sh @@ -9,3 +9,4 @@ while [ "$(cat ${status_file})" != "Running" ]; do done echo "$(date -Iseconds): Workspace state is now 'Running', continuing postStart hook execution." echo "$(date -Iseconds): Finished sleeping until workspace is running." +echo "$(date -Iseconds): ----------------------------------------" diff --git a/ee/lib/remote_development/workspace_operations/create/internal_poststart_command_start_sshd.sh b/ee/lib/remote_development/workspace_operations/create/internal_poststart_command_start_sshd.sh index cc4adb32df67dfdf8f3a5aac21751cf43400366b..ba3b2b30ff4b92b38262cb593a48cc6b5445c487 100644 --- a/ee/lib/remote_development/workspace_operations/create/internal_poststart_command_start_sshd.sh +++ b/ee/lib/remote_development/workspace_operations/create/internal_poststart_command_start_sshd.sh @@ -1,11 +1,13 @@ #!/bin/sh echo "$(date -Iseconds): ----------------------------------------" -echo "$(date -Iseconds): Starting sshd if it is found..." +echo "$(date -Iseconds): Starting sshd in background if it is found..." sshd_path=$(which sshd) if [ -x "${sshd_path}" ]; then - echo "$(date -Iseconds): Starting ${sshd_path} on port ${GL_SSH_PORT} with output written to ${GL_WORKSPACE_LOGS_DIR}/start-sshd.log" + echo "$(date -Iseconds): Starting ${sshd_path} in background on port ${GL_SSH_PORT} with output written to ${GL_WORKSPACE_LOGS_DIR}/start-sshd.log" "${sshd_path}" -D -p "${GL_SSH_PORT}" >> "${GL_WORKSPACE_LOGS_DIR}/start-sshd.log" 2>&1 & + echo "$(date -Iseconds): Finished starting sshd in background if it is found." else echo "$(date -Iseconds): 'sshd' not found in path. Not starting SSH server." >&2 + echo "$(date -Iseconds): Failed to start sshd, no sshd executable found" fi -echo "$(date -Iseconds): Finished starting sshd if it is found." +echo "$(date -Iseconds): ----------------------------------------" diff --git a/ee/lib/remote_development/workspace_operations/create/internal_poststart_command_start_vscode.sh b/ee/lib/remote_development/workspace_operations/create/internal_poststart_command_start_vscode.sh index d585b4d5dc25aa8f4a5fd9523bb0402c36b8c44b..75d68ac2c18642ca752826384d6121cba4756386 100644 --- a/ee/lib/remote_development/workspace_operations/create/internal_poststart_command_start_vscode.sh +++ b/ee/lib/remote_development/workspace_operations/create/internal_poststart_command_start_vscode.sh @@ -1,10 +1,10 @@ #!/bin/sh echo "$(date -Iseconds): ----------------------------------------" -echo "$(date -Iseconds): Running main_component_updater_start_vscode.sh with output written to ${GL_WORKSPACE_LOGS_DIR}/start_vscode.log..." +echo "$(date -Iseconds): Starting GitLab Fork of VS Code server in background with output written to ${GL_WORKSPACE_LOGS_DIR}/start-vscode.log..." # Define log file path -LOG_FILE="${GL_WORKSPACE_LOGS_DIR}/start_vscode.log" +LOG_FILE="${GL_WORKSPACE_LOGS_DIR}/start-vscode.log" mkdir -p "$(dirname "${LOG_FILE}")" @@ -89,11 +89,13 @@ echo "$(date -Iseconds): - Log level: ${GL_VSCODE_LOG_LEVEL}" echo "$(date -Iseconds): - Without connection token: yes" echo "$(date -Iseconds): - Workspace trust disabled: yes" -# For the actual server execution, we need to make sure it doesn't get backgrounded -# and its output continues going to the log file +# The server execution is backgrounded to allow for the rest of the internal init scripts to execute. "${GL_TOOLS_DIR}/vscode-reh-web/bin/gitlab-webide-server" \ --host "${GL_VSCODE_HOST}" \ --port "${GL_VSCODE_PORT}" \ --log "${GL_VSCODE_LOG_LEVEL}" \ --without-connection-token \ --disable-workspace-trust & + +echo "$(date -Iseconds): Finished starting GitLab Fork of VS Code server in background" +echo "$(date -Iseconds): ----------------------------------------" diff --git a/ee/lib/remote_development/workspace_operations/create/internal_poststart_commands_inserter.rb b/ee/lib/remote_development/workspace_operations/create/internal_poststart_commands_inserter.rb index 5016c9924ca65aff535a71aed1909ec066d25f29..ae2e1ddb63c9310b1d639df4dc3e6dd2e97d4e1a 100644 --- a/ee/lib/remote_development/workspace_operations/create/internal_poststart_commands_inserter.rb +++ b/ee/lib/remote_development/workspace_operations/create/internal_poststart_commands_inserter.rb @@ -37,6 +37,8 @@ def self.insert(context) clone_dir = "#{volume_path}/#{project.path}" project_url = project.http_url_to_repo + clone_depth_option = workspaces_shallow_clone_project_feature_enabled?(project) ? CLONE_DEPTH_OPTION : "" + # Add the clone_project event clone_project_command_id = "gl-clone-project-command" clone_project_script = @@ -45,7 +47,8 @@ def self.insert(context) project_cloning_successful_file: Shellwords.shellescape(project_cloning_successful_file), clone_dir: Shellwords.shellescape(clone_dir), project_ref: Shellwords.shellescape(project_ref), - project_url: Shellwords.shellescape(project_url) + project_url: Shellwords.shellescape(project_url), + clone_depth_option: clone_depth_option ) # NOTE: We will always have exactly one main_component found, because we have already @@ -67,6 +70,26 @@ def self.insert(context) } } + unless clone_depth_option.empty? + # Add the clone_unshallow event + clone_unshallow_command_id = "gl-clone-unshallow-command" + clone_unshallow_script = + format( + INTERNAL_POSTSTART_COMMAND_CLONE_UNSHALLOW_SCRIPT, + project_cloning_successful_file: Shellwords.shellescape(project_cloning_successful_file), + clone_dir: Shellwords.shellescape(clone_dir) + ) + + commands << { + id: clone_unshallow_command_id, + exec: { + commandLine: clone_unshallow_script, + component: main_component_name, + label: INTERNAL_BLOCKING_COMMAND_LABEL + } + } + end + # Add the start_sshd event start_sshd_command_id = "gl-start-sshd-command" commands << { @@ -106,16 +129,29 @@ def self.insert(context) } } - # Prepend internal commands so they are executed before any user-defined poststart events. - poststart_events.prepend( + commands_to_prepend = [ clone_project_command_id, start_sshd_command_id, start_vscode_command_id, sleep_until_container_is_running_command_id - ) + ] + + # Insert the unshallow command after the clone command, if the FF is enabled and clone_depth_option is set. + commands_to_prepend.insert(1, clone_unshallow_command_id) unless clone_depth_option.empty? + + # Prepend internal commands so they are executed before any user-defined poststart events. + poststart_events.prepend(*commands_to_prepend) context end + + # @param [Project] project + # @return [TrueClass, FalseClass] + def self.workspaces_shallow_clone_project_feature_enabled?(project) + Feature.enabled?(:workspaces_shallow_clone_project, project) + end + + private_class_method :workspaces_shallow_clone_project_feature_enabled? end end end diff --git a/ee/spec/fixtures/remote_development/example.internal-poststart-commands-inserted-devfile.yaml.erb b/ee/spec/fixtures/remote_development/example.internal-poststart-commands-inserted-devfile.yaml.erb index 93b06e24fff62a04ee6e5c7c2124a6bbfc7638df..5e6fdf7b4e14bfc9efefa254e0c92c4233d81e28 100644 --- a/ee/spec/fixtures/remote_development/example.internal-poststart-commands-inserted-devfile.yaml.erb +++ b/ee/spec/fixtures/remote_development/example.internal-poststart-commands-inserted-devfile.yaml.erb @@ -72,6 +72,15 @@ commands: %> component: tooling-container label: <%= INTERNAL_BLOCKING_COMMAND_LABEL %> + - id: gl-clone-unshallow-command + exec: + commandLine: | + <%= + script = INTERNAL_POSTSTART_COMMAND_CLONE_UNSHALLOW_SCRIPT + indent_yaml_literal(script, 8) + %> + component: tooling-container + label: <%= INTERNAL_BLOCKING_COMMAND_LABEL %> - id: gl-start-sshd-command exec: commandLine: | @@ -101,6 +110,7 @@ events: - gl-tools-injector-command postStart: - gl-clone-project-command + - gl-clone-unshallow-command - gl-start-sshd-command - gl-init-tools-command - gl-sleep-until-container-is-running-command diff --git a/ee/spec/fixtures/remote_development/example.processed-devfile.yaml.erb b/ee/spec/fixtures/remote_development/example.processed-devfile.yaml.erb index 6e824aaa12d67e5c0944a4781166972042ee5a6d..6d683c9da64e5a7c83e529e6b144b92f7347d89f 100644 --- a/ee/spec/fixtures/remote_development/example.processed-devfile.yaml.erb +++ b/ee/spec/fixtures/remote_development/example.processed-devfile.yaml.erb @@ -84,6 +84,15 @@ commands: %> component: tooling-container label: <%= INTERNAL_BLOCKING_COMMAND_LABEL %> + - id: gl-clone-unshallow-command + exec: + commandLine: | + <%= + script = INTERNAL_POSTSTART_COMMAND_CLONE_UNSHALLOW_SCRIPT + indent_yaml_literal(script, 8) + %> + component: tooling-container + label: <%= INTERNAL_BLOCKING_COMMAND_LABEL %> - id: gl-start-sshd-command exec: commandLine: | @@ -113,6 +122,7 @@ events: - gl-tools-injector-command postStart: - gl-clone-project-command + - gl-clone-unshallow-command - gl-start-sshd-command - gl-init-tools-command - gl-sleep-until-container-is-running-command diff --git a/ee/spec/lib/remote_development/workspace_operations/create/desired_config/scripts_configmap_appender_spec.rb b/ee/spec/lib/remote_development/workspace_operations/create/desired_config/scripts_configmap_appender_spec.rb index afe962b5a7f196559f501735ba192d060b8d37c1..a9dfe811fe2779e0f77d144db552d48f2166aac0 100644 --- a/ee/spec/lib/remote_development/workspace_operations/create/desired_config/scripts_configmap_appender_spec.rb +++ b/ee/spec/lib/remote_development/workspace_operations/create/desired_config/scripts_configmap_appender_spec.rb @@ -51,6 +51,7 @@ expect(configmap_name).to eq(name) expect(data).to eq( "gl-clone-project-command": clone_project_script, + "gl-clone-unshallow-command": clone_unshallow_script, "gl-init-tools-command": files::INTERNAL_POSTSTART_COMMAND_START_VSCODE_SCRIPT, create_constants_module::RUN_INTERNAL_BLOCKING_POSTSTART_COMMANDS_SCRIPT_NAME.to_sym => internal_blocking_poststart_commands_script, diff --git a/ee/spec/lib/remote_development/workspace_operations/create/internal_poststart_commands_inserter_spec.rb b/ee/spec/lib/remote_development/workspace_operations/create/internal_poststart_commands_inserter_spec.rb index 2d60c336a9d8fee1f7eb1d9443093d28537c42ec..b7fe8073659d933f8627f80d1ed7ae97c27589d0 100644 --- a/ee/spec/lib/remote_development/workspace_operations/create/internal_poststart_commands_inserter_spec.rb +++ b/ee/spec/lib/remote_development/workspace_operations/create/internal_poststart_commands_inserter_spec.rb @@ -3,7 +3,7 @@ require "fast_spec_helper" RSpec.describe RemoteDevelopment::WorkspaceOperations::Create::InternalPoststartCommandsInserter, feature_category: :workspaces do - include_context 'with remote development shared fixtures' + include_context "with remote development shared fixtures" let(:input_processed_devfile) do read_devfile("example.main-container-updated-devfile.yaml.erb") @@ -35,11 +35,57 @@ } end + let(:clone_command) do + returned_value[:processed_devfile][:commands].find do |cmd| + cmd[:id] == "gl-clone-project-command" + end + end + + let(:clone_unshallow_command) do + returned_value[:processed_devfile][:commands].find do |cmd| + cmd[:id] == "gl-clone-unshallow-command" + end + end + + let(:workspaces_shallow_clone_project_feature_enabled) { true } + subject(:returned_value) do described_class.insert(context) end - it 'updates the devfile' do + before do + expect(described_class) # rubocop:disable RSpec/ExpectInHook -- We are intentionally doing an expect here, so we will be forced to remove this code when we remove the feature flag + .to receive(:workspaces_shallow_clone_project_feature_enabled?) + .and_return(workspaces_shallow_clone_project_feature_enabled) + end + + it "updates the devfile" do expect(returned_value[:processed_devfile]).to eq(expected_processed_devfile) end + + it "includes depth option in clone command" do + expect(clone_command).not_to be_nil + expect(clone_command[:exec][:commandLine]).to include("--depth 10") + end + + it "includes unshallow logic in clone command" do + command_line = clone_unshallow_command[:exec][:commandLine] + + expect(command_line).to include("git fetch --unshallow") + expect(command_line).to include("clone-unshallow.log") + expect(command_line).to include("git rev-parse --is-shallow-repository") + end + + context "when workspaces_shallow_clone_project feature option is disabled" do + let(:workspaces_shallow_clone_project_feature_enabled) { false } + + it "does not include depth option in clone command" do + expect(clone_command).not_to be_nil + expect(clone_command[:exec][:commandLine]).not_to include("--depth") + end + + it "does not add clone unshallow command" do + expect(clone_unshallow_command).to be_nil + end + end end diff --git a/ee/spec/lib/remote_development/workspace_operations/create/main_component_updater_start_vscode_script_spec.rb b/ee/spec/lib/remote_development/workspace_operations/create/main_component_updater_start_vscode_script_spec.rb index 411fd14f7af5c0fffffb6efac24a43a0159f2aa4..5952e9a852929284b64feac5cdbfb2c9e3384289 100644 --- a/ee/spec/lib/remote_development/workspace_operations/create/main_component_updater_start_vscode_script_spec.rb +++ b/ee/spec/lib/remote_development/workspace_operations/create/main_component_updater_start_vscode_script_spec.rb @@ -12,7 +12,7 @@ let(:log_dir) { Dir.mktmpdir } let(:tools_dir) { Dir.mktmpdir } let(:product_json_path) { File.join(tools_dir, "vscode-reh-web/product.json") } - let(:log_file_path) { File.join(log_dir, "start_vscode.log") } + let(:log_file_path) { File.join(log_dir, "start-vscode.log") } let(:extension_marketplace_service_url) { "https://marketplace.example.com" } let(:extension_marketplace_item_url) { "https://item.example.com" } let(:extension_marketplace_resource_url_template) { "https://resource.example.com/{path}" } diff --git a/ee/spec/lib/remote_development/workspace_operations/reconcile/output/desired_config_generator_golden_master_spec.rb b/ee/spec/lib/remote_development/workspace_operations/reconcile/output/desired_config_generator_golden_master_spec.rb index ae0b6e2bdb24706529ce06d157fd178695cd508f..d6c8f7427579df769faf01b81840a6cc58ef23d5 100644 --- a/ee/spec/lib/remote_development/workspace_operations/reconcile/output/desired_config_generator_golden_master_spec.rb +++ b/ee/spec/lib/remote_development/workspace_operations/reconcile/output/desired_config_generator_golden_master_spec.rb @@ -630,7 +630,7 @@ def golden_master_desired_config_with_include_all_resources_true command: [ "/bin/sh", "-c", - "#!/bin/sh\n\nmkdir -p \"${GL_WORKSPACE_LOGS_DIR}\"\nln -sf \"${GL_WORKSPACE_LOGS_DIR}\" /tmp\n\n{\n echo \"$(date -Iseconds): ----------------------------------------\"\n echo \"$(date -Iseconds): Running poststart commands for workspace...\"\n\n echo \"$(date -Iseconds): ----------------------------------------\"\n echo \"$(date -Iseconds): Running internal blocking poststart commands script...\"\n} >> \"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log\"\n\n\"/workspace-scripts/gl-run-internal-blocking-poststart-commands.sh\" 1>>\"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log\" 2>>\"${GL_WORKSPACE_LOGS_DIR}/poststart-stderr.log\"\n\n{\n echo \"$(date -Iseconds): ----------------------------------------\"\n echo \"$(date -Iseconds): Running non-blocking poststart commands script...\"\n} >> \"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log\"\n\n\"/workspace-scripts/gl-run-non-blocking-poststart-commands.sh\" 1>>\"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log\" 2>>\"${GL_WORKSPACE_LOGS_DIR}/poststart-stderr.log\" &\n" + "#!/bin/sh\n\nmkdir -p \"${GL_WORKSPACE_LOGS_DIR}\"\nln -sf \"${GL_WORKSPACE_LOGS_DIR}\" /tmp\n\n# shellcheck disable=SC2129 # We area using redirects with a command block as this warning proposes to do. It must be a false positive from the subsequent lines which handle stdout and stderr seprately.\n{\n echo \"$(date -Iseconds): ----------------------------------------\"\n echo \"$(date -Iseconds): Running poststart commands for workspace...\"\n\n echo \"$(date -Iseconds): ----------------------------------------\"\n echo \"$(date -Iseconds): Running internal blocking poststart commands script...\"\n} >> \"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log\"\n\n\"/workspace-scripts/gl-run-internal-blocking-poststart-commands.sh\" 1>>\"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log\" 2>>\"${GL_WORKSPACE_LOGS_DIR}/poststart-stderr.log\"\n\n{\n echo \"$(date -Iseconds): Finished running internal blocking poststart commands script.\"\n echo \"$(date -Iseconds): ----------------------------------------\"\n echo \"$(date -Iseconds): Running non-blocking poststart commands script...\"\n} >> \"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log\"\n\n\"/workspace-scripts/gl-run-non-blocking-poststart-commands.sh\" 1>>\"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log\" 2>>\"${GL_WORKSPACE_LOGS_DIR}/poststart-stderr.log\" &\n\n{\n echo \"$(date -Iseconds): Finished running non-blocking poststart commands script.\"\n} >> \"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log\"\n" ] } } @@ -948,8 +948,8 @@ def golden_master_desired_config_with_include_all_resources_true namespace: "gl-rd-ns-991-990-fedcba" }, data: { - "gl-run-internal-blocking-poststart-commands.sh": "#!/bin/sh\necho \"$(date -Iseconds): Running /workspace-scripts/gl-internal-example-command-1...\"\n/workspace-scripts/gl-internal-example-command-1 || true\n", - "gl-run-non-blocking-poststart-commands.sh": "#!/bin/sh\necho \"$(date -Iseconds): Running /workspace-scripts/gl-internal-example-command-2...\"\n/workspace-scripts/gl-internal-example-command-2 || true\n", + "gl-run-internal-blocking-poststart-commands.sh": "#!/bin/sh\necho \"$(date -Iseconds): ----------------------------------------\"\necho \"$(date -Iseconds): Running /workspace-scripts/gl-internal-example-command-1...\"\n/workspace-scripts/gl-internal-example-command-1 || true\necho \"$(date -Iseconds): Finished running /workspace-scripts/gl-internal-example-command-1.\"\n", + "gl-run-non-blocking-poststart-commands.sh": "#!/bin/sh\necho \"$(date -Iseconds): ----------------------------------------\"\necho \"$(date -Iseconds): Running /workspace-scripts/gl-internal-example-command-2...\"\n/workspace-scripts/gl-internal-example-command-2 || true\necho \"$(date -Iseconds): Finished running /workspace-scripts/gl-internal-example-command-2.\"\n", "gl-internal-example-command-1": "echo 'gl-internal-example-command-1'", "gl-internal-example-command-2": "echo 'gl-internal-example-command-2'" } @@ -1210,7 +1210,7 @@ def golden_master_desired_config_with_include_all_resources_false command: [ "/bin/sh", "-c", - "#!/bin/sh\n\nmkdir -p \"${GL_WORKSPACE_LOGS_DIR}\"\nln -sf \"${GL_WORKSPACE_LOGS_DIR}\" /tmp\n\n{\n echo \"$(date -Iseconds): ----------------------------------------\"\n echo \"$(date -Iseconds): Running poststart commands for workspace...\"\n\n echo \"$(date -Iseconds): ----------------------------------------\"\n echo \"$(date -Iseconds): Running internal blocking poststart commands script...\"\n} >> \"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log\"\n\n\"/workspace-scripts/gl-run-internal-blocking-poststart-commands.sh\" 1>>\"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log\" 2>>\"${GL_WORKSPACE_LOGS_DIR}/poststart-stderr.log\"\n\n{\n echo \"$(date -Iseconds): ----------------------------------------\"\n echo \"$(date -Iseconds): Running non-blocking poststart commands script...\"\n} >> \"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log\"\n\n\"/workspace-scripts/gl-run-non-blocking-poststart-commands.sh\" 1>>\"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log\" 2>>\"${GL_WORKSPACE_LOGS_DIR}/poststart-stderr.log\" &\n" + "#!/bin/sh\n\nmkdir -p \"${GL_WORKSPACE_LOGS_DIR}\"\nln -sf \"${GL_WORKSPACE_LOGS_DIR}\" /tmp\n\n# shellcheck disable=SC2129 # We area using redirects with a command block as this warning proposes to do. It must be a false positive from the subsequent lines which handle stdout and stderr seprately.\n{\n echo \"$(date -Iseconds): ----------------------------------------\"\n echo \"$(date -Iseconds): Running poststart commands for workspace...\"\n\n echo \"$(date -Iseconds): ----------------------------------------\"\n echo \"$(date -Iseconds): Running internal blocking poststart commands script...\"\n} >> \"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log\"\n\n\"/workspace-scripts/gl-run-internal-blocking-poststart-commands.sh\" 1>>\"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log\" 2>>\"${GL_WORKSPACE_LOGS_DIR}/poststart-stderr.log\"\n\n{\n echo \"$(date -Iseconds): Finished running internal blocking poststart commands script.\"\n echo \"$(date -Iseconds): ----------------------------------------\"\n echo \"$(date -Iseconds): Running non-blocking poststart commands script...\"\n} >> \"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log\"\n\n\"/workspace-scripts/gl-run-non-blocking-poststart-commands.sh\" 1>>\"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log\" 2>>\"${GL_WORKSPACE_LOGS_DIR}/poststart-stderr.log\" &\n\n{\n echo \"$(date -Iseconds): Finished running non-blocking poststart commands script.\"\n} >> \"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log\"\n" ] } } @@ -1528,8 +1528,8 @@ def golden_master_desired_config_with_include_all_resources_false namespace: "gl-rd-ns-991-990-fedcba" }, data: { - "gl-run-internal-blocking-poststart-commands.sh": "#!/bin/sh\necho \"$(date -Iseconds): Running /workspace-scripts/gl-internal-example-command-1...\"\n/workspace-scripts/gl-internal-example-command-1 || true\n", - "gl-run-non-blocking-poststart-commands.sh": "#!/bin/sh\necho \"$(date -Iseconds): Running /workspace-scripts/gl-internal-example-command-2...\"\n/workspace-scripts/gl-internal-example-command-2 || true\n", + "gl-run-internal-blocking-poststart-commands.sh": "#!/bin/sh\necho \"$(date -Iseconds): ----------------------------------------\"\necho \"$(date -Iseconds): Running /workspace-scripts/gl-internal-example-command-1...\"\n/workspace-scripts/gl-internal-example-command-1 || true\necho \"$(date -Iseconds): Finished running /workspace-scripts/gl-internal-example-command-1.\"\n", + "gl-run-non-blocking-poststart-commands.sh": "#!/bin/sh\necho \"$(date -Iseconds): ----------------------------------------\"\necho \"$(date -Iseconds): Running /workspace-scripts/gl-internal-example-command-2...\"\n/workspace-scripts/gl-internal-example-command-2 || true\necho \"$(date -Iseconds): Finished running /workspace-scripts/gl-internal-example-command-2.\"\n", "gl-internal-example-command-1": "echo 'gl-internal-example-command-1'", "gl-internal-example-command-2": "echo 'gl-internal-example-command-2'" } @@ -2009,7 +2009,7 @@ def golden_master_desired_config_from_legacy_devfile_with_poststart_and_with_inc namespace: "gl-rd-ns-991-990-fedcba" }, data: { - "gl-run-poststart-commands.sh": "#!/bin/sh\necho \"$(date -Iseconds): Running /workspace-scripts/gl-internal-example-command-1...\"\n/workspace-scripts/gl-internal-example-command-1 || true\necho \"$(date -Iseconds): Running /workspace-scripts/gl-internal-example-command-2...\"\n/workspace-scripts/gl-internal-example-command-2 || true\n", + "gl-run-poststart-commands.sh": "#!/bin/sh\necho \"$(date -Iseconds): ----------------------------------------\"\necho \"$(date -Iseconds): Running /workspace-scripts/gl-internal-example-command-1...\"\n/workspace-scripts/gl-internal-example-command-1 || true\necho \"$(date -Iseconds): Finished running /workspace-scripts/gl-internal-example-command-1.\"\necho \"$(date -Iseconds): ----------------------------------------\"\necho \"$(date -Iseconds): Running /workspace-scripts/gl-internal-example-command-2...\"\n/workspace-scripts/gl-internal-example-command-2 || true\necho \"$(date -Iseconds): Finished running /workspace-scripts/gl-internal-example-command-2.\"\n", "gl-internal-example-command-1": "echo 'gl-internal-example-command-1'", "gl-internal-example-command-2": "echo 'gl-internal-example-command-2'" } @@ -2845,7 +2845,7 @@ def golden_master_desired_config_for_shared_namespace_with_include_all_resources command: [ "/bin/sh", "-c", - "#!/bin/sh\n\nmkdir -p \"${GL_WORKSPACE_LOGS_DIR}\"\nln -sf \"${GL_WORKSPACE_LOGS_DIR}\" /tmp\n\n{\n echo \"$(date -Iseconds): ----------------------------------------\"\n echo \"$(date -Iseconds): Running poststart commands for workspace...\"\n\n echo \"$(date -Iseconds): ----------------------------------------\"\n echo \"$(date -Iseconds): Running internal blocking poststart commands script...\"\n} >> \"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log\"\n\n\"/workspace-scripts/gl-run-internal-blocking-poststart-commands.sh\" 1>>\"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log\" 2>>\"${GL_WORKSPACE_LOGS_DIR}/poststart-stderr.log\"\n\n{\n echo \"$(date -Iseconds): ----------------------------------------\"\n echo \"$(date -Iseconds): Running non-blocking poststart commands script...\"\n} >> \"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log\"\n\n\"/workspace-scripts/gl-run-non-blocking-poststart-commands.sh\" 1>>\"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log\" 2>>\"${GL_WORKSPACE_LOGS_DIR}/poststart-stderr.log\" &\n" + "#!/bin/sh\n\nmkdir -p \"${GL_WORKSPACE_LOGS_DIR}\"\nln -sf \"${GL_WORKSPACE_LOGS_DIR}\" /tmp\n\n# shellcheck disable=SC2129 # We area using redirects with a command block as this warning proposes to do. It must be a false positive from the subsequent lines which handle stdout and stderr seprately.\n{\n echo \"$(date -Iseconds): ----------------------------------------\"\n echo \"$(date -Iseconds): Running poststart commands for workspace...\"\n\n echo \"$(date -Iseconds): ----------------------------------------\"\n echo \"$(date -Iseconds): Running internal blocking poststart commands script...\"\n} >> \"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log\"\n\n\"/workspace-scripts/gl-run-internal-blocking-poststart-commands.sh\" 1>>\"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log\" 2>>\"${GL_WORKSPACE_LOGS_DIR}/poststart-stderr.log\"\n\n{\n echo \"$(date -Iseconds): Finished running internal blocking poststart commands script.\"\n echo \"$(date -Iseconds): ----------------------------------------\"\n echo \"$(date -Iseconds): Running non-blocking poststart commands script...\"\n} >> \"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log\"\n\n\"/workspace-scripts/gl-run-non-blocking-poststart-commands.sh\" 1>>\"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log\" 2>>\"${GL_WORKSPACE_LOGS_DIR}/poststart-stderr.log\" &\n\n{\n echo \"$(date -Iseconds): Finished running non-blocking poststart commands script.\"\n} >> \"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log\"\n" ] } } @@ -3173,8 +3173,8 @@ def golden_master_desired_config_for_shared_namespace_with_include_all_resources namespace: "default" }, data: { - "gl-run-internal-blocking-poststart-commands.sh": "#!/bin/sh\necho \"$(date -Iseconds): Running /workspace-scripts/gl-internal-example-command-1...\"\n/workspace-scripts/gl-internal-example-command-1 || true\n", - "gl-run-non-blocking-poststart-commands.sh": "#!/bin/sh\necho \"$(date -Iseconds): Running /workspace-scripts/gl-internal-example-command-2...\"\n/workspace-scripts/gl-internal-example-command-2 || true\n", + "gl-run-internal-blocking-poststart-commands.sh": "#!/bin/sh\necho \"$(date -Iseconds): ----------------------------------------\"\necho \"$(date -Iseconds): Running /workspace-scripts/gl-internal-example-command-1...\"\n/workspace-scripts/gl-internal-example-command-1 || true\necho \"$(date -Iseconds): Finished running /workspace-scripts/gl-internal-example-command-1.\"\n", + "gl-run-non-blocking-poststart-commands.sh": "#!/bin/sh\necho \"$(date -Iseconds): ----------------------------------------\"\necho \"$(date -Iseconds): Running /workspace-scripts/gl-internal-example-command-2...\"\n/workspace-scripts/gl-internal-example-command-2 || true\necho \"$(date -Iseconds): Finished running /workspace-scripts/gl-internal-example-command-2.\"\n", "gl-internal-example-command-1": "echo 'gl-internal-example-command-1'", "gl-internal-example-command-2": "echo 'gl-internal-example-command-2'" } @@ -3413,7 +3413,7 @@ def golden_master_desired_config_for_shared_namespace_with_include_all_resources command: [ "/bin/sh", "-c", - "#!/bin/sh\n\nmkdir -p \"${GL_WORKSPACE_LOGS_DIR}\"\nln -sf \"${GL_WORKSPACE_LOGS_DIR}\" /tmp\n\n{\n echo \"$(date -Iseconds): ----------------------------------------\"\n echo \"$(date -Iseconds): Running poststart commands for workspace...\"\n\n echo \"$(date -Iseconds): ----------------------------------------\"\n echo \"$(date -Iseconds): Running internal blocking poststart commands script...\"\n} >> \"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log\"\n\n\"/workspace-scripts/gl-run-internal-blocking-poststart-commands.sh\" 1>>\"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log\" 2>>\"${GL_WORKSPACE_LOGS_DIR}/poststart-stderr.log\"\n\n{\n echo \"$(date -Iseconds): ----------------------------------------\"\n echo \"$(date -Iseconds): Running non-blocking poststart commands script...\"\n} >> \"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log\"\n\n\"/workspace-scripts/gl-run-non-blocking-poststart-commands.sh\" 1>>\"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log\" 2>>\"${GL_WORKSPACE_LOGS_DIR}/poststart-stderr.log\" &\n" + "#!/bin/sh\n\nmkdir -p \"${GL_WORKSPACE_LOGS_DIR}\"\nln -sf \"${GL_WORKSPACE_LOGS_DIR}\" /tmp\n\n# shellcheck disable=SC2129 # We area using redirects with a command block as this warning proposes to do. It must be a false positive from the subsequent lines which handle stdout and stderr seprately.\n{\n echo \"$(date -Iseconds): ----------------------------------------\"\n echo \"$(date -Iseconds): Running poststart commands for workspace...\"\n\n echo \"$(date -Iseconds): ----------------------------------------\"\n echo \"$(date -Iseconds): Running internal blocking poststart commands script...\"\n} >> \"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log\"\n\n\"/workspace-scripts/gl-run-internal-blocking-poststart-commands.sh\" 1>>\"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log\" 2>>\"${GL_WORKSPACE_LOGS_DIR}/poststart-stderr.log\"\n\n{\n echo \"$(date -Iseconds): Finished running internal blocking poststart commands script.\"\n echo \"$(date -Iseconds): ----------------------------------------\"\n echo \"$(date -Iseconds): Running non-blocking poststart commands script...\"\n} >> \"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log\"\n\n\"/workspace-scripts/gl-run-non-blocking-poststart-commands.sh\" 1>>\"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log\" 2>>\"${GL_WORKSPACE_LOGS_DIR}/poststart-stderr.log\" &\n\n{\n echo \"$(date -Iseconds): Finished running non-blocking poststart commands script.\"\n} >> \"${GL_WORKSPACE_LOGS_DIR}/poststart-stdout.log\"\n" ] } } @@ -3741,8 +3741,8 @@ def golden_master_desired_config_for_shared_namespace_with_include_all_resources namespace: "default" }, data: { - "gl-run-internal-blocking-poststart-commands.sh": "#!/bin/sh\necho \"$(date -Iseconds): Running /workspace-scripts/gl-internal-example-command-1...\"\n/workspace-scripts/gl-internal-example-command-1 || true\n", - "gl-run-non-blocking-poststart-commands.sh": "#!/bin/sh\necho \"$(date -Iseconds): Running /workspace-scripts/gl-internal-example-command-2...\"\n/workspace-scripts/gl-internal-example-command-2 || true\n", + "gl-run-internal-blocking-poststart-commands.sh": "#!/bin/sh\necho \"$(date -Iseconds): ----------------------------------------\"\necho \"$(date -Iseconds): Running /workspace-scripts/gl-internal-example-command-1...\"\n/workspace-scripts/gl-internal-example-command-1 || true\necho \"$(date -Iseconds): Finished running /workspace-scripts/gl-internal-example-command-1.\"\n", + "gl-run-non-blocking-poststart-commands.sh": "#!/bin/sh\necho \"$(date -Iseconds): ----------------------------------------\"\necho \"$(date -Iseconds): Running /workspace-scripts/gl-internal-example-command-2...\"\n/workspace-scripts/gl-internal-example-command-2 || true\necho \"$(date -Iseconds): Finished running /workspace-scripts/gl-internal-example-command-2.\"\n", "gl-internal-example-command-1": "echo 'gl-internal-example-command-1'", "gl-internal-example-command-2": "echo 'gl-internal-example-command-2'" } diff --git a/ee/spec/support/helpers/remote_development/fixture_file_helpers.rb b/ee/spec/support/helpers/remote_development/fixture_file_helpers.rb index e27999c2a1fbf93a73fb056cfc50e03422c530b7..c9a86e84d916f879f644f1ec80c9616409b74e2f 100644 --- a/ee/spec/support/helpers/remote_development/fixture_file_helpers.rb +++ b/ee/spec/support/helpers/remote_development/fixture_file_helpers.rb @@ -59,6 +59,7 @@ def format_clone_project_script!( "%s", Shellwords.shellescape("#{WORKSPACE_DATA_VOLUME_PATH}/#{project_name}") ) + content.gsub!("%s", CLONE_DEPTH_OPTION) nil end diff --git a/ee/spec/support/shared_contexts/remote_development/remote_development_shared_contexts.rb b/ee/spec/support/shared_contexts/remote_development/remote_development_shared_contexts.rb index 81fb3b9102636e223f179704fe3962b830d0d606..d575399d3867dd5713a666c2072a8dba29651560 100644 --- a/ee/spec/support/shared_contexts/remote_development/remote_development_shared_contexts.rb +++ b/ee/spec/support/shared_contexts/remote_development/remote_development_shared_contexts.rb @@ -1165,12 +1165,22 @@ def workspace_network_policy( def internal_blocking_poststart_commands_script <<~SCRIPT #!/bin/sh + echo "$(date -Iseconds): ----------------------------------------" echo "$(date -Iseconds): Running #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-clone-project-command..." #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-clone-project-command || true + echo "$(date -Iseconds): Finished running #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-clone-project-command." + echo "$(date -Iseconds): ----------------------------------------" + echo "$(date -Iseconds): Running #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-clone-unshallow-command..." + #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-clone-unshallow-command || true + echo "$(date -Iseconds): Finished running #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-clone-unshallow-command." + echo "$(date -Iseconds): ----------------------------------------" echo "$(date -Iseconds): Running #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-start-sshd-command..." #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-start-sshd-command || true + echo "$(date -Iseconds): Finished running #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-start-sshd-command." + echo "$(date -Iseconds): ----------------------------------------" echo "$(date -Iseconds): Running #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-init-tools-command..." #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-init-tools-command || true + echo "$(date -Iseconds): Finished running #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-init-tools-command." SCRIPT end @@ -1179,15 +1189,19 @@ def internal_blocking_poststart_commands_script def non_blocking_poststart_commands_script(user_command_ids: []) script = <<~SCRIPT #!/bin/sh + echo "$(date -Iseconds): ----------------------------------------" echo "$(date -Iseconds): Running #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-sleep-until-container-is-running-command..." #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-sleep-until-container-is-running-command || true + echo "$(date -Iseconds): Finished running #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-sleep-until-container-is-running-command." SCRIPT # Add user-defined commands if any user_command_ids.each do |command_id| script += <<~SCRIPT + echo "$(date -Iseconds): ----------------------------------------" echo "$(date -Iseconds): Running #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/#{command_id}..." #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/#{command_id} || true + echo "$(date -Iseconds): Finished running #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/#{command_id}." SCRIPT end @@ -1198,14 +1212,22 @@ def non_blocking_poststart_commands_script(user_command_ids: []) def legacy_poststart_commands_script <<~SCRIPT #!/bin/sh + echo "$(date -Iseconds): ----------------------------------------" echo "$(date -Iseconds): Running #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-clone-project-command..." #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-clone-project-command || true + echo "$(date -Iseconds): Finished running #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-clone-project-command." + echo "$(date -Iseconds): ----------------------------------------" echo "$(date -Iseconds): Running #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-start-sshd-command..." #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-start-sshd-command || true + echo "$(date -Iseconds): Finished running #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-start-sshd-command." + echo "$(date -Iseconds): ----------------------------------------" echo "$(date -Iseconds): Running #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-init-tools-command..." #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-init-tools-command || true + echo "$(date -Iseconds): Finished running #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-init-tools-command." + echo "$(date -Iseconds): ----------------------------------------" echo "$(date -Iseconds): Running #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-sleep-until-container-is-running-command..." #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-sleep-until-container-is-running-command || true + echo "$(date -Iseconds): Finished running #{create_constants_module::WORKSPACE_SCRIPTS_VOLUME_PATH}/gl-sleep-until-container-is-running-command." SCRIPT end @@ -1221,7 +1243,20 @@ def clone_project_script project_cloning_successful_file: Shellwords.shellescape(project_cloning_successful_file), clone_dir: Shellwords.shellescape(clone_dir), project_ref: Shellwords.shellescape(project_ref), - project_url: Shellwords.shellescape(project_url) + project_url: Shellwords.shellescape(project_url), + clone_depth_option: create_constants_module::CLONE_DEPTH_OPTION + ) + end + + # @return [String] + def clone_unshallow_script + volume_path = workspace_operations_constants_module::WORKSPACE_DATA_VOLUME_PATH + project_cloning_successful_file = "#{volume_path}/#{create_constants_module::PROJECT_CLONING_SUCCESSFUL_FILE_NAME}" + clone_dir = "#{workspace_operations_constants_module::WORKSPACE_DATA_VOLUME_PATH}/test-project" + format( + RemoteDevelopment::Files::INTERNAL_POSTSTART_COMMAND_CLONE_UNSHALLOW_SCRIPT, + project_cloning_successful_file: Shellwords.shellescape(project_cloning_successful_file), + clone_dir: Shellwords.shellescape(clone_dir) ) end @@ -1253,6 +1288,7 @@ def scripts_configmap( data = { "gl-clone-project-command": clone_project_script, + "gl-clone-unshallow-command": clone_unshallow_script, "gl-init-tools-command": files_module::INTERNAL_POSTSTART_COMMAND_START_VSCODE_SCRIPT, create_constants_module::RUN_INTERNAL_BLOCKING_POSTSTART_COMMANDS_SCRIPT_NAME.to_sym => internal_blocking_poststart_commands_script, @@ -1265,6 +1301,7 @@ def scripts_configmap( if legacy_poststart_container_command data.delete(create_constants_module::RUN_INTERNAL_BLOCKING_POSTSTART_COMMANDS_SCRIPT_NAME.to_sym) data.delete(create_constants_module::RUN_NON_BLOCKING_POSTSTART_COMMANDS_SCRIPT_NAME.to_sym) + data.delete(:"gl-clone-unshallow-command") data[create_constants_module::LEGACY_RUN_POSTSTART_COMMANDS_SCRIPT_NAME.to_sym] = legacy_poststart_commands_script end