Skip to content
代码片段 群组 项目
提交 5dd3fde9 编辑于 作者: Ash McKenzie's avatar Ash McKenzie
浏览文件

Merge branch '1977-automate-bootstrap-gdk-in-workspace' into 'main'

No related branches found
No related tags found
无相关合并请求
{
"version": "2.0.0",
"tasks": [
{
"label": "Bootstrap GDK",
"type": "shell",
"command": "support/gitlab-remote-development/setup_workspace.rb",
"presentation": {
"echo": true,
"reveal": "always"
},
"runOptions": {
"reevaluateOnRerun": true,
"runOn": "folderOpen"
}
}
]
}
......@@ -38,13 +38,10 @@ alt="Workspaces overview page">
## Run GDK in your workspace
1. On the left sidebar, open the terminal.
1. Select __Terminal > New Terminal__.
1. The _Bootstrap GDK_ task starts automatically when a workspace is opened, executing the [bootstrap script](../../support/gitlab-remote-development/setup_workspace.rb).
1. After the bootstrap script finishes, you'll see a prompt asking if you want to send duration data.
1. After responding, enter any command to close the task terminal.
<img src="img/remote-development-select-terminal.png" width="800"
alt="Remote development New Terminal button in Terminal menu">
Your GDK should now be ready to use.
1. Run the command `support/gitlab-remote-development/setup_workspace.rb`. The GDK link is displayed.
<img src="img/remote-development-bootstrapped-gdk.png" width="800"
alt="Remote development Terminal window showing workspace URL">
<img src="img/remote-development-bootstrapped-gdk.png" width="800" alt="Remote development Terminal window showing workspace URL">
......@@ -23,23 +23,42 @@
end
describe '#run', :hide_output do
context 'when telemetry is allowed' do
it 'executes the bootstrap script and sends telemetry' do
expect(workspace).to receive(:execute_bootstrap)
expect(workspace).to receive(:send_telemetry).with(success, duration)
context 'when bootstrap is needed' do
before do
allow(workspace).to receive(:bootstrap_needed?).and_return(true)
end
workspace.run
context 'when telemetry is allowed' do
it 'executes the bootstrap script and sends telemetry' do
expect(workspace).to receive(:execute_bootstrap)
expect(workspace).to receive(:send_telemetry).with(success, duration)
workspace.run
end
end
context 'when telemetry is not allowed' do
before do
allow($stdin).to receive(:gets).and_return('no')
end
it 'executes the bootstrap script but does not send telemetry' do
expect(workspace).to receive(:execute_bootstrap)
expect(workspace).not_to receive(:send_telemetry)
workspace.run
end
end
end
context 'when telemetry is not allowed' do
context 'when bootstrap is not needed' do
before do
allow($stdin).to receive(:gets).and_return('no')
allow(workspace).to receive(:bootstrap_needed?).and_return(false)
end
it 'executes the bootstrap script but does not send telemetry' do
expect(workspace).to receive(:execute_bootstrap)
expect(workspace).not_to receive(:send_telemetry)
it 'does not execute the bootstrap script and outputs information about GDK is already being bootstrapped' do
expect(workspace).not_to receive(:execute_bootstrap)
expect(GDK::Output).to receive(:info).with("#{SetupWorkspace::GDK_BOOTSTRAPPED_FILE} exists, GDK has already been bootstrapped.\n\nRemove the #{SetupWorkspace::GDK_BOOTSTRAPPED_FILE} to re-bootstrap.")
workspace.run
end
......
......@@ -6,17 +6,26 @@
class SetupWorkspace
ROOT_DIR = '/projects/gitlab-development-kit'
GDK_BOOTSTRAPPED_FILE = "#{ROOT_DIR}/.cache/.gdk_bootstrapped".freeze
def run
success, duration = execute_bootstrap
if bootstrap_needed?
success, duration = execute_bootstrap
return unless allow_sending_telemetry?
return unless allow_sending_telemetry?
send_telemetry(success, duration)
send_telemetry(success, duration)
else
GDK::Output.info("#{GDK_BOOTSTRAPPED_FILE} exists, GDK has already been bootstrapped.\n\nRemove the #{GDK_BOOTSTRAPPED_FILE} to re-bootstrap.")
end
end
private
def bootstrap_needed?
!File.exist?(GDK_BOOTSTRAPPED_FILE)
end
def execute_bootstrap
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
success = Dir.chdir(ROOT_DIR) do
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册