diff --git a/.circleci/config.yml b/.circleci/config.yml index a670f1b2..37593f24 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,7 +8,7 @@ jobs: - checkout - run: name: CI on Ruby 2.3 - command: ./toys-dev ci + command: ./toys-dev do ci init , ci Test Ruby 2.4: docker: - image: circleci/ruby:2.4-stretch @@ -17,7 +17,7 @@ jobs: - checkout - run: name: CI on Ruby 2.4 - command: ./toys-dev ci + command: ./toys-dev do ci init , ci Test Ruby 2.5: docker: - image: circleci/ruby:2.5-stretch @@ -26,7 +26,7 @@ jobs: - checkout - run: name: CI on Ruby 2.5 - command: ./toys-dev ci + command: ./toys-dev do ci init , ci Test Ruby 2.6: docker: - image: circleci/ruby:2.6-stretch @@ -35,7 +35,7 @@ jobs: - checkout - run: name: CI on Ruby 2.6 - command: ./toys-dev ci + command: ./toys-dev do ci init , ci workflows: version: 2 tests: diff --git a/.toys.rb b/.toys.rb index 5315f188..717f6828 100644 --- a/.toys.rb +++ b/.toys.rb @@ -88,6 +88,32 @@ def run handle_gem("toys-core") handle_gem("toys") end + + tool "init" do + desc "Initialize the environment for CI systems" + + include :exec + include :terminal + + def run + changed = false + if exec(["git", "config", "--global", "--get", "user.email"], out: :null).error? + exec(["git", "config", "--global", "user.email", "hello@example.com"], + exit_on_nonzero_status: true) + changed = true + end + if exec(["git", "config", "--global", "--get", "user.name"], out: :null).error? + exec(["git", "config", "--global", "user.name", "Hello Ruby"], + exit_on_nonzero_status: true) + changed = true + end + if changed + puts("**** Environment is now set up for CI", :bold, :green) + else + puts("**** Environment was already set up for CI", :bold, :yellow) + end + end + end end tool "yardoc" do