firespring_dev_commands 2.5.0.pre.alpha.3 → 3.0.0.pre.alpha.2
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/artifact.rb +12 -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 +82 -15
- data/lib/firespring_dev_commands/templates/docker/php/application.rb +74 -19
- data/lib/firespring_dev_commands/templates/docker/ruby/application.rb +79 -12
- data/lib/firespring_dev_commands/version.rb +1 -1
- data/lib/firespring_dev_commands.rb +1 -1
- metadata +43 -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,19 +7,48 @@ 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 lint_artifacts [Dev::Docker::Artifact] An array of lint artifacts to copy back from the container
|
21
|
+
# @param test_artifacts [Dev::Docker::Artifact] An array of test artifacts to copy back from the container
|
22
|
+
# @param exclude [Array<Symbol>] An array of default template tasks to exclude
|
23
|
+
def initialize(
|
24
|
+
application,
|
25
|
+
container_path: nil,
|
26
|
+
local_path: nil,
|
27
|
+
start_container_dependencies_on_test: false,
|
28
|
+
test_isolation: false,
|
29
|
+
coverage: nil,
|
30
|
+
lint_artifacts: nil,
|
31
|
+
test_artifacts: nil,
|
32
|
+
exclude: []
|
33
|
+
)
|
34
|
+
@node = Dev::Node.new(container_path:, local_path:, coverage:)
|
35
|
+
@start_container_dependencies_on_test = start_container_dependencies_on_test
|
36
|
+
@test_isolation = test_isolation
|
37
|
+
@lint_artifacts = lint_artifacts
|
38
|
+
@test_artifacts = test_artifacts
|
39
|
+
raise 'lint artifact must be instance of Dev::Docker::Artifact' if lint_artifacts&.any? { |it| !it.is_a?(Dev::Docker::Artifact) }
|
40
|
+
raise 'test artifact must be instance of Dev::Docker::Artifact' if test_artifacts&.any? { |it| !it.is_a?(Dev::Docker::Artifact) }
|
11
41
|
|
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
42
|
super(application, exclude:)
|
16
43
|
end
|
17
44
|
|
45
|
+
# rubocop:disable Metrics/MethodLength
|
18
46
|
# Create the rake task which runs linting for the application name
|
19
47
|
def create_lint_task!
|
20
48
|
application = @name
|
21
49
|
node = @node
|
22
50
|
exclude = @exclude
|
51
|
+
lint_artifacts = @lint_artifacts
|
23
52
|
return if exclude.include?(:lint)
|
24
53
|
|
25
54
|
DEV_COMMANDS_TOP_LEVEL.instance_eval do
|
@@ -30,19 +59,27 @@ module Dev
|
|
30
59
|
end
|
31
60
|
|
32
61
|
namespace :node do
|
33
|
-
desc "Run the node linting software against the #{application}'s codebase"
|
62
|
+
desc "Run the node linting software against the #{application}'s codebase" \
|
63
|
+
"\n\t(optional) use OPTS=... to pass additional options to the command"
|
34
64
|
task lint: %w(init_docker up_no_deps) do
|
35
|
-
LOG.debug(
|
65
|
+
LOG.debug("Check for node linting errors in the #{application} codebase")
|
36
66
|
|
67
|
+
# Run the lint command
|
37
68
|
options = []
|
38
69
|
options << '-T' if Dev::Common.new.running_codebuild?
|
39
70
|
Dev::Docker::Compose.new(services: application, options:).exec(*node.lint_command)
|
71
|
+
ensure
|
72
|
+
# Copy any defined artifacts back
|
73
|
+
container = Dev::Docker::Compose.new.container_by_name(application)
|
74
|
+
lint_artifacts&.each do |artifact|
|
75
|
+
Dev::Docker.new.copy_from_container(container, artifact.container_path, artifact.local_path)
|
76
|
+
end
|
40
77
|
end
|
41
78
|
|
42
79
|
namespace :lint do
|
43
80
|
desc "Run the linting software against the #{application}'s codebase and apply all available fixes"
|
44
81
|
task fix: %w(init_docker up_no_deps) do
|
45
|
-
LOG.debug(
|
82
|
+
LOG.debug("Check and fix all node linting errors in the #{application} codebase")
|
46
83
|
|
47
84
|
options = []
|
48
85
|
options << '-T' if Dev::Common.new.running_codebuild?
|
@@ -53,12 +90,17 @@ module Dev
|
|
53
90
|
end
|
54
91
|
end
|
55
92
|
end
|
93
|
+
# rubocop:enable Metrics/MethodLength
|
56
94
|
|
95
|
+
# rubocop:disable Metrics/MethodLength
|
57
96
|
# Create the rake task which runs all tests for the application name
|
58
97
|
def create_test_task!
|
59
98
|
application = @name
|
60
99
|
node = @node
|
61
100
|
exclude = @exclude
|
101
|
+
test_isolation = @test_isolation
|
102
|
+
up_cmd = @start_container_dependencies_on_test ? :up : :up_no_deps
|
103
|
+
test_artifacts = @test_artifacts
|
62
104
|
return if exclude.include?(:test)
|
63
105
|
|
64
106
|
DEV_COMMANDS_TOP_LEVEL.instance_eval do
|
@@ -68,19 +110,43 @@ module Dev
|
|
68
110
|
# This is just a placeholder to execute the dependencies
|
69
111
|
end
|
70
112
|
|
113
|
+
task test_init_docker: %w(init_docker) do
|
114
|
+
Dev::Docker::Compose.configure do |c|
|
115
|
+
c.project_name = SecureRandom.hex if test_isolation
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
71
119
|
namespace :node do
|
72
|
-
desc "Run all node tests against the #{application}'s codebase"
|
73
|
-
|
74
|
-
|
120
|
+
desc "Run all node tests against the #{application}'s codebase" \
|
121
|
+
"\n\t(optional) use OPTS=... to pass additional options to the command"
|
122
|
+
task test: %W(test_init_docker #{up_cmd}) do
|
123
|
+
begin
|
124
|
+
LOG.debug("Running all node tests in the #{application} codebase")
|
75
125
|
|
76
|
-
|
77
|
-
|
78
|
-
|
126
|
+
# Run the test command
|
127
|
+
options = []
|
128
|
+
options << '-T' if Dev::Common.new.running_codebuild?
|
129
|
+
Dev::Docker::Compose.new(services: application, options:).exec(*node.test_command)
|
130
|
+
node.check_test_coverage(application:)
|
131
|
+
ensure
|
132
|
+
# Copy any defined artifacts back
|
133
|
+
container = Dev::Docker::Compose.new.container_by_name(application)
|
134
|
+
test_artifacts&.each do |artifact|
|
135
|
+
Dev::Docker.new.copy_from_container(container, artifact.container_path, artifact.local_path)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
ensure
|
139
|
+
# Clean up resources if we are on an isolated project name
|
140
|
+
if test_isolation
|
141
|
+
Dev::Docker::Compose.new.down
|
142
|
+
Dev::Docker.new.prune_project_volumes(project_name: Dev::Docker::Compose.config.project_name)
|
143
|
+
end
|
79
144
|
end
|
80
145
|
end
|
81
146
|
end
|
82
147
|
end
|
83
148
|
end
|
149
|
+
# rubocop:enable Metrics/MethodLength
|
84
150
|
|
85
151
|
# Create the rake task which runs the install command for the application packages
|
86
152
|
def create_install_task!
|
@@ -120,12 +186,13 @@ module Dev
|
|
120
186
|
namespace :node do
|
121
187
|
desc 'Run NPM Audit on the target application' \
|
122
188
|
"\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."
|
189
|
+
"\n\tuse IGNORELIST=(comma delimited list of ids) removes the entry from the list." \
|
190
|
+
"\n\t(optional) use OPTS=... to pass additional options to the command"
|
124
191
|
task audit: %w(init_docker up_no_deps) do
|
125
192
|
opts = []
|
126
193
|
opts << '-T' if Dev::Common.new.running_codebuild?
|
127
194
|
|
128
|
-
#
|
195
|
+
# Run the audit command and retrieve the results
|
129
196
|
data = Dev::Docker::Compose.new(services: application, options: opts, capture: true).exec(*node.audit_command)
|
130
197
|
Dev::Node::Audit.new(data).to_report.check
|
131
198
|
end
|