ci-scripts 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9ac5e229d85cdef8e918dede6312a3ccf6b90f24
4
+ data.tar.gz: c18f8fa9149a1ed9d156f14a9790a24c12f5c0ae
5
+ SHA512:
6
+ metadata.gz: 9eed1550a221a800b91d424334ba8874acc6cbe79737972073503826610c489b3037bb16ef221bd29575b963226ed2cab53976c65ec0f49a597fcea77cbf91e4
7
+ data.tar.gz: 4276f93e74777fb4af74409208c7da357d855aade6365e8edb3b8adb3a5c162e7330218b25cf0c29be19555b51f1052b21af09b2b10768b89fbb6081a92a2dca
data/.gitignore ADDED
@@ -0,0 +1,55 @@
1
+
2
+ *.gem
3
+ *.rbc
4
+ /.config
5
+ /coverage/
6
+ /InstalledFiles
7
+ /pkg/
8
+ /spec/reports/
9
+ /spec/examples.txt
10
+ /test/tmp/
11
+ /test/version_tmp/
12
+ /tmp/
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+ ## Specific to RubyMotion:
16
+ .dat*
17
+ .repl_history
18
+ build/
19
+ *.bridgesupport
20
+ build-iPhoneOS/
21
+ build-iPhoneSimulator/
22
+ ## Specific to RubyMotion (use of CocoaPods):
23
+ #
24
+ # We recommend against adding the Pods directory to your .gitignore. However
25
+ # you should judge for yourself, the pros and cons are mentioned at:
26
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
27
+ # vendor/Pods/
28
+ ## Documentation cache and generated files:
29
+ /.yardoc/
30
+ /_yardoc/
31
+ /doc/
32
+ /rdoc/
33
+ ## Environment normalization:
34
+ /.bundle/
35
+ /vendor/bundle
36
+ /lib/bundler/man/
37
+ # for a library or gem, you might want to ignore these files since the code is
38
+ # intended to run in multiple environments; otherwise, check them in:
39
+ # Gemfile.lock
40
+ # .ruby-version
41
+ # .ruby-gemset
42
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
43
+ .rvmrc
44
+ .rubocop-*
45
+
46
+ /.bundle/
47
+ /.yardoc
48
+ /Gemfile.lock
49
+ /_yardoc/
50
+ /coverage/
51
+ /doc/
52
+ /pkg/
53
+ /spec/reports/
54
+ /tmp/
55
+
data/.gitlab-ci.yml ADDED
@@ -0,0 +1,18 @@
1
+ image: "ruby:2.3"
2
+
3
+ # Cache gems in between builds
4
+ cache:
5
+ paths:
6
+ - vendor/ruby
7
+
8
+ variables:
9
+ CI_SCRIPTS_VERSION: git
10
+
11
+ before_script:
12
+ - ruby -v # Print out ruby version for debugging
13
+ - wget -qO- https://raw.githubusercontent.com/benjamincaldwell/ci-scripts/master/install | bash
14
+
15
+ rubocop:
16
+ script:
17
+ - ci-scripts ruby/rubocop
18
+
data/.rubocop.yml ADDED
@@ -0,0 +1,12 @@
1
+ inherit_from:
2
+ - http://shopify.github.io/ruby-style-guide/rubocop.yml
3
+
4
+ AllCops:
5
+ Exclude:
6
+ - 'vendor/**/*'
7
+ # TargetRubyVersion: 1.9
8
+
9
+ # some changes to support older ruby versions
10
+ Layout/IndentHeredoc:
11
+ # only works in ruby 2.3+
12
+ EnforcedStyle: unindent
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at caldwellbenjamin8@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in ci-scripts.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Benjamin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Benjamin Caldwell
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # CI Scripts
2
+
3
+ A collection of modular scripts that are commonly run in CI. The goal of this project is to reduce the number of CI configuration files that have duplicate code. Environment variables are used to configure the scripts. To include a script add the following to the CI config:
4
+
5
+
6
+ ```
7
+ wget -qO- https://raw.githubusercontent.com/benjamincaldwell/ci-scripts/master/install | bash
8
+ ci-scripts SCRIPT_NAME
9
+ ```
10
+
11
+ <!--Since this allows remove code execuation in the CI environment, it is suggested that this repo is forked so -->
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
data/bin/ci-scripts ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ dir = File.join(File.dirname(__FILE__), '..')
3
+
4
+ unless File.exist? File.join(dir, "lib/base.rb")
5
+ dir = if ENV["CI_SCRIPTS_INSTALL_LOCATION"]
6
+ ENV["CI_SCRIPTS_INSTALL_LOCATION"]
7
+ else
8
+ "/opt/ci-scripts"
9
+ end
10
+ end
11
+
12
+ $LOAD_PATH.unshift(dir)
13
+
14
+ require "lib/base"
15
+ # required for using english versions of ruby globals
16
+ # https://github.com/CocoaPods/cocoapods-downloader/issues/28
17
+ require "English"
18
+
19
+ if ARGV.count <= 0
20
+ log_error "No script specified"
21
+ exit 1
22
+ end
23
+
24
+ ARGV.each do |script_name|
25
+ script_name = script_name.strip
26
+ run_script(script_name)
27
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ci/scripts"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "ci_scripts/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ci-scripts"
8
+ spec.version = CIScripts::VERSION
9
+ spec.authors = ["Benjamin Caldwell"]
10
+ spec.email = ["caldwellbenjamin8@gmail.com"]
11
+
12
+ spec.summary = %q(A collection fo scripts for commomly run scripts in CI.)
13
+ # spec.description = %q{TODO: Write a longer description or delete this line.}
14
+ spec.homepage = "http://github.com/benjamincaldwell/ci-scripts"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "bin"
21
+ spec.executables = ["ci-scripts"]
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.15"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "minitest", "~> 5.0"
27
+ end
data/docker/build.rb ADDED
@@ -0,0 +1,20 @@
1
+ module Docker
2
+ extend self
3
+ def build
4
+ required_env("DOCKER_IMAGE")
5
+
6
+ # set image tag if it hasnt been set
7
+ env_check("IMAGE_TAG", `git rev-parse HEAD`.strip)
8
+
9
+ dockerfile = env_fetch("BUILD_DOCKERFILE", "Dockerfile")
10
+ # project_folder = env_fetch("DOCKER_FOLDER", ".")
11
+
12
+ # build docker image
13
+ command("docker build --pull -t \"$DOCKER_IMAGE:$IMAGE_TAG\" -f #{dockerfile} .")
14
+
15
+ # push docker image
16
+ command('docker push "$DOCKER_IMAGE:$IMAGE_TAG"')
17
+ end
18
+ end
19
+
20
+ Docker.build if __FILE__ == $PROGRAM_NAME
@@ -0,0 +1,28 @@
1
+ module Docker
2
+ extend self
3
+ def herokuish
4
+ # set image tag if it hasnt been set
5
+ # also has to support old ruby versions
6
+ dockerfile_contents = <<-DOCKERFILE
7
+ FROM gliderlabs/herokuish
8
+
9
+ COPY . /app
10
+
11
+ RUN /bin/herokuish buildpack build
12
+
13
+ CMD ["/start", "web"]
14
+ DOCKERFILE
15
+
16
+ dockerfile_contents = unindent(dockerfile_contents)
17
+
18
+ timed_run "Creating herokuish dockerfile" do
19
+ File.write("Dockerfile.herokuish", dockerfile_contents)
20
+
21
+ ENV["BUILD_DOCKERFILE"] = "Dockerfile.herokuish"
22
+ end
23
+
24
+ run_script("docker/build")
25
+ end
26
+ end
27
+
28
+ Docker.herokuish if __FILE__ == $PROGRAM_NAME
data/docker/login.rb ADDED
@@ -0,0 +1,19 @@
1
+ module Docker
2
+ extend self
3
+ def login
4
+ # set image tag if it hasnt been set
5
+ required_env("DOCKER_USERNAME")
6
+ required_env("DOCKER_PASSWORD")
7
+
8
+ env_check("DOCKER_EMAIL", "ci@ci-runner.com")
9
+
10
+ docker_registry = env_fetch("DOCKER_REGISTRY", nil)
11
+
12
+ # login to docker hub
13
+ login_command = 'docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD" -e "$DOCKER_EMAIL"'
14
+ login_command += " #{docker_registry}" if docker_registry
15
+ command(login_command)
16
+ end
17
+ end
18
+
19
+ Docker.login if __FILE__ == $PROGRAM_NAME
@@ -0,0 +1,19 @@
1
+ module Docker
2
+ extend self
3
+ def push_branch
4
+ required_env("DOCKER_IMAGE")
5
+
6
+ # set image tag if it hasnt been set
7
+ env_check("IMAGE_TAG", `git rev-parse HEAD`.strip)
8
+
9
+ branch = `git rev-parse --abbrev-ref HEAD`.strip
10
+
11
+ # tag image
12
+ command("docker tag \"$DOCKER_IMAGE:$IMAGE_TAG\" \"$DOCKER_IMAGE:#{branch}\"")
13
+
14
+ # push docker image
15
+ command("docker push \"$DOCKER_IMAGE:#{branch}\"")
16
+ end
17
+ end
18
+
19
+ Docker.push_branch if __FILE__ == $PROGRAM_NAME
@@ -0,0 +1,22 @@
1
+ module Docker
2
+ extend self
3
+ def push_latest
4
+ latest_branch = env_fetch("DOCKER_LATEST_BRANCH", "master")
5
+
6
+ branch = `git rev-parse --abbrev-ref HEAD`.strip
7
+ return if branch != latest_branch
8
+
9
+ required_env("DOCKER_IMAGE")
10
+
11
+ # set image tag if it hasnt been set
12
+ env_check("IMAGE_TAG", `git rev-parse HEAD`.strip)
13
+
14
+ # tag latest image
15
+ command('docker tag "$DOCKER_IMAGE:$IMAGE_TAG" "$DOCKER_IMAGE:latest"')
16
+
17
+ # push docker image
18
+ command('docker push "$DOCKER_IMAGE:latest"')
19
+ end
20
+ end
21
+
22
+ Docker.push_latest if __FILE__ == $PROGRAM_NAME
data/exe/ci-scripts ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ dir = File.join(File.dirname(__FILE__), '..')
4
+
5
+ unless File.exist? File.join(dir, "lib/base.rb")
6
+ dir = if ENV["CI_SCRIPTS_INSTALL_LOCATION"]
7
+ ENV["CI_SCRIPTS_INSTALL_LOCATION"]
8
+ else
9
+ "/opt/ci-scripts"
10
+ end
11
+ end
12
+
13
+ $LOAD_PATH.unshift(dir)
14
+
15
+ require "lib/base"
16
+ # required for using english versions of ruby globals
17
+ # https://github.com/CocoaPods/cocoapods-downloader/issues/28
18
+ require "English"
19
+
20
+ if ARGV.count <= 0
21
+ log_error "No script specified"
22
+ exit 1
23
+ end
24
+
25
+ ARGV.each do |script_name|
26
+ script_name = script_name.strip
27
+ run_script(script_name)
28
+ end
data/git/ssh_keys.rb ADDED
@@ -0,0 +1,10 @@
1
+ module Git
2
+ extend self
3
+ def ssh_keys
4
+ timed_run "something" do
5
+ puts "hello"
6
+ end
7
+ end
8
+ end
9
+
10
+ Git.ssh_keys if __FILE__ == $PROGRAM_NAME
data/go/glide ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/bash
data/go/install ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/bash
data/go/test ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/bash
data/install ADDED
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/bash
2
+ set -e
3
+
4
+ # set TMPDIR to /tmp if it doesnt exist
5
+ if [ -z "$TMPDIR" ]; then
6
+ export TMPDIR=/tmp
7
+ fi
8
+
9
+ install_location=${CI_SCRIPTS_INSTALL_LOCATION:="/opt/ci-scripts"}
10
+
11
+ install_version=${CI_SCRIPTS_VERSION:="latest"}
12
+
13
+ echo "Installing ci-scripts-${install_version} to ${install_location}"
14
+
15
+ _ci_scripts_install_version() {
16
+ local tar_file="${TMPDIR}/ci-scripts.tar.gz"
17
+ local extracted_folder="${TMPDIR}/ci-scripts-$1"
18
+ wget "https://github.com/benjamincaldwell/ci-scripts/archive/v$1.tar.gz" -O "${tar_file}"
19
+ tar -zxvf "${tar_file}" -C "${TMPDIR}"
20
+ _ci_scripts_sudo mv "${extracted_folder}" "${install_location}"
21
+ rm -rf "${extracted_folder}" "${tar_file}"
22
+ }
23
+
24
+ _ci_scripts_sudo() {
25
+ SUDO=''
26
+ if [ "$(whoami)" != "root" ]; then
27
+ SUDO='sudo'
28
+ fi
29
+ $SUDO "$@"
30
+ }
31
+
32
+ case "$install_version" in
33
+ git)
34
+ _ci_scripts_sudo git clone git://github.com/benjamincaldwell/ci-scripts.git "${install_location}"
35
+ ;;
36
+ latest)
37
+ echo "guh"
38
+ ;;
39
+ *)
40
+ _ci_scripts_install_version "$install_version"
41
+ ;;
42
+ esac
43
+
44
+ _ci_scripts_sudo ln -snf /opt/ci-scripts/bin/ci-scripts /usr/bin/ci-scripts
data/lib/base.rb ADDED
@@ -0,0 +1,92 @@
1
+ # #!/usr/bin/ruby
2
+
3
+ BASE_SCRIPT_PATH = "https://raw.githubusercontent.com/benjamincaldwell/ci-scripts/master/".freeze
4
+
5
+ # Logging
6
+ def log_info(s)
7
+ puts("\x1b[34m#{s}\x1b[0m")
8
+ end
9
+
10
+ def log_success(s)
11
+ puts("\x1b[32m#{s}\x1b[0m")
12
+ end
13
+
14
+ def log_error(s)
15
+ puts("\x1b[31m#{s}\x1b[0m")
16
+ end
17
+
18
+ # Timed runs
19
+ def command(*options)
20
+ log_info(options.join(" "))
21
+ t = Time.now
22
+ system(*options)
23
+ log_success("#{(Time.now - t).round(2)}s\n ")
24
+ exit $CHILD_STATUS if $CHILD_STATUS != 0
25
+ end
26
+
27
+ def timed_run(name)
28
+ log_info(name)
29
+ t = Time.now
30
+ yield
31
+ log_success("#{(Time.now - t).round(2)}s\n ")
32
+ end
33
+
34
+ # system helpers
35
+ def test_command?(*options)
36
+ system(*options, out: File::NULL)
37
+ $CHILD_STATUS == 0
38
+ end
39
+
40
+ def installed?(binary)
41
+ test_command?("command", "-v", binary)
42
+ end
43
+
44
+ # env helpers
45
+ def env_check(key, value)
46
+ unless ENV[key]
47
+ puts "Setting #{key} to #{value}"
48
+ ENV[key] = value
49
+ end
50
+ end
51
+
52
+ def required_env(key)
53
+ unless ENV[key]
54
+ log_error "Required environment variable #{key} not set"
55
+ exit 1
56
+ end
57
+ end
58
+
59
+ def env_fetch(key, default = "")
60
+ if ENV[key]
61
+ ENV[key]
62
+ else
63
+ default
64
+ end
65
+ end
66
+
67
+ # helpers
68
+ def classify(s)
69
+ s = s.to_s.split('_').collect(&:capitalize).join
70
+ s[0] = s[0].capitalize
71
+ s
72
+ end
73
+
74
+ def unindent(s)
75
+ indent = s.split("\n").select { |line| !line.strip.empty? }.map { |line| line.index(/[^\s]/) }.compact.min || 0
76
+ s.gsub(/^[[:blank:]]{#{indent}}/, '')
77
+ end
78
+
79
+ def run_script(script_name)
80
+ require script_name
81
+
82
+ script_parts = script_name.split("/")
83
+ function_name = script_parts.pop
84
+ module_name = ""
85
+
86
+ script_parts.each do |part|
87
+ module_name += "::" unless module_name.empty?
88
+ module_name += classify(part)
89
+ end
90
+
91
+ Object.const_get(module_name).send(function_name)
92
+ end
@@ -0,0 +1,3 @@
1
+ module CIScripts
2
+ VERSION = "0.0.1"
3
+ end
data/lib/ci_scripts.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "ci_scripts/version"
2
+
3
+ module CIScripts
4
+ # Your code goes here...
5
+ end
data/ruby/bundler.rb ADDED
@@ -0,0 +1,14 @@
1
+ module Ruby
2
+ extend self
3
+ def bundler
4
+ unless installed?("bundler")
5
+ command("gem", "install", "bundler", "--no-ri", "--no-rdoc")
6
+ end
7
+
8
+ unless test_command?("bundler", "check")
9
+ command("bundler", "install")
10
+ end
11
+ end
12
+ end
13
+
14
+ Ruby.bundler if __FILE__ == $PROGRAM_NAME
data/ruby/rubocop.rb ADDED
@@ -0,0 +1,14 @@
1
+ module Ruby
2
+ extend self
3
+ def rubocop
4
+ unless installed?("rubocop")
5
+ command("gem", "install", "rubocop")
6
+ end
7
+ # ugh check bundle rubocop as well
8
+ # puts test_command?("bundle exec rubocop")
9
+
10
+ command("rubocop")
11
+ end
12
+ end
13
+
14
+ Ruby.rubocop if __FILE__ == $PROGRAM_NAME
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ci-scripts
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Benjamin Caldwell
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-06-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.15'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.15'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ description:
56
+ email:
57
+ - caldwellbenjamin8@gmail.com
58
+ executables:
59
+ - ci-scripts
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ".gitlab-ci.yml"
65
+ - ".rubocop.yml"
66
+ - CODE_OF_CONDUCT.md
67
+ - Gemfile
68
+ - LICENSE
69
+ - LICENSE.txt
70
+ - README.md
71
+ - Rakefile
72
+ - bin/ci-scripts
73
+ - bin/console
74
+ - bin/setup
75
+ - ci-scripts.gemspec
76
+ - docker/build.rb
77
+ - docker/herokuish.rb
78
+ - docker/login.rb
79
+ - docker/push_branch.rb
80
+ - docker/push_latest.rb
81
+ - exe/ci-scripts
82
+ - git/ssh_keys.rb
83
+ - go/glide
84
+ - go/install
85
+ - go/test
86
+ - install
87
+ - lib/base.rb
88
+ - lib/ci_scripts.rb
89
+ - lib/ci_scripts/version.rb
90
+ - ruby/bundler.rb
91
+ - ruby/rubocop.rb
92
+ homepage: http://github.com/benjamincaldwell/ci-scripts
93
+ licenses:
94
+ - MIT
95
+ metadata: {}
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project:
112
+ rubygems_version: 2.5.1
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: A collection fo scripts for commomly run scripts in CI.
116
+ test_files: []