ci-scripts 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bed99c8505ea0b8e5fd987d8dc3908ab5077f315
4
- data.tar.gz: 9e97dc28a22958d6096c808ac0d18e8b1af248f2
3
+ metadata.gz: 18afac7ed4402c46f981d151340dde80612fa923
4
+ data.tar.gz: 9d3069c932a9e43e900e1dfb1ffc0d7263b64c4d
5
5
  SHA512:
6
- metadata.gz: 4741cad527006c2f5378f4a1e395780a34f858edd210d0dddad14542ef1c0aa4b5f10ca6031ff7a654446819f5cf506eda040add86c50c6016bb83741a7640ca
7
- data.tar.gz: 79f6708f4a1f2459ff07e0efa02b41fdf6a55262bbf6ac7e083e62d092944cffc246376d1a827f1faf97cf6856f687faa0db14c1698d13d19c01a3d55bd88aba
6
+ metadata.gz: bc668a60f57dbe74c9c1eec29d54c70bbc783f1bba762a48b59d97d8cdbfa34f6e33362e82b23ef9421e466f47535d53e70debe7be46ef9b2aa29ea0a4617e87
7
+ data.tar.gz: a0819121e9f55170de454ab29158ba0a4503474b30d94cc40bd5da031cbe42e289390a3ec50b276d0a5fb501f4e481838bcb18f6a106a8396c3ad87b172770a5
data/.editorconfig CHANGED
@@ -7,7 +7,7 @@ root = true
7
7
  [*]
8
8
  end_of_line = lf
9
9
  insert_final_newline = true
10
- trim_trailing_whitespace = true
10
+ # trim_trailing_whitespace = true
11
11
  charset = utf-8
12
12
  indent_style = space
13
13
  indent_size = 2
data/ci_scripts.yml ADDED
@@ -0,0 +1,3 @@
1
+ files:
2
+ tarball:
3
+ output_directory: /tmp
@@ -0,0 +1,38 @@
1
+ # https://github.com/Invoca/ruby_dig/blob/master/lib/ruby_dig.rb
2
+
3
+ module RubyDig
4
+ def dig(key, *rest)
5
+ value = self[key]
6
+ if value.nil? || rest.empty?
7
+ value
8
+ elsif value.respond_to?(:dig)
9
+ value.dig(*rest)
10
+ else
11
+ fail TypeError, "#{value.class} does not have #dig method"
12
+ end
13
+ end
14
+ end
15
+
16
+ if RUBY_VERSION < '2.3'
17
+ class Array
18
+ include RubyDig
19
+ end
20
+
21
+ class Hash
22
+ include RubyDig
23
+ end
24
+ end
25
+
26
+ module RubyDotDig
27
+ def dot_dig(key)
28
+ dig(*key.split("."))
29
+ end
30
+ end
31
+
32
+ class Array
33
+ include RubyDotDig
34
+ end
35
+
36
+ class Hash
37
+ include RubyDotDig
38
+ end
@@ -1,5 +1,6 @@
1
1
  # #!/usr/bin/ruby
2
2
  require 'open3'
3
+ require 'ci_scripts/dig'
3
4
 
4
5
  # Logging
5
6
  def log_info(s)
@@ -25,7 +26,10 @@ def command(*options)
25
26
  t = Time.now
26
27
  system(*options)
27
28
  log_success("#{(Time.now - t).round(2)}s\n ")
28
- exit $CHILD_STATUS.exitstatus if $CHILD_STATUS && $CHILD_STATUS.exitstatus != 0
29
+ if $CHILD_STATUS && $CHILD_STATUS.exitstatus != 0
30
+ log_error("Exit status #{$CHILD_STATUS.exitstatus}")
31
+ exit $CHILD_STATUS.exitstatus
32
+ end
29
33
  end
30
34
 
31
35
  def timed_run(name)
@@ -36,7 +40,14 @@ def timed_run(name)
36
40
  end
37
41
 
38
42
  def capture_command(*options)
39
- Open3.capture2(*options)
43
+ output, status = Open3.capture2(*options)
44
+ require "byebug"
45
+ unless status.success?
46
+ log_error("Attempted to capture output of `#{options.join ' '}` but received exit code #{status.to_i}")
47
+ log_error(output)
48
+ exit status.to_i
49
+ end
50
+ output
40
51
  end
41
52
 
42
53
  # system helpers
@@ -1,3 +1,3 @@
1
1
  module CIScripts
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -25,7 +25,7 @@ module Files
25
25
  timed_run "Generating SHA256" do
26
26
  sha256 = Digest::SHA256.new
27
27
 
