From 0dba6dc8568a8f4afc99dc9e616cc4f7c8669be5 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer <jacob@gitlab.com> Date: Mon, 8 Aug 2016 15:23:48 +0200 Subject: [PATCH 01/11] Add 'gdk' command wrapper --- .gitignore | 1 + HELP | 12 ++++++------ bootstrap | 12 ++++++++++++ env.sh | 1 + gdk.rb | 24 ++++++++++++++++++++++++ 5 files changed, 44 insertions(+), 6 deletions(-) create mode 100755 bootstrap create mode 100644 env.sh create mode 100644 gdk.rb diff --git a/.gitignore b/.gitignore index 28f6fc3..0f6ab02 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,4 @@ /nginx/uwsgi_temp /.gitlab-shell-bundle /.gitlab-bundle +/gdk diff --git a/HELP b/HELP index ca4583e..d69fb56 100644 --- a/HELP +++ b/HELP @@ -1,11 +1,11 @@ # GitLab Development Kit cheat sheet -./run # Start everything -./run db # Start enough to run tests -./run app # Start GitLab, need './run db' +./gdk run # Start everything +./gdk run db # Start enough to run tests +./gdk run app # Start GitLab, need './run db' -make gitlab_repo=https://my-fork # Install everything -make update # Pull application changes from Git -make clean-config all # Delete and regenerate all config files created by GDK +./gdk install gitlab_repo=https://my-fork # Install everything +./gdk update # Pull application changes from Git +./gdk reconfigure # Delete and regenerate all config files created by GDK # Development admin account: root / 5iveL!fe diff --git a/bootstrap b/bootstrap new file mode 100755 index 0000000..94552d0 --- /dev/null +++ b/bootstrap @@ -0,0 +1,12 @@ +#!/bin/sh + +cat > gdk <<EOF +#!/bin/sh +export GDK_ROOT=$(pwd) +export GDK_INVOKED=\$0 +exec /usr/bin/env ruby \$GDK_ROOT/gdk.rb "\$@" +EOF + +chmod +x gdk + +exec ./gdk install diff --git a/env.sh b/env.sh new file mode 100644 index 0000000..ab1ca11 --- /dev/null +++ b/env.sh @@ -0,0 +1 @@ +export PATH=$(pwd)/bin/:$PATH diff --git a/gdk.rb b/gdk.rb new file mode 100644 index 0000000..98cf61a --- /dev/null +++ b/gdk.rb @@ -0,0 +1,24 @@ +GDK_ROOT = ENV.delete('GDK_ROOT').to_s +PROGNAME = ENV.delete('GDK_INVOKED').to_s + +def main + case ARGV.shift + when 'run' + system('./run', *ARGV, chdir: GDK_ROOT) + when 'install' + system('make', *ARGV, chdir: GDK_ROOT) + when 'update' + system('make', 'update', chdir: GDK_ROOT) + when 'reconfigure' + system('make', 'clean-config', 'all', chdir: GDK_ROOT) + when 'help' + puts File.read(File.join(GDK_ROOT, 'HELP')).gsub(/^\.\/gdk/, PROGNAME) + true + else + puts "Usage: #{PROGNAME} run|install|update|reconfigure|help [ARGS...]" + false + end +end + +exit main + -- GitLab From 5ce7fd4768faec4e7acf8127bfa1c9ccc0f4f81b Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer <jacob@gitlab.com> Date: Mon, 8 Aug 2016 15:25:15 +0200 Subject: [PATCH 02/11] Remove unused env.sh --- env.sh | 1 - 1 file changed, 1 deletion(-) delete mode 100644 env.sh diff --git a/env.sh b/env.sh deleted file mode 100644 index ab1ca11..0000000 --- a/env.sh +++ /dev/null @@ -1 +0,0 @@ -export PATH=$(pwd)/bin/:$PATH -- GitLab From 8e49ac731ecb6f1138b4549072b998db005bc63d Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer <jacob@gitlab.com> Date: Mon, 8 Aug 2016 15:28:10 +0200 Subject: [PATCH 03/11] Align all the things --- HELP | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/HELP b/HELP index d69fb56..61c88e4 100644 --- a/HELP +++ b/HELP @@ -5,7 +5,7 @@ ./gdk run app # Start GitLab, need './run db' ./gdk install gitlab_repo=https://my-fork # Install everything -./gdk update # Pull application changes from Git -./gdk reconfigure # Delete and regenerate all config files created by GDK +./gdk update # Pull application changes from Git +./gdk reconfigure # Delete and regenerate all config files created by GDK # Development admin account: root / 5iveL!fe -- GitLab From aba04480160f822c4cedd6dff343958ba46c6399 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer <jacob@gitlab.com> Date: Mon, 8 Aug 2016 15:35:52 +0200 Subject: [PATCH 04/11] Prefer explicit "gdk install" --- bootstrap | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bootstrap b/bootstrap index 94552d0..52f3dfd 100755 --- a/bootstrap +++ b/bootstrap @@ -1,12 +1,16 @@ #!/bin/sh +gdk_path=$(pwd)/gdk -cat > gdk <<EOF +printf "Creating executable: ${gdk_path} ... " + +cat > ${gdk_path} <<EOF #!/bin/sh export GDK_ROOT=$(pwd) export GDK_INVOKED=\$0 exec /usr/bin/env ruby \$GDK_ROOT/gdk.rb "\$@" EOF -chmod +x gdk - -exec ./gdk install +chmod +x ${gdk_path} +echo done +echo +./gdk help -- GitLab From 13623661f7f9566211cbf25a1d2137cc46d81a0a Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer <jacob@gitlab.com> Date: Mon, 8 Aug 2016 16:25:30 +0200 Subject: [PATCH 05/11] Make gdk a gem --- .gitignore | 1 + GDK_ROOT | 0 HELP | 12 ++++++------ bin/gdk | 30 ++++++++++++++++++++++++++++++ gdk.rb | 24 ------------------------ gitlab-development-kit.gemspec | 15 +++++++++++++++ lib/gdk.rb | 22 ++++++++++++++++++++++ 7 files changed, 74 insertions(+), 30 deletions(-) create mode 100644 GDK_ROOT create mode 100755 bin/gdk delete mode 100644 gdk.rb create mode 100644 gitlab-development-kit.gemspec create mode 100644 lib/gdk.rb diff --git a/.gitignore b/.gitignore index 0f6ab02..e4e5c53 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,4 @@ /.gitlab-shell-bundle /.gitlab-bundle /gdk +/*.gem diff --git a/GDK_ROOT b/GDK_ROOT new file mode 100644 index 0000000..e69de29 diff --git a/HELP b/HELP index 61c88e4..dcc5774 100644 --- a/HELP +++ b/HELP @@ -1,11 +1,11 @@ # GitLab Development Kit cheat sheet -./gdk run # Start everything -./gdk run db # Start enough to run tests -./gdk run app # Start GitLab, need './run db' +gdk run # Start everything +gdk run db # Start enough to run tests +gdk run app # Start GitLab, needs 'gdk run db' -./gdk install gitlab_repo=https://my-fork # Install everything -./gdk update # Pull application changes from Git -./gdk reconfigure # Delete and regenerate all config files created by GDK +gdk install gitlab_repo=https://my-fork # Install everything +gdk update # Pull application changes from Git +gdk reconfigure # Delete and regenerate all config files created by GDK # Development admin account: root / 5iveL!fe diff --git a/bin/gdk b/bin/gdk new file mode 100755 index 0000000..52440fa --- /dev/null +++ b/bin/gdk @@ -0,0 +1,30 @@ +#!/usr/bin/env ruby +require 'fileutils' + +def main + case ARGV.first + when 'init' + system(*%W(git clone -b gdk-cli https://gitlab.com/gitlab-org/gitlab-development-kit.git)) + else + $gdk_root = find_root(Dir.pwd) + if $gdk_root.nil? + puts "Could not find GDK_ROOT in the current directory or any of its parents." + return false + end + puts "(in #{$gdk_root})" + load(File.join($gdk_root, 'lib/gdk.rb')) + GDK::main + end +end + +def find_root(current) + if File.exist?(File.join(current, 'GDK_ROOT')) + File.realpath(current) + elsif File.realpath(current) == '/' + nil + else + find_root(File.join(current, '..')) + end +end + +exit(main) diff --git a/gdk.rb b/gdk.rb deleted file mode 100644 index 98cf61a..0000000 --- a/gdk.rb +++ /dev/null @@ -1,24 +0,0 @@ -GDK_ROOT = ENV.delete('GDK_ROOT').to_s -PROGNAME = ENV.delete('GDK_INVOKED').to_s - -def main - case ARGV.shift - when 'run' - system('./run', *ARGV, chdir: GDK_ROOT) - when 'install' - system('make', *ARGV, chdir: GDK_ROOT) - when 'update' - system('make', 'update', chdir: GDK_ROOT) - when 'reconfigure' - system('make', 'clean-config', 'all', chdir: GDK_ROOT) - when 'help' - puts File.read(File.join(GDK_ROOT, 'HELP')).gsub(/^\.\/gdk/, PROGNAME) - true - else - puts "Usage: #{PROGNAME} run|install|update|reconfigure|help [ARGS...]" - false - end -end - -exit main - diff --git a/gitlab-development-kit.gemspec b/gitlab-development-kit.gemspec new file mode 100644 index 0000000..8aedf34 --- /dev/null +++ b/gitlab-development-kit.gemspec @@ -0,0 +1,15 @@ +# coding: utf-8 + +Gem::Specification.new do |spec| + spec.name = "gitlab-development-kit" + spec.version = '0.1.0' + spec.authors = ["Jacob Vosmaer"] + spec.email = ["jacob@gitlab.com"] + + spec.summary = %q{CLI for GitLab Development Kit} + spec.description = %q{CLI for GitLab Development Kit.} + spec.homepage = "https://gitlab.com/gitlab-org/gitlab-development-kit" + spec.license = "MIT" + spec.files = [] + spec.executables = ['gdk'] +end diff --git a/lib/gdk.rb b/lib/gdk.rb new file mode 100644 index 0000000..f40ef61 --- /dev/null +++ b/lib/gdk.rb @@ -0,0 +1,22 @@ +module GDK + PROGNAME = 'gdk' + + def self.main + case ARGV.shift + when 'run' + system('./run', *ARGV, chdir: $gdk_root) + when 'install' + system('make', *ARGV, chdir: $gdk_root) + when 'update' + system('make', 'update', chdir: $gdk_root) + when 'reconfigure' + system('make', 'clean-config', 'all', chdir: $gdk_root) + when 'help' + puts File.read(File.join($gdk_root, 'HELP')) + true + else + puts "Usage: #{PROGNAME} run|init|install|update|reconfigure|help [ARGS...]" + false + end + end +end -- GitLab From 5a851de1dc7f80342b861fe369471439a2cf830a Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer <jacob@gitlab.com> Date: Mon, 8 Aug 2016 16:26:51 +0200 Subject: [PATCH 06/11] No longer use /gdk --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index e4e5c53..7db39ef 100644 --- a/.gitignore +++ b/.gitignore @@ -43,5 +43,4 @@ /nginx/uwsgi_temp /.gitlab-shell-bundle /.gitlab-bundle -/gdk /*.gem -- GitLab From 921843bf12a54b0b9bf5447e1ece3955215f805e Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer <jacob@gitlab.com> Date: Mon, 8 Aug 2016 16:33:02 +0200 Subject: [PATCH 07/11] Allow passing a directory to gdk init --- bin/gdk | 9 ++++++++- gitlab-development-kit.gemspec | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/bin/gdk b/bin/gdk index 52440fa..651425c 100755 --- a/bin/gdk +++ b/bin/gdk @@ -4,7 +4,14 @@ require 'fileutils' def main case ARGV.first when 'init' - system(*%W(git clone -b gdk-cli https://gitlab.com/gitlab-org/gitlab-development-kit.git)) + if ARGV.count > 2 + puts "Usage: gdk init [DIR]" + return false + end + + cmd = %W(git clone -b gdk-cli https://gitlab.com/gitlab-org/gitlab-development-kit.git) + cmd << ARGV[1] if ARGV.count == 2 + system(*cmd) else $gdk_root = find_root(Dir.pwd) if $gdk_root.nil? diff --git a/gitlab-development-kit.gemspec b/gitlab-development-kit.gemspec index 8aedf34..8a55197 100644 --- a/gitlab-development-kit.gemspec +++ b/gitlab-development-kit.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |spec| spec.name = "gitlab-development-kit" - spec.version = '0.1.0' + spec.version = '0.1.1' spec.authors = ["Jacob Vosmaer"] spec.email = ["jacob@gitlab.com"] -- GitLab From eb711c830c1b7aeed1bf62585988975fc10f0933 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer <jacob@gitlab.com> Date: Mon, 8 Aug 2016 16:37:59 +0200 Subject: [PATCH 08/11] Update docs and koding for "gdk" command --- .koding.yml | 7 ++++--- bootstrap | 16 ---------------- doc/howto/browse.md | 2 +- doc/howto/https.md | 4 ++-- doc/howto/local_network.md | 4 ++-- doc/howto/performance_metrics.md | 2 +- doc/howto/pry.md | 4 ++-- doc/set-up-gdk.md | 26 ++++++++++++++------------ 8 files changed, 26 insertions(+), 39 deletions(-) delete mode 100755 bootstrap diff --git a/.koding.yml b/.koding.yml index 2aa6bc2..72f67f7 100644 --- a/.koding.yml +++ b/.koding.yml @@ -51,14 +51,15 @@ resource: echo _KD_NOTIFY_@Cloning GitLab repository...@ # clone and run gitlab - git clone https://gitlab.com/gitlab-org/gitlab-development-kit.git + gem install gitlab-development-kit + gdk init # force to use 0.0.0.0 for localhost echo "0.0.0.0" > gitlab-development-kit/host echo _KD_NOTIFY_@Compiling GitLab...@ cd gitlab-development-kit - make + gdk install EOF @@ -70,7 +71,7 @@ resource: echo "" echo "Now launch a new terminal and do;" echo " $ cd gitlab-development-kit" - echo " $ ./run" + echo " $ gdk run" echo "" echo _KD_DONE_ diff --git a/bootstrap b/bootstrap deleted file mode 100755 index 52f3dfd..0000000 --- a/bootstrap +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh -gdk_path=$(pwd)/gdk - -printf "Creating executable: ${gdk_path} ... " - -cat > ${gdk_path} <<EOF -#!/bin/sh -export GDK_ROOT=$(pwd) -export GDK_INVOKED=\$0 -exec /usr/bin/env ruby \$GDK_ROOT/gdk.rb "\$@" -EOF - -chmod +x ${gdk_path} -echo done -echo -./gdk help diff --git a/doc/howto/browse.md b/doc/howto/browse.md index 6b417d9..217dd50 100644 --- a/doc/howto/browse.md +++ b/doc/howto/browse.md @@ -5,7 +5,7 @@ quickest way to do it. ``` cd gitlab-development-kit -./run +gdk run ``` Open [localhost:3000](http://localhost:3000) in your web browser. It diff --git a/doc/howto/https.md b/doc/howto/https.md index 0a3c803..7198caf 100644 --- a/doc/howto/https.md +++ b/doc/howto/https.md @@ -15,8 +15,8 @@ On OS X you can add this certificate to the trust store with: Next make sure that HTTPS is enabled in gitlab/config/gitlab.yml: look for the `https:` and `port:` settings. -Uncomment the `nginx` line in your Procfile. Now `./run app` -(and `./run`) will start NGINX listening on https://localhost:3443. +Uncomment the `nginx` line in your Procfile. Now `gdk run app` +(and `gdk run`) will start NGINX listening on https://localhost:3443. If you are using a port other than localhost:3000 for gitlab-workhorse, or if you want to use a port other than diff --git a/doc/howto/local_network.md b/doc/howto/local_network.md index f4f4067..0f1c4f4 100644 --- a/doc/howto/local_network.md +++ b/doc/howto/local_network.md @@ -6,12 +6,12 @@ application then run: ``` echo 0.0.0.0 > host -./run +gdk run ``` If you would like to revert back to the `localhost` network then run: ``` rm host -./run +gdk run ``` diff --git a/doc/howto/performance_metrics.md b/doc/howto/performance_metrics.md index 1612a2b..bce0542 100644 --- a/doc/howto/performance_metrics.md +++ b/doc/howto/performance_metrics.md @@ -10,7 +10,7 @@ Golang compiler and NPM installed. InfluxDB and Grafana consume about You need to have a working GDK installation before you install InfluxDB and Grafana. -First make sure you do not have `./run` active anywhere. Then run: +First make sure you do not have `gdk run` active anywhere. Then run: rm Procfile make performance-metrics-setup diff --git a/doc/howto/pry.md b/doc/howto/pry.md index 5d7500f..38b1fb4 100644 --- a/doc/howto/pry.md +++ b/doc/howto/pry.md @@ -12,6 +12,6 @@ development server (localhost:3000) you need to comment out the `rails-web:` line in the Procfile in your GDK root directory because Unicorn is not compatible with Pry. -Then launch GDK as usual (e.g. with `./run`) and in a separate -terminal run: `./run thin`. Your Pry prompts will appear in the window +Then launch GDK as usual (e.g. with `gdk run`) and in a separate +terminal run: `gdk run thin`. Your Pry prompts will appear in the window that runs Thin. diff --git a/doc/set-up-gdk.md b/doc/set-up-gdk.md index e5bee87..0581315 100644 --- a/doc/set-up-gdk.md +++ b/doc/set-up-gdk.md @@ -8,11 +8,12 @@ contain 'problematic' characters such as ` ` and `(`. For example, cause problems. ``` -git clone https://gitlab.com/gitlab-org/gitlab-development-kit.git +gem install gitlab-development-kit +gdk init cd gitlab-development-kit ``` -The `Makefile` will clone the repositories, install the Gem bundles and set up +The `gdk install` command will clone the repositories, install the Gem bundles and set up basic configuration files. Pick one: ## Develop in a fork @@ -20,19 +21,19 @@ basic configuration files. Pick one: ``` # Set up GDK with 'origin' pointing to your gitlab-ce fork. # Replace MY-FORK with your namespace -make gitlab_repo=https://gitlab.com/MY-FORK/gitlab-ce.git +gdk install gitlab_repo=https://gitlab.com/MY-FORK/gitlab-ce.git support/set-gitlab-upstream ``` The set-gitlab-upstream script creates a remote named `upstream` for [the canonical GitLab CE repository](https://gitlab.com/gitlab-org/gitlab-ce). It also modifies -`make update` (See [Update gitlab and gitlab-shell +`gdk update` (See [Update gitlab and gitlab-shell repositories](Update gitlab and gitlab-shell repositories)) to pull down from the upstream repository instead of your fork, making it easier to keep up-to-date with the project. -If you want to push changes from upstream to your fork, run `make +If you want to push changes from upstream to your fork, run `gdk update` and then `git push origin` from the `gitlab` directory. ## Develop in the main repo @@ -41,7 +42,7 @@ Alternatively, you can clone all components from their official source. ``` # Clone your own forked repositories -make +gdk install ``` @@ -56,13 +57,14 @@ instead of 3000 so that you can run GDK EE next to CE without port conflicts. ``` -git clone https://gitlab.com/gitlab-org/gitlab-development-kit.git gdk-ee +gem install gdk +gdk init gdk-ee cd gdk-ee echo 3001 > port -make gitlab_repo=https://gitlab.com/gitlab-org/gitlab-ee.git +gdk install gitlab_repo=https://gitlab.com/gitlab-org/gitlab-ee.git ``` -Now you can start GitLab EE with `./run` in the `gdk-ee` directory and you +Now you can start GitLab EE with `gdk run` in the `gdk-ee` directory and you will not have port conflicts with a separate GDK instance for CE that might still be running. @@ -73,15 +75,15 @@ onboarding document: https://about.gitlab.com/handbook/developer-onboarding/#git Start GitLab and all required services: - ./run + gdk run To start only the databases use: - ./run db + gdk run db To start only the app (assuming the DBs are already running): - ./run app + gdk run app To access GitLab you may now go to http://localhost:3000 in your browser. The development login credentials are `root` and `5iveL!fe`. -- GitLab From 6f4b620180425f59578713c735094056e88c8115 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer <jacob@gitlab.com> Date: Mon, 8 Aug 2016 16:58:33 +0200 Subject: [PATCH 09/11] Add comments about bin/lib separation --- bin/gdk | 6 ++++++ lib/gdk.rb | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/bin/gdk b/bin/gdk index 651425c..e2903de 100755 --- a/bin/gdk +++ b/bin/gdk @@ -1,6 +1,12 @@ #!/usr/bin/env ruby require 'fileutils' +# Gitlab Development Kit CLI launcher +# +# Note to contributors: this script must not change (much) because it is +# installed outside the gitlab-development-kit repository with 'gem +# install'. + def main case ARGV.first when 'init' diff --git a/lib/gdk.rb b/lib/gdk.rb index f40ef61..e17811d 100644 --- a/lib/gdk.rb +++ b/lib/gdk.rb @@ -1,6 +1,10 @@ +# GitLab Development Kit CLI parser / executor + module GDK PROGNAME = 'gdk' + # This function is called from bin/gdk. It must return true/false or + # an exit code. def self.main case ARGV.shift when 'run' -- GitLab From ba7246d102840148bbe2f70700727dfa8f58e69c Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer <jacob@gitlab.com> Date: Mon, 8 Aug 2016 17:00:50 +0200 Subject: [PATCH 10/11] Prepare for merge --- bin/gdk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/gdk b/bin/gdk index e2903de..c52bcdc 100755 --- a/bin/gdk +++ b/bin/gdk @@ -15,7 +15,7 @@ def main return false end - cmd = %W(git clone -b gdk-cli https://gitlab.com/gitlab-org/gitlab-development-kit.git) + cmd = %W(git clone https://gitlab.com/gitlab-org/gitlab-development-kit.git) cmd << ARGV[1] if ARGV.count == 2 system(*cmd) else -- GitLab From bea998ee99bcba7dfb60b554f83362f075d4238a Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer <jacob@gitlab.com> Date: Mon, 8 Aug 2016 17:03:38 +0200 Subject: [PATCH 11/11] Explain what is right, not just what is wrong --- bin/gdk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/gdk b/bin/gdk index c52bcdc..d556d46 100755 --- a/bin/gdk +++ b/bin/gdk @@ -5,7 +5,7 @@ require 'fileutils' # # Note to contributors: this script must not change (much) because it is # installed outside the gitlab-development-kit repository with 'gem -# install'. +# install'. Edit lib/gdk.rb to define new commands. def main case ARGV.first -- GitLab