firespring_dev_commands 2.5.0.pre.alpha.3 → 3.0.0.pre.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/firespring_dev_commands/audit/report.rb +9 -2
- data/lib/firespring_dev_commands/aws/account.rb +3 -7
- data/lib/firespring_dev_commands/aws/login.rb +0 -20
- data/lib/firespring_dev_commands/bloom_growth/rock.rb +34 -0
- data/lib/firespring_dev_commands/bloom_growth/seat.rb +16 -0
- data/lib/firespring_dev_commands/bloom_growth/user.rb +43 -0
- data/lib/firespring_dev_commands/bloom_growth.rb +132 -0
- data/lib/firespring_dev_commands/common.rb +11 -22
- data/lib/firespring_dev_commands/coverage/base.rb +21 -0
- data/lib/firespring_dev_commands/coverage/cobertura.rb +86 -0
- data/lib/firespring_dev_commands/coverage/none.rb +25 -0
- data/lib/firespring_dev_commands/docker.rb +23 -25
- data/lib/firespring_dev_commands/node.rb +13 -12
- data/lib/firespring_dev_commands/php.rb +13 -9
- data/lib/firespring_dev_commands/platform.rb +1 -1
- data/lib/firespring_dev_commands/ruby.rb +19 -7
- data/lib/firespring_dev_commands/target_process/query.rb +30 -4
- data/lib/firespring_dev_commands/target_process.rb +3 -1
- data/lib/firespring_dev_commands/templates/aws.rb +0 -2
- data/lib/firespring_dev_commands/templates/base_interface.rb +2 -2
- data/lib/firespring_dev_commands/templates/docker/application.rb +2 -2
- data/lib/firespring_dev_commands/templates/docker/node/application.rb +47 -10
- data/lib/firespring_dev_commands/templates/docker/php/application.rb +39 -16
- data/lib/firespring_dev_commands/templates/docker/ruby/application.rb +44 -8
- data/lib/firespring_dev_commands/version.rb +1 -1
- data/lib/firespring_dev_commands.rb +1 -1
- metadata +42 -35
@@ -8,11 +8,12 @@ module Dev
|
|
8
8
|
DEFAULT_PACKAGE_FILE = 'package.json'.freeze
|
9
9
|
|
10
10
|
# Config object for setting top level git config options
|
11
|
-
Config = Struct.new(:container_path, :local_path, :package_file) do
|
11
|
+
Config = Struct.new(:container_path, :local_path, :package_file, :coverage) do
|
12
12
|
def initialize
|
13
13
|
self.container_path = DEFAULT_PATH
|
14
14
|
self.local_path = DEV_COMMANDS_ROOT_DIR
|
15
15
|
self.package_file = DEFAULT_PACKAGE_FILE
|
16
|
+
self.coverage = nil
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
@@ -30,12 +31,14 @@ module Dev
|
|
30
31
|
alias_method :configure, :config
|
31
32
|
end
|
32
33
|
|
33
|
-
attr_accessor :container_path, :local_path, :package_file
|
34
|
+
attr_accessor :container_path, :local_path, :package_file, :coverage
|
34
35
|
|
35
|
-
def initialize(container_path: nil, local_path: nil, package_file: nil)
|
36
|
+
def initialize(container_path: nil, local_path: nil, package_file: nil, coverage: nil)
|
36
37
|
@container_path = container_path || self.class.config.container_path
|
37
38
|
@local_path = local_path || self.class.config.local_path
|
38
39
|
@package_file = package_file || self.class.config.package_file
|
40
|
+
@coverage = coverage || Dev::Coverage::None.new
|
41
|
+
raise 'coverage must be an instance of the base class' unless @coverage.is_a?(Dev::Coverage::Base)
|
39
42
|
end
|
40
43
|
|
41
44
|
# The base npm command that is the starting point for all subsequent commands
|
@@ -75,7 +78,7 @@ module Dev
|
|
75
78
|
# Build the node lint command
|
76
79
|
def lint_command
|
77
80
|
lint = base_command
|
78
|
-
lint << 'run' << 'lint'
|
81
|
+
lint << 'run' << 'lint' << '--'
|
79
82
|
lint.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s))
|
80
83
|
lint
|
81
84
|
end
|
@@ -83,7 +86,7 @@ module Dev
|
|
83
86
|
# Build the node lint fix command
|
84
87
|
def lint_fix_command
|
85
88
|
lint_fix = base_command
|
86
|
-
lint_fix << 'run' << 'lint-fix'
|
89
|
+
lint_fix << 'run' << 'lint-fix' << '--'
|
87
90
|
lint_fix.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s))
|
88
91
|
lint_fix
|
89
92
|
end
|
@@ -91,17 +94,15 @@ module Dev
|
|
91
94
|
# Build the node test command
|
92
95
|
def test_command
|
93
96
|
test = base_command
|
94
|
-
test << 'run' << 'test'
|
97
|
+
test << 'run' << 'test' << '--'
|
98
|
+
test.concat(coverage.node_options) if coverage
|
95
99
|
test.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s))
|
96
100
|
test
|
97
101
|
end
|
98
102
|
|
99
|
-
#
|
100
|
-
def
|
101
|
-
|
102
|
-
test << 'run' << 'test:coverage'
|
103
|
-
test.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s))
|
104
|
-
test
|
103
|
+
# Run the check to ensure code coverage meets the desired threshold
|
104
|
+
def check_test_coverage(application:)
|
105
|
+
coverage.check(application:)
|
105
106
|
end
|
106
107
|
end
|
107
108
|
end
|
@@ -8,11 +8,12 @@ module Dev
|
|
8
8
|
DEFAULT_PACKAGE_FILE = 'composer.json'.freeze
|
9
9
|
|
10
10
|
# Config object for setting top level git config options
|
11
|
-
Config = Struct.new(:container_path, :local_path, :package_file) do
|
11
|
+
Config = Struct.new(:container_path, :local_path, :package_file, :coverage) do
|
12
12
|
def initialize
|
13
13
|
self.container_path = DEFAULT_PATH
|
14
14
|
self.local_path = DEV_COMMANDS_ROOT_DIR
|
15
15
|
self.package_file = DEFAULT_PACKAGE_FILE
|
16
|
+
self.coverage = nil
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
@@ -30,12 +31,14 @@ module Dev
|
|
30
31
|
alias_method :configure, :config
|
31
32
|
end
|
32
33
|
|
33
|
-
attr_accessor :container_path, :local_path, :package_file
|
34
|
+
attr_accessor :container_path, :local_path, :package_file, :coverage
|
34
35
|
|
35
|
-
def initialize(container_path: nil, local_path: nil, package_file: nil)
|
36
|
+
def initialize(container_path: nil, local_path: nil, package_file: nil, coverage: nil)
|
36
37
|
@container_path = container_path || self.class.config.container_path
|
37
38
|
@local_path = local_path || self.class.config.local_path
|
38
39
|
@package_file = package_file || self.class.config.package_file
|
40
|
+
@coverage = coverage || Dev::Coverage::None.new
|
41
|
+
raise 'coverage must be an instance of the base class' unless @coverage.is_a?(Dev::Coverage::Base)
|
39
42
|
end
|
40
43
|
|
41
44
|
# The base npm command that is the starting point for all subsequent commands
|
@@ -73,7 +76,7 @@ module Dev
|
|
73
76
|
# Build the php lint command
|
74
77
|
def lint_command
|
75
78
|
lint = base_command
|
76
|
-
lint << 'run' << 'lint'
|
79
|
+
lint << 'run' << 'lint' << '--'
|
77
80
|
lint.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s))
|
78
81
|
lint
|
79
82
|
end
|
@@ -81,7 +84,7 @@ module Dev
|
|
81
84
|
# Build the php lint fix command
|
82
85
|
def lint_fix_command
|
83
86
|
lint_fix = base_command
|
84
|
-
lint_fix << 'run' << 'lint-fix'
|
87
|
+
lint_fix << 'run' << 'lint-fix' << '--'
|
85
88
|
lint_fix.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s))
|
86
89
|
lint_fix
|
87
90
|
end
|
@@ -89,14 +92,15 @@ module Dev
|
|
89
92
|
# Build the php test command
|
90
93
|
def test_command
|
91
94
|
test = base_command
|
92
|
-
test << 'run' << 'test'
|
95
|
+
test << 'run' << 'test' << '--'
|
96
|
+
test.concat(coverage.php_options) if coverage
|
93
97
|
test.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s))
|
94
98
|
test
|
95
99
|
end
|
96
100
|
|
97
|
-
#
|
98
|
-
def
|
99
|
-
|
101
|
+
# Run the check to ensure code coverage meets the desired threshold
|
102
|
+
def check_test_coverage(application:)
|
103
|
+
coverage.check(application:)
|
100
104
|
end
|
101
105
|
end
|
102
106
|
end
|
@@ -8,7 +8,7 @@ module Dev
|
|
8
8
|
# Normalize the ruby platform to return a docker platform architecture format
|
9
9
|
def determine_compute_architecture
|
10
10
|
case RUBY_PLATFORM
|
11
|
-
when /x86_64|amd64/
|
11
|
+
when /x86_64|amd64|x64-mingw/
|
12
12
|
'linux/amd64' # 64-bit Intel/AMD architecture
|
13
13
|
when /arm|aarch64/
|
14
14
|
'linux/arm64' # ARM architecture
|
@@ -8,11 +8,12 @@ module Dev
|
|
8
8
|
DEFAULT_PACKAGE_FILE = 'Gemfile'.freeze
|
9
9
|
|
10
10
|
# Config object for setting top level git config options
|
11
|
-
Config = Struct.new(:container_path, :local_path, :package_file, :min_version, :max_version) do
|
11
|
+
Config = Struct.new(:container_path, :local_path, :package_file, :min_version, :max_version, :coverage) do
|
12
12
|
def initialize
|
13
13
|
self.container_path = DEFAULT_PATH
|
14
14
|
self.local_path = DEV_COMMANDS_ROOT_DIR
|
15
15
|
self.package_file = DEFAULT_PACKAGE_FILE
|
16
|
+
self.coverage = nil
|
16
17
|
self.min_version = nil
|
17
18
|
self.max_version = nil
|
18
19
|
end
|
@@ -37,12 +38,15 @@ module Dev
|
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
40
|
-
attr_accessor :container_path, :local_path, :package_file
|
41
|
+
attr_accessor :container_path, :local_path, :package_file, :coverage
|
41
42
|
|
42
|
-
def initialize(container_path: nil, local_path: nil, package_file: nil)
|
43
|
+
def initialize(container_path: nil, local_path: nil, package_file: nil, coverage: nil)
|
43
44
|
@container_path = container_path || self.class.config.container_path
|
44
45
|
@local_path = local_path || self.class.config.local_path
|
45
46
|
@package_file = package_file || self.class.config.package_file
|
47
|
+
@coverage = coverage || Dev::Coverage::None.new
|
48
|
+
raise 'coverage must be an instance of the base class' unless @coverage.is_a?(Dev::Coverage::Base)
|
49
|
+
|
46
50
|
check_version
|
47
51
|
end
|
48
52
|
|
@@ -90,24 +94,32 @@ module Dev
|
|
90
94
|
|
91
95
|
# Build the bundle lint command
|
92
96
|
def lint_command
|
93
|
-
lint =
|
97
|
+
lint = base_command
|
98
|
+
lint << 'exec' << 'rake' << 'lint'
|
94
99
|
lint.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s))
|
95
100
|
lint
|
96
101
|
end
|
97
102
|
|
98
103
|
# Build the bundle lint fix command
|
99
104
|
def lint_fix_command
|
100
|
-
lint_fix =
|
101
|
-
lint_fix << '
|
105
|
+
lint_fix = base_command
|
106
|
+
lint_fix << 'exec' << 'rake' << 'lint:fix'
|
102
107
|
lint_fix.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s))
|
103
108
|
lint_fix
|
104
109
|
end
|
105
110
|
|
106
111
|
# Build the bundle test command
|
107
112
|
def test_command
|
108
|
-
test =
|
113
|
+
test = base_command
|
114
|
+
test << 'exec' << 'rake' << 'test'
|
115
|
+
test.concat(coverage.ruby_options) if coverage
|
109
116
|
test.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s))
|
110
117
|
test
|
111
118
|
end
|
119
|
+
|
120
|
+
# Run the check to ensure code coverage meets the desired threshold
|
121
|
+
def check_test_coverage(application:)
|
122
|
+
coverage.check(application:)
|
123
|
+
end
|
112
124
|
end
|
113
125
|
end
|
@@ -2,12 +2,13 @@ module Dev
|
|
2
2
|
class TargetProcess
|
3
3
|
# Class for writing target process query statements
|
4
4
|
class Query
|
5
|
-
attr_accessor :where, :incl, :take
|
5
|
+
attr_accessor :where, :incl, :take, :empty
|
6
6
|
|
7
7
|
def initialize
|
8
8
|
@where = []
|
9
9
|
@incl = []
|
10
10
|
@take = 250
|
11
|
+
@empty = false
|
11
12
|
end
|
12
13
|
|
13
14
|
# Add a new query clause
|
@@ -33,6 +34,11 @@ module Dev
|
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
37
|
+
# Check if any of the "in" statements were empty. If so then we don't want to actually run the query
|
38
|
+
def empty?
|
39
|
+
@empty == true
|
40
|
+
end
|
41
|
+
|
36
42
|
# Generate the string representation for this query
|
37
43
|
def generate
|
38
44
|
{}.tap do |clause|
|
@@ -50,22 +56,38 @@ module Dev
|
|
50
56
|
# TODO: Do these need moved to their associated entities?
|
51
57
|
# Add a filter that looks for stories whose id is contained in the list of ids given
|
52
58
|
def filter_by_user_story_ids(user_story_ids)
|
59
|
+
if user_story_ids.nil? || user_story_ids.empty?
|
60
|
+
@empty = true
|
61
|
+
return
|
62
|
+
end
|
53
63
|
self << "(Id in ('#{user_story_ids.join("', '")}'))"
|
54
64
|
end
|
55
65
|
|
56
66
|
# Add a filter that looks for stories whose team id is contained in the list of ids given
|
57
67
|
def filter_by_team_ids(team_ids)
|
58
|
-
|
68
|
+
if team_ids.nil? || team_ids.empty?
|
69
|
+
@empty = true
|
70
|
+
return
|
71
|
+
end
|
72
|
+
self << "(Team.Id in ('#{team_ids.join("', '")}'))"
|
59
73
|
end
|
60
74
|
|
61
75
|
# Add a filter that looks for stories whose project id is contained in the list of ids given
|
62
76
|
def filter_by_project(projects)
|
77
|
+
if projects.nil? || projects.empty?
|
78
|
+
@empty = true
|
79
|
+
return
|
80
|
+
end
|
63
81
|
self << "(Project.Name in ('#{projects.join("', '")}'))"
|
64
82
|
end
|
65
83
|
|
66
84
|
# Add a filter that looks for stories whose state is contained in the list of states given
|
67
85
|
def filter_by_states(states)
|
68
|
-
|
86
|
+
if states.nil? || states.empty?
|
87
|
+
@empty = true
|
88
|
+
return
|
89
|
+
end
|
90
|
+
self << "(EntityState.Name in ('#{states.join("', '")}'))"
|
69
91
|
end
|
70
92
|
|
71
93
|
# Add a filter that looks for stories whose state is set to final
|
@@ -114,7 +136,11 @@ module Dev
|
|
114
136
|
|
115
137
|
# Add a filter that looks for assignable ids which are included in the given array
|
116
138
|
def filter_by_entity_ids(entity_ids)
|
117
|
-
|
139
|
+
if entity_ids.nil? || entity_ids.empty?
|
140
|
+
@empty = true
|
141
|
+
return
|
142
|
+
end
|
143
|
+
self << "(Assignable.Id in ('#{entity_ids.join("', '")}'))"
|
118
144
|
end
|
119
145
|
|
120
146
|
# Add a filter that looks for a custom deploy date between the given dates`
|
@@ -15,7 +15,7 @@ module Dev
|
|
15
15
|
# The text of the url variable key
|
16
16
|
TP_URL = 'TP_URL'.freeze
|
17
17
|
|
18
|
-
# Config object for setting top level
|
18
|
+
# Config object for setting top level target process config options
|
19
19
|
Config = Struct.new(:username, :password, :url, :http_debug) do
|
20
20
|
def initialize
|
21
21
|
Dotenv.load(CONFIG_FILE) if File.exist?(CONFIG_FILE)
|
@@ -117,6 +117,8 @@ module Dev
|
|
117
117
|
# Call the given block (if present) with each piece of data
|
118
118
|
# Return all pieces of data
|
119
119
|
def get(path, query, &)
|
120
|
+
return [] if query.empty?
|
121
|
+
|
120
122
|
query_string = query.generate
|
121
123
|
url = "/api/v1/#{path}"
|
122
124
|
url << "?#{URI.encode_www_form(query_string)}" unless query_string.empty?
|
@@ -49,7 +49,6 @@ module Dev
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
# rubocop:disable Metrics/MethodLength
|
53
52
|
# Create the rake task for the aws credentials setup and login method
|
54
53
|
def create_login_task!
|
55
54
|
# Have to set a local variable to be accessible inside of the instance_eval block
|
@@ -92,7 +91,6 @@ module Dev
|
|
92
91
|
end
|
93
92
|
end
|
94
93
|
end
|
95
|
-
# rubocop:enable Metrics/MethodLength
|
96
94
|
|
97
95
|
# Create the rake task for the eol method
|
98
96
|
def create_eol_task!
|
@@ -47,14 +47,14 @@ end
|
|
47
47
|
# Create the base init command
|
48
48
|
DEV_COMMANDS_TOP_LEVEL.instance_eval do
|
49
49
|
task :init do
|
50
|
-
|
50
|
+
# Placeholder for general initialization tasks
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
54
|
# Create the base init_docker command
|
55
55
|
DEV_COMMANDS_TOP_LEVEL.instance_eval do
|
56
56
|
task init_docker: %w(init) do
|
57
|
-
|
57
|
+
# Placeholder for general docker initialization tasks
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
@@ -72,7 +72,7 @@ module Dev
|
|
72
72
|
return if exclude.include?(:sh)
|
73
73
|
|
74
74
|
desc "Open a shell into a running #{application} container"
|
75
|
-
task sh: %W(init_docker #{application}:
|
75
|
+
task sh: %W(init_docker #{application}:up_no_deps _pre_sh_hooks) do
|
76
76
|
Dev::Docker::Compose.new(services: [application]).sh
|
77
77
|
Rake::Task[:_post_sh_hooks].execute
|
78
78
|
end
|
@@ -154,7 +154,7 @@ module Dev
|
|
154
154
|
return if exclude.include?(:reload)
|
155
155
|
|
156
156
|
desc "Reloads the #{application} container"
|
157
|
-
task reload: %w(init_docker _pre_reload_hooks down
|
157
|
+
task reload: %w(init_docker _pre_reload_hooks down up_no_deps) do
|
158
158
|
Rake::Task[:_post_reload_hooks].execute
|
159
159
|
end
|
160
160
|
end
|
@@ -7,11 +7,30 @@ module Dev
|
|
7
7
|
module Node
|
8
8
|
# Class for default rake tasks associated with a node project
|
9
9
|
class Application < Dev::Template::ApplicationInterface
|
10
|
-
attr_reader :node
|
10
|
+
attr_reader :node, :start_container_dependencies_on_test, :test_isolation
|
11
|
+
|
12
|
+
# Create the templated rake tasks for the node application
|
13
|
+
#
|
14
|
+
# @param application [String] The name of the application
|
15
|
+
# @param container_path [String] The path to the application inside of the container
|
16
|
+
# @param local_path [String] The path to the application on your local system
|
17
|
+
# @param start_container_dependencies_on_test [Boolean] Whether or not to start up container dependencies when running tests
|
18
|
+
# @param test_isolation [Boolean] Whether or not to start tests in an isolated project and clean up after tests are run
|
19
|
+
# @param coverage [Dev::Coverage::Base] The coverage class which is an instance of Base to be used to evaluate coverage
|
20
|
+
# @param exclude [Array<Symbol>] An array of default template tasks to exclude
|
21
|
+
def initialize(
|
22
|
+
application,
|
23
|
+
container_path: nil,
|
24
|
+
local_path: nil,
|
25
|
+
start_container_dependencies_on_test: false,
|
26
|
+
test_isolation: false,
|
27
|
+
coverage: nil,
|
28
|
+
exclude: []
|
29
|
+
)
|
30
|
+
@node = Dev::Node.new(container_path:, local_path:, coverage:)
|
31
|
+
@start_container_dependencies_on_test = start_container_dependencies_on_test
|
32
|
+
@test_isolation = test_isolation
|
11
33
|
|
12
|
-
# Allow for custom container path for the application
|
13
|
-
def initialize(application, container_path: nil, local_path: nil, exclude: [])
|
14
|
-
@node = Dev::Node.new(container_path:, local_path:)
|
15
34
|
super(application, exclude:)
|
16
35
|
end
|
17
36
|
|
@@ -30,9 +49,10 @@ module Dev
|
|
30
49
|
end
|
31
50
|
|
32
51
|
namespace :node do
|
33
|
-
desc "Run the node linting software against the #{application}'s codebase"
|
52
|
+
desc "Run the node linting software against the #{application}'s codebase" \
|
53
|
+
"\n\t(optional) use OPTS=... to pass additional options to the command"
|
34
54
|
task lint: %w(init_docker up_no_deps) do
|
35
|
-
LOG.debug(
|
55
|
+
LOG.debug("Check for node linting errors in the #{application} codebase")
|
36
56
|
|
37
57
|
options = []
|
38
58
|
options << '-T' if Dev::Common.new.running_codebuild?
|
@@ -42,7 +62,7 @@ module Dev
|
|
42
62
|
namespace :lint do
|
43
63
|
desc "Run the linting software against the #{application}'s codebase and apply all available fixes"
|
44
64
|
task fix: %w(init_docker up_no_deps) do
|
45
|
-
LOG.debug(
|
65
|
+
LOG.debug("Check and fix all node linting errors in the #{application} codebase")
|
46
66
|
|
47
67
|
options = []
|
48
68
|
options << '-T' if Dev::Common.new.running_codebuild?
|
@@ -59,6 +79,8 @@ module Dev
|
|
59
79
|
application = @name
|
60
80
|
node = @node
|
61
81
|
exclude = @exclude
|
82
|
+
test_isolation = @test_isolation
|
83
|
+
up_cmd = @start_container_dependencies_on_test ? :up : :up_no_deps
|
62
84
|
return if exclude.include?(:test)
|
63
85
|
|
64
86
|
DEV_COMMANDS_TOP_LEVEL.instance_eval do
|
@@ -68,14 +90,28 @@ module Dev
|
|
68
90
|
# This is just a placeholder to execute the dependencies
|
69
91
|
end
|
70
92
|
|
93
|
+
task test_init_docker: %w(init_docker) do
|
94
|
+
Dev::Docker::Compose.configure do |c|
|
95
|
+
c.project_name = SecureRandom.hex if test_isolation
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
71
99
|
namespace :node do
|
72
|
-
desc "Run all node tests against the #{application}'s codebase"
|
73
|
-
|
100
|
+
desc "Run all node tests against the #{application}'s codebase" \
|
101
|
+
"\n\t(optional) use OPTS=... to pass additional options to the command"
|
102
|
+
task test: %W(test_init_docker #{up_cmd}) do
|
74
103
|
LOG.debug("Running all node tests in the #{application} codebase")
|
75
104
|
|
76
105
|
options = []
|
77
106
|
options << '-T' if Dev::Common.new.running_codebuild?
|
78
107
|
Dev::Docker::Compose.new(services: application, options:).exec(*node.test_command)
|
108
|
+
node.check_test_coverage(application:)
|
109
|
+
|
110
|
+
# Clean up resources if we are on an isolated project name
|
111
|
+
if test_isolation
|
112
|
+
Dev::Docker::Compose.new.down
|
113
|
+
Dev::Docker.new.prune_project_volumes(project_name: Dev::Docker::Compose.config.project_name)
|
114
|
+
end
|
79
115
|
end
|
80
116
|
end
|
81
117
|
end
|
@@ -120,7 +156,8 @@ module Dev
|
|
120
156
|
namespace :node do
|
121
157
|
desc 'Run NPM Audit on the target application' \
|
122
158
|
"\n\tuse MIN_SEVERITY=(info low moderate high critical) to fetch only severity type selected and above (default=high)." \
|
123
|
-
"\n\tuse IGNORELIST=(comma delimited list of ids) removes the entry from the list."
|
159
|
+
"\n\tuse IGNORELIST=(comma delimited list of ids) removes the entry from the list." \
|
160
|
+
"\n\t(optional) use OPTS=... to pass additional options to the command"
|
124
161
|
task audit: %w(init_docker up_no_deps) do
|
125
162
|
opts = []
|
126
163
|
opts << '-T' if Dev::Common.new.running_codebuild?
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require_relative '../../base_interface'
|
2
|
-
require 'securerandom'
|
3
2
|
|
4
3
|
module Dev
|
5
4
|
module Template
|
@@ -8,14 +7,28 @@ module Dev
|
|
8
7
|
module Php
|
9
8
|
# Class for default rake tasks associated with a php project
|
10
9
|
class Application < Dev::Template::ApplicationInterface
|
11
|
-
attr_reader :php, :
|
12
|
-
|
13
|
-
#
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
10
|
+
attr_reader :php, :start_container_dependencies_on_test, :test_isolation
|
11
|
+
|
12
|
+
# Create the templated rake tasks for the php application
|
13
|
+
#
|
14
|
+
# @param application [String] The name of the application
|
15
|
+
# @param container_path [String] The path to the application inside of the container
|
16
|
+
# @param local_path [String] The path to the application on your local system
|
17
|
+
# @param start_container_dependencies_on_test [Boolean] Whether or not to start up container dependencies when running tests
|
18
|
+
# @param test_isolation [Boolean] Whether or not to start tests in an isolated project and clean up after tests are run
|
19
|
+
# @param coverage [Dev::Coverage::Base] The coverage class which is an instance of Base to be used to evaluate coverage
|
20
|
+
def initialize(
|
21
|
+
application,
|
22
|
+
container_path: nil,
|
23
|
+
local_path: nil,
|
24
|
+
start_container_dependencies_on_test: false,
|
25
|
+
test_isolation: false,
|
26
|
+
coverage: nil,
|
27
|
+
exclude: []
|
28
|
+
)
|
29
|
+
@php = Dev::Php.new(container_path:, local_path:, coverage:)
|
30
|
+
@start_container_dependencies_on_test = start_container_dependencies_on_test
|
31
|
+
@test_isolation = test_isolation
|
19
32
|
|
20
33
|
super(application, exclude:)
|
21
34
|
end
|
@@ -108,8 +121,9 @@ module Dev
|
|
108
121
|
def create_test_task!
|
109
122
|
application = @name
|
110
123
|
php = @php
|
111
|
-
siloed_tests = @siloed_tests
|
112
124
|
exclude = @exclude
|
125
|
+
test_isolation = @test_isolation
|
126
|
+
up_cmd = @start_container_dependencies_on_test ? :up : :up_no_deps
|
113
127
|
return if exclude.include?(:test)
|
114
128
|
|
115
129
|
DEV_COMMANDS_TOP_LEVEL.instance_eval do
|
@@ -119,19 +133,28 @@ module Dev
|
|
119
133
|
# This is just a placeholder to execute the dependencies
|
120
134
|
end
|
121
135
|
|
136
|
+
task test_init_docker: %w(init_docker) do
|
137
|
+
Dev::Docker::Compose.configure do |c|
|
138
|
+
c.project_name = SecureRandom.hex if test_isolation
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
122
142
|
namespace :php do
|
123
143
|
desc "Run all php tests against the #{application}'s codebase" \
|
124
144
|
"\n\t(optional) use OPTS=... to pass additional options to the command"
|
125
|
-
task test: %
|
145
|
+
task test: %W(test_init_docker #{up_cmd}) do
|
126
146
|
LOG.debug("Running all php tests in the #{application} codebase")
|
127
147
|
|
128
|
-
project_name = nil
|
129
|
-
project_name = SecureRandom.hex if siloed_tests
|
130
|
-
|
131
148
|
options = []
|
132
149
|
options << '-T' if Dev::Common.new.running_codebuild?
|
133
|
-
Dev::Docker::Compose.new(
|
134
|
-
|
150
|
+
Dev::Docker::Compose.new(services: application, options:).exec(*php.test_command)
|
151
|
+
php.check_test_coverage(application:)
|
152
|
+
|
153
|
+
# Clean up resources if we are on an isolated project name
|
154
|
+
if test_isolation
|
155
|
+
Dev::Docker::Compose.new.down
|
156
|
+
Dev::Docker.new.prune_project_volumes(project_name: Dev::Docker::Compose.config.project_name)
|
157
|
+
end
|
135
158
|
end
|
136
159
|
end
|
137
160
|
end
|
@@ -7,11 +7,29 @@ module Dev
|
|
7
7
|
module Ruby
|
8
8
|
# Class for default rake tasks associated with a ruby project
|
9
9
|
class Application < Dev::Template::ApplicationInterface
|
10
|
-
attr_reader :ruby
|
10
|
+
attr_reader :ruby, :start_container_dependencies_on_test, :test_isolation
|
11
|
+
|
12
|
+
# Create the templated rake tasks for the ruby application
|
13
|
+
#
|
14
|
+
# @param application [String] The name of the application
|
15
|
+
# @param container_path [String] The path to the application inside of the container
|
16
|
+
# @param local_path [String] The path to the application on your local system
|
17
|
+
# @param start_container_dependencies_on_test [Boolean] Whether or not to start up container dependencies when running tests
|
18
|
+
# @param test_isolation [Boolean] Whether or not to start tests in an isolated project and clean up after tests are run
|
19
|
+
# @param coverage [Dev::Coverage::Base] The coverage class which is an instance of Base to be used to evaluate coverage
|
20
|
+
def initialize(
|
21
|
+
application,
|
22
|
+
container_path: nil,
|
23
|
+
local_path: nil,
|
24
|
+
start_container_dependencies_on_test: false,
|
25
|
+
test_isolation: false,
|
26
|
+
coverage: nil,
|
27
|
+
exclude: []
|
28
|
+
)
|
29
|
+
@ruby = Dev::Ruby.new(container_path:, local_path:, coverage:)
|
30
|
+
@start_container_dependencies_on_test = start_container_dependencies_on_test
|
31
|
+
@test_isolation = test_isolation
|
11
32
|
|
12
|
-
# Allow for custom container path for the application
|
13
|
-
def initialize(application, container_path: nil, local_path: nil, exclude: [])
|
14
|
-
@ruby = Dev::Ruby.new(container_path:, local_path:)
|
15
33
|
super(application, exclude:)
|
16
34
|
end
|
17
35
|
|
@@ -30,7 +48,8 @@ module Dev
|
|
30
48
|
end
|
31
49
|
|
32
50
|
namespace :ruby do
|
33
|
-
desc "Run the ruby linting software against the #{application}'s codebase"
|
51
|
+
desc "Run the ruby linting software against the #{application}'s codebase" \
|
52
|
+
"\n\t(optional) use OPTS=... to pass additional options to the command"
|
34
53
|
task lint: %w(init_docker up_no_deps) do
|
35
54
|
LOG.debug("Check for ruby linting errors in the #{application} codebase")
|
36
55
|
|
@@ -59,6 +78,8 @@ module Dev
|
|
59
78
|
application = @name
|
60
79
|
ruby = @ruby
|
61
80
|
exclude = @exclude
|
81
|
+
test_isolation = @test_isolation
|
82
|
+
up_cmd = @start_container_dependencies_on_test ? :up : :up_no_deps
|
62
83
|
return if exclude.include?(:test)
|
63
84
|
|
64
85
|
DEV_COMMANDS_TOP_LEVEL.instance_eval do
|
@@ -68,14 +89,28 @@ module Dev
|
|
68
89
|
# This is just a placeholder to execute the dependencies
|
69
90
|
end
|
70
91
|
|
92
|
+
task test_init_docker: %w(init_docker) do
|
93
|
+
Dev::Docker::Compose.configure do |c|
|
94
|
+
c.project_name = SecureRandom.hex if test_isolation
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
71
98
|
namespace :ruby do
|
72
|
-
desc "Run all ruby tests against the #{application}'s codebase"
|
73
|
-
|
99
|
+
desc "Run all ruby tests against the #{application}'s codebase" \
|
100
|
+
"\n\t(optional) use OPTS=... to pass additional options to the command"
|
101
|
+
task test: %W(test_init_docker #{up_cmd}) do
|
74
102
|
LOG.debug("Running all ruby tests in the #{application} codebase")
|
75
103
|
|
76
104
|
options = []
|
77
105
|
options << '-T' if Dev::Common.new.running_codebuild?
|
78
106
|
Dev::Docker::Compose.new(services: application, options:).exec(*ruby.test_command)
|
107
|
+
ruby.check_test_coverage(application:)
|
108
|
+
|
109
|
+
# Clean up resources if we are on an isolated project name
|
110
|
+
if test_isolation
|
111
|
+
Dev::Docker::Compose.new.down
|
112
|
+
Dev::Docker.new.prune_project_volumes(project_name: Dev::Docker::Compose.config.project_name)
|
113
|
+
end
|
79
114
|
end
|
80
115
|
end
|
81
116
|
end
|
@@ -120,7 +155,8 @@ module Dev
|
|
120
155
|
namespace :ruby do
|
121
156
|
desc 'Run Bundle Audit on the target application' \
|
122
157
|
"\n\tuse MIN_SEVERITY=(info low moderate high critical) to fetch only severity type selected and above (default=high)." \
|
123
|
-
"\n\tuse IGNORELIST=(comma delimited list of ids) removes the entry from the list."
|
158
|
+
"\n\tuse IGNORELIST=(comma delimited list of ids) removes the entry from the list." \
|
159
|
+
"\n\t(optional) use OPTS=... to pass additional options to the command"
|
124
160
|
task audit: %w(init_docker up_no_deps) do
|
125
161
|
opts = []
|
126
162
|
opts << '-T' if Dev::Common.new.running_codebuild?
|