Skip to content

Commit 3879460

Browse files
committed
Ensure ruby bits are checked
so that syntax errors can't make it into master
1 parent e84d937 commit 3879460

31 files changed

+258
-117
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
.env
99
.envrc
10-
.ruby-version
1110
.terraform/
1211
/tmp/
1312
assets/*.tar.bz2

.rubocop.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
inherit_from: .rubocop_todo.yml
2+
3+
AllCops:
4+
TargetRubyVersion: 2.5
5+
6+
Style/Documentation:
7+
Enabled: false
8+
9+
Style/AccessModifierDeclarations:
10+
EnforcedStyle: inline

.rubocop_todo.yml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# This configuration was generated by
2+
# `rubocop --auto-gen-config`
3+
# on 2018-11-30 09:10:04 -0500 using RuboCop version 0.60.0.
4+
# The point is for the user to remove these configuration records
5+
# one by one as the offenses are removed from the code base.
6+
# Note that changes in the inspected code, or installation of new
7+
# versions of RuboCop, may require this file to be generated again.
8+
9+
# Offense count: 22
10+
Metrics/AbcSize:
11+
Max: 80
12+
13+
# Offense count: 2
14+
# Configuration parameters: CountComments, ExcludedMethods.
15+
# ExcludedMethods: refine
16+
Metrics/BlockLength:
17+
Max: 30
18+
19+
# Offense count: 1
20+
# Configuration parameters: CountComments.
21+
Metrics/ClassLength:
22+
Max: 138
23+
24+
# Offense count: 1
25+
Metrics/CyclomaticComplexity:
26+
Max: 7
27+
28+
# Offense count: 27
29+
# Configuration parameters: CountComments, ExcludedMethods.
30+
Metrics/MethodLength:
31+
Max: 81
32+
33+
# Offense count: 4
34+
# Configuration parameters: Blacklist.
35+
# Blacklist: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$))
36+
Naming/HeredocDelimiterNaming:
37+
Exclude:
38+
- 'bin/gcloud-nats-by-zone'
39+
- 'bin/generate-latest-gce-images'
40+
- 'bin/write-config-files'
41+
42+
# Offense count: 4
43+
Style/DoubleNegation:
44+
Exclude:
45+
- 'bin/gce-export-net'
46+
- 'bin/gce-export-workers'
47+
- 'bin/gce-import-net'
48+
- 'bin/gce-import-workers'
49+
50+
# Offense count: 1
51+
# Cop supports --auto-correct.
52+
# Configuration parameters: EnforcedStyle, AllowInnerSlashes.
53+
# SupportedStyles: slashes, percent_r, mixed
54+
Style/RegexpLiteral:
55+
Exclude:
56+
- 'bin/travis-worker-verify-config'
57+
58+
# Offense count: 7
59+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
60+
# URISchemes: http, https
61+
Metrics/LineLength:
62+
Max: 145

.ruby-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.5.3

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
language: bash
2-
rvm: 2.4.2
32
dist: xenial
43
group: edge
54
sudo: required
@@ -12,6 +11,7 @@ env:
1211
- PATH="${HOME}/bin:${PATH}"
1312
- TMPDIR="${TMPDIR:-/tmp}"
1413
before_install:
14+
- rvm use --install --fuzzy "$(cat .ruby-version)"
1515
- eval "$(gimme 1.11.1)"
1616
- make deps
1717
script:

Gemfile

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# frozen_string_literal: true
2+
3+
source 'https://rubygems.org'
4+
5+
gem 'rubocop'

Gemfile.lock

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
ast (2.4.0)
5+
jaro_winkler (1.5.1)
6+
parallel (1.12.1)
7+
parser (2.5.3.0)
8+
ast (~> 2.4.0)
9+
powerpack (0.1.2)
10+
rainbow (3.0.0)
11+
rubocop (0.60.0)
12+
jaro_winkler (~> 1.5.1)
13+
parallel (~> 1.10)
14+
parser (>= 2.5, != 2.5.1.1)
15+
powerpack (~> 0.1)
16+
rainbow (>= 2.2.2, < 4.0)
17+
ruby-progressbar (~> 1.7)
18+
unicode-display_width (~> 1.4.0)
19+
ruby-progressbar (1.10.0)
20+
unicode-display_width (1.4.0)
21+
22+
PLATFORMS
23+
ruby
24+
25+
DEPENDENCIES
26+
rubocop
27+
28+
BUNDLED WITH
29+
1.17.1

Makefile

+6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ PROVIDER_TRAVIS_URL := github.com/travis-ci/terraform-provider-travis
66

77
DEPS := \
88
.ensure-provider-travis \
9+
.ensure-rubocop \
910
.ensure-shellcheck \
1011
.ensure-shfmt \
1112
.ensure-terraforms \
@@ -43,6 +44,11 @@ deps: $(DEPS)
4344
./bin/ensure-terraform $${tf_version}; \
4445
done
4546

47+
.PHONY: .ensure-rubocop
48+
.ensure-rubocop:
49+
bundle version &>/dev/null || gem install bundler
50+
bundle exec rubocop --version &>/dev/null || bundle install
51+
4652
.PHONY: .ensure-shellcheck
4753
.ensure-shellcheck:
4854
if [[ ! -x "$(HOME)/bin/shellcheck" ]]; then \

bin/build-cache-configure

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
23

34
require 'json'
45
require 'optparse'
@@ -10,7 +11,7 @@ def main
1011
apps: [],
1112
fqdn: '',
1213
heroku_api_hostname: 'api.heroku.com',
13-
heroku_api_key: ENV.fetch('HEROKU_API_KEY', '').strip,
14+
heroku_api_key: ENV.fetch('HEROKU_API_KEY', '').strip
1415
}
1516

1617
OptionParser.new do |opts|
@@ -35,8 +36,8 @@ def main
3536
) { |v| options[:heroku_api_key] = v.strip }
3637
end.parse!
3738

38-
fail 'Missing HEROKU_API_KEY' if options[:heroku_api_key].empty?
39-
fail 'No apps specified' if options[:apps].empty?
39+
raise 'Missing HEROKU_API_KEY' if options[:heroku_api_key].empty?
40+
raise 'No apps specified' if options[:apps].empty?
4041

4142
heroku = HerokuClient.new(
4243
api_key: options.fetch(:heroku_api_key),

bin/env-url-to-parts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
24
require 'uri'
35

46
def main(argv = ARGV)
@@ -8,7 +10,7 @@ def main(argv = ARGV)
810

911
parsed = URI(ENV.fetch(url_varname))
1012

11-
%w(scheme user password host port path query).each do |part|
13+
%w[scheme user password host port path query].each do |part|
1214
basename = "#{url_varname}_#{part.upcase}_#{suffix}"
1315
File.open(File.join(out_dir, basename), 'w') do |f|
1416
f.puts parsed.send(part).to_s + "\n"

bin/format-images-json

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
23

34
require 'json'
45

bin/format-public-ip-addresses

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
23

34
require 'json'
45
require 'net/http'

bin/gce-export-net

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
24
require 'optparse'
35

46
def main
57
options = {
68
module_name: ENV.fetch('MODULE_NAME', 'gce_project_1'),
79
noop: false,
8-
terraform: ENV.fetch('TERRAFORM', 'terraform'),
10+
terraform: ENV.fetch('TERRAFORM', 'terraform')
911
}
1012

1113
OptionParser.new do |opts|
@@ -50,7 +52,7 @@ def main
5052
].map { |r| "module.#{module_name}.#{r}" }
5153
)
5254

53-
$stderr.puts("---> #{command.join(' ')}")
55+
warn("---> #{command.join(' ')}")
5456
system(*command) unless noop
5557

5658
0

bin/gce-export-workers

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
24
require 'optparse'
35

46
def main
57
options = {
68
counts: {
79
com: Integer(ENV.fetch('COUNT_COM', '0')),
8-
org: Integer(ENV.fetch('COUNT_ORG', '0')),
10+
org: Integer(ENV.fetch('COUNT_ORG', '0'))
911
},
1012
module_name: ENV.fetch('MODULE_NAME', 'gce_project_1'),
1113
noop: false,
1214
terraform: ENV.fetch('TERRAFORM', 'terraform'),
13-
zones: ENV.fetch('ZONES', 'a,b,c,f').split(',').map(&:strip),
15+
zones: ENV.fetch('ZONES', 'a,b,c,f').split(',').map(&:strip)
1416
}
1517

1618
OptionParser.new do |opts|
@@ -59,7 +61,7 @@ def main
5961
end
6062
end
6163

62-
$stderr.puts("---> #{command.join(' ')}")
64+
warn("---> #{command.join(' ')}")
6365
system(*command) unless noop
6466

6567
0

bin/gce-import-net

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
24
require 'optparse'
35

46
def main
@@ -8,7 +10,7 @@ def main
810
noop: false,
911
project: ENV.fetch('PROJECT', 'notset'),
1012
region: ENV.fetch('REGION', 'us-central1'),
11-
terraform: ENV.fetch('TERRAFORM', 'terraform'),
13+
terraform: ENV.fetch('TERRAFORM', 'terraform')
1214
}
1315

1416
OptionParser.new do |opts|
@@ -57,14 +59,15 @@ def main
5759
'google_compute_subnetwork.jobs_com' => "#{region}/jobs-com",
5860
'google_compute_subnetwork.jobs_org' => "#{region}/jobs-org",
5961
'google_compute_subnetwork.public' => "#{region}/public",
60-
'google_compute_subnetwork.workers' => "#{region}/workers",
62+
'google_compute_subnetwork.workers' => "#{region}/workers"
6163
}.each do |resource, importable|
6264
command = %W[
6365
#{terraform} import module.gce_net.#{resource} #{importable}
6466
]
65-
$stderr.puts("---> #{command.join(' ')}")
67+
warn("---> #{command.join(' ')}")
6668
next if noop
67-
system(*command) || $stderr.puts('---? already imported?')
69+
70+
system(*command) || warn('---? already imported?')
6871
end
6972

7073
0

bin/gce-import-workers

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
24
require 'optparse'
35

46
def main
57
options = {
68
counts: {
79
com: Integer(ENV.fetch('COUNT_COM', '0')),
8-
org: Integer(ENV.fetch('COUNT_ORG', '0')),
10+
org: Integer(ENV.fetch('COUNT_ORG', '0'))
911
},
1012
env: ENV.fetch('ENV', 'staging'),
1113
index: ENV.fetch('INDEX', '1'),
@@ -14,7 +16,7 @@ def main
1416
project: ENV.fetch('PROJECT', 'notset'),
1517
region: ENV.fetch('REGION', 'us-central1'),
1618
terraform: ENV.fetch('TERRAFORM', 'terraform'),
17-
zones: ENV.fetch('ZONES', 'a,b,c,f').split(',').map(&:strip),
19+
zones: ENV.fetch('ZONES', 'a,b,c,f').split(',').map(&:strip)
1820
}
1921

2022
OptionParser.new do |opts|
@@ -70,7 +72,7 @@ def main
7072
zones = options.fetch(:zones)
7173

7274
to_import = {
73-
'heroku_app.gcloud_cleanup' => "gcloud-cleanup-#{env}-#{index}",
75+
'heroku_app.gcloud_cleanup' => "gcloud-cleanup-#{env}-#{index}"
7476
}
7577

7678
%i[com org].each do |site|
@@ -90,9 +92,10 @@ def main
9092
command = %W[
9193
#{terraform} import module.#{module_name}.#{resource} #{importable}
9294
]
93-
$stderr.puts("---> #{command.join(' ')}")
95+
warn("---> #{command.join(' ')}")
9496
next if noop
95-
system(*command) || $stderr.puts('---? already imported?')
97+
98+
system(*command) || warn('---? already imported?')
9699
end
97100

98101
0

0 commit comments

Comments
 (0)