28
- return puts "#{sha_folder} does not exist" unless File.exists?(sha_folder)
28
+ return puts "#{sha_folder} does not exist" unless File.exist?(sha_folder)
29
29
 
30
30
  Dir.foreach(sha_folder) do |file|
31
31
  next if File.directory?(file)
@@ -61,13 +61,13 @@ module Files
61
61
  private
62
62
 
63
63
  def git_url
64
- git_remotes = capture_command("git", "remote", "-v").first
65
- url = /(?:git@|https:\/\/)([^\s]+)/.match(git_remotes)[1]
66
- url.gsub(":", "/")
64
+ git_remotes = capture_command("git", "remote", "-v")
65
+ url = %r{/(?:git@|https:\/\/)([^\s]+)/}.match(git_remotes)[1]
66
+ url.tr(":", "/")
67
67
  end
68
68
 
69
69
  def firebase_escape(s)
70
- s.gsub(".", "_")
70
+ s.tr(".", "_")
71
71
  end
72
72
  end
73
73
  end
@@ -0,0 +1,17 @@
1
+ require "byebug"
2
+ module Files
3
+ class Tarball
4
+ def run
5
+ # env_require("files.tarball.output_directory")
6
+ tar_output_dir = env_require("FILES_TARBALL_OUTPUT_DIRECTORY")
7
+ # require "YAML"
8
+ # thing = YAML.load_file("ci_scripts.yml")
9
+ # byebug
10
+
11
+ # get files to add to tarball
12
+ # Description: comma separated for
13
+ tar_files = env_require("FILES_TARBALL_FILES").split(",")
14
+ tar_included = env_fetch("FILES")
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,35 @@
1
+ require 'tempfile'
2
+
3
+ module Go
4
+ class Test
5
+ class << self
6
+ def description
7
+ <<-MARKDOWN
8
+ Run all test from all packages. Creates coverage.txt which concats all coverprofiles from go test.
9
+ MARKDOWN
10
+ end
11
+ end
12
+
13
+ def run
14
+ go_test_package = env_fetch("GO_TEST_PACKAGE", ".")
15
+ go_coverage_output = env_fetch("GO_COVERAGE_OUTPUT", "./coverage.txt")
16
+
17
+ output = capture_command("sh", "-c", "go list #{go_test_package}/... | grep -v vendor")
18
+ packages = output.split("\n")
19
+
20
+ cover_output = ""
21
+
22
+ packages.each do |package|
23
+ output_file = Tempfile.new('go test')
24
+
25
+ command("go", "test", "-v", "-race", "-coverprofile=#{output_file.path}", "-covermode=atomic", package)
26
+
27
+ cover_output += output_file.read
28
+ output_file.close
29
+ output_file.unlink
30
+ end
31
+
32
+ File.write(go_coverage_output, cover_output)
33
+ end
34
+ end
35
+ end
@@ -4,9 +4,9 @@ module Ruby
4
4
  # Bundler release scripts
5
5
  # https://github.com/bundler/bundler/blob/master/lib/bundler/gem_helper.rb
6
6
  # also gemspec loading https://github.com/bundler/bundler/blob/ff4a522e8e75eb4ce5675a99698fb3df23b680be/lib/bundler.rb#L406
7
- out, stat = capture_command("bundle", "exec", "rake", "-T")
7
+ out = capture_command("bundle", "exec", "rake", "-T")
8
8
 
9
- if stat && out.include?("rake release[remote]")
9
+ if out.include?("rake release[remote]")
10
10
  command("bundle", "exec", "rake", "release")
11
11
  else
12
12
  log_error("bundler/gem_tasks is required to use this script")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ci-scripts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Caldwell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-06 00:00:00.000000000 Z
11
+ date: 2018-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: firebase
@@ -116,7 +116,9 @@ files:
116
116
  - bin/document
117
117
  - bin/setup
118
118
  - ci-scripts.gemspec
119
+ - ci_scripts.yml
119
120
  - lib/ci_scripts.rb
121
+ - lib/ci_scripts/dig.rb
120
122
  - lib/ci_scripts/helpers.rb
121
123
  - lib/ci_scripts/version.rb
122
124
  - lib/scripts/demo/test.rb
@@ -131,7 +133,7 @@ files:
131
133
  - lib/scripts/go/build.rb
132
134
  - lib/scripts/go/glide
133
135
  - lib/scripts/go/install
134
- - lib/scripts/go/test
136
+ - lib/scripts/go/test.rb
135
137
  - lib/scripts/ruby/bundler.rb
136
138
  - lib/scripts/ruby/publish_gem.rb
137
139
  - lib/scripts/ruby/rake_test.rb
data/lib/scripts/go/test DELETED
@@ -1 +0,0 @@
1
- #!/usr/bin/bash