firespring_dev_commands 3.0.0.pre.alpha.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 72bba6fb9e4d227bad3c551b1ac78eb42819178141353aefbf9a6186bd986175
4
- data.tar.gz: d7f127460c9daedbe0bfe7e5902cc40196cd8e383a29c971ae0241ae76978f28
3
+ metadata.gz: 1d9211192a2f7237d7730a3a5cd893083a77242ec0f87e592383680411ef04f8
4
+ data.tar.gz: 9db918c1ac84c9ea5d05c108767f0204ab361a4fb89b12735c35ef78d1ff1fe3
5
5
  SHA512:
6
- metadata.gz: 10690a7a9e253d00f7ca60d36358893248cd111a07b28918564b1dd79e2f19dcf77ea5d980c905005d05c1f2ed8aba395c595c3af3426c76c431062405f3eb86
7
- data.tar.gz: 369af054ddaaeaae52e347ec02a49b26edff5f2b9c1b88c39c4b7061c68ec64ad091d052b193828034bd2f3d6165550fc920f752524ccbe70c8dc828d71beec1
6
+ metadata.gz: e22f66cbb3ddf74da92a4f3c408e6393dcd5ada6149f9b1e7297c147a83dbb985078e50efbd93ca716952122c22f4b39de7911b7659134220951f84be4140b88
7
+ data.tar.gz: 1bafebda4310e7cb15495e51aa79614c0779993014379a4ada0ee4d3192ec6980c60b2b6f5f26a422e4f692151aec42e3b914f500ddb87f88071f1ebc020417f
@@ -0,0 +1,12 @@
1
+ module Dev
2
+ class Docker
3
+ class Artifact
4
+ attr_accessor :container_path, :local_path
5
+
6
+ def initialize(container_path:, local_path:)
7
+ @container_path = container_path
8
+ @local_path = local_path
9
+ end
10
+ end
11
+ end
12
+ end
@@ -17,6 +17,8 @@ module Dev
17
17
  # @param start_container_dependencies_on_test [Boolean] Whether or not to start up container dependencies when running tests
18
18
  # @param test_isolation [Boolean] Whether or not to start tests in an isolated project and clean up after tests are run
19
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
20
22
  # @param exclude [Array<Symbol>] An array of default template tasks to exclude
21
23
  def initialize(
22
24
  application,
@@ -25,20 +27,28 @@ module Dev
25
27
  start_container_dependencies_on_test: false,
26
28
  test_isolation: false,
27
29
  coverage: nil,
30
+ lint_artifacts: nil,
31
+ test_artifacts: nil,
28
32
  exclude: []
29
33
  )
30
34
  @node = Dev::Node.new(container_path:, local_path:, coverage:)
31
35
  @start_container_dependencies_on_test = start_container_dependencies_on_test
32
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) }
33
41
 
34
42
  super(application, exclude:)
35
43
  end
36
44
 
45
+ # rubocop:disable Metrics/MethodLength
37
46
  # Create the rake task which runs linting for the application name
38
47
  def create_lint_task!
39
48
  application = @name
40
49
  node = @node
41
50
  exclude = @exclude
51
+ lint_artifacts = @lint_artifacts
42
52
  return if exclude.include?(:lint)
43
53
 
44
54
  DEV_COMMANDS_TOP_LEVEL.instance_eval do
@@ -54,9 +64,16 @@ module Dev
54
64
  task lint: %w(init_docker up_no_deps) do
55
65
  LOG.debug("Check for node linting errors in the #{application} codebase")
56
66
 
67
+ # Run the lint command
57
68
  options = []
58
69
  options << '-T' if Dev::Common.new.running_codebuild?
59
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
60
77
  end
61
78
 
62
79
  namespace :lint do
@@ -73,7 +90,9 @@ module Dev
73
90
  end
74
91
  end
75
92
  end
93
+ # rubocop:enable Metrics/MethodLength
76
94
 
95
+ # rubocop:disable Metrics/MethodLength
77
96
  # Create the rake task which runs all tests for the application name
78
97
  def create_test_task!
79
98
  application = @name
@@ -81,6 +100,7 @@ module Dev
81
100
  exclude = @exclude
82
101
  test_isolation = @test_isolation
83
102
  up_cmd = @start_container_dependencies_on_test ? :up : :up_no_deps
103
+ test_artifacts = @test_artifacts
84
104
  return if exclude.include?(:test)
85
105
 
86
106
  DEV_COMMANDS_TOP_LEVEL.instance_eval do
@@ -100,13 +120,22 @@ module Dev
100
120
  desc "Run all node tests against the #{application}'s codebase" \
101
121
  "\n\t(optional) use OPTS=... to pass additional options to the command"
102
122
  task test: %W(test_init_docker #{up_cmd}) do
103
- LOG.debug("Running all node tests in the #{application} codebase")
104
-
105
- options = []
106
- options << '-T' if Dev::Common.new.running_codebuild?
107
- Dev::Docker::Compose.new(services: application, options:).exec(*node.test_command)
108
- node.check_test_coverage(application:)
123
+ begin
124
+ LOG.debug("Running all node tests in the #{application} codebase")
109
125
 
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
110
139
  # Clean up resources if we are on an isolated project name
111
140
  if test_isolation
112
141
  Dev::Docker::Compose.new.down
@@ -117,6 +146,7 @@ module Dev
117
146
  end
118
147
  end
119
148
  end
149
+ # rubocop:enable Metrics/MethodLength
120
150
 
121
151
  # Create the rake task which runs the install command for the application packages
122
152
  def create_install_task!
@@ -162,7 +192,7 @@ module Dev
162
192
  opts = []
163
193
  opts << '-T' if Dev::Common.new.running_codebuild?
164
194
 
165
- # Retrieve results of the scan.
195
+ # Run the audit command and retrieve the results
166
196
  data = Dev::Docker::Compose.new(services: application, options: opts, capture: true).exec(*node.audit_command)
167
197
  Dev::Node::Audit.new(data).to_report.check
168
198
  end
@@ -17,6 +17,9 @@ module Dev
17
17
  # @param start_container_dependencies_on_test [Boolean] Whether or not to start up container dependencies when running tests
18
18
  # @param test_isolation [Boolean] Whether or not to start tests in an isolated project and clean up after tests are run
19
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
20
23
  def initialize(
21
24
  application,
22
25
  container_path: nil,
@@ -24,11 +27,17 @@ module Dev
24
27
  start_container_dependencies_on_test: false,
25
28
  test_isolation: false,
26
29
  coverage: nil,
30
+ lint_artifacts: nil,
31
+ test_artifacts: nil,
27
32
  exclude: []
28
33
  )
29
34
  @php = Dev::Php.new(container_path:, local_path:, coverage:)
30
35
  @start_container_dependencies_on_test = start_container_dependencies_on_test
31
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) }
32
41
 
33
42
  super(application, exclude:)
34
43
  end
@@ -77,11 +86,13 @@ module Dev
77
86
  end
78
87
  end
79
88
 
89
+ # rubocop:disable Metrics/MethodLength
80
90
  # Create the rake task which runs linting for the application name
81
91
  def create_lint_task!
82
92
  application = @name
83
93
  php = @php
84
94
  exclude = @exclude
95
+ lint_artifacts = @lint_artifacts
85
96
  return if exclude.include?(:lint)
86
97
 
87
98
  DEV_COMMANDS_TOP_LEVEL.instance_eval do
@@ -97,9 +108,16 @@ module Dev
97
108
  task lint: %w(init_docker up_no_deps) do
98
109
  LOG.debug("Check for php linting errors in the #{application} codebase")
99
110
 
111
+ # Run the lint command
100
112
  options = []
101
113
  options << '-T' if Dev::Common.new.running_codebuild?
102
114
  Dev::Docker::Compose.new(services: application, options:).exec(*php.lint_command)
115
+ ensure
116
+ # Copy any defined artifacts back
117
+ container = Dev::Docker::Compose.new.container_by_name(application)
118
+ lint_artifacts&.each do |artifact|
119
+ Dev::Docker.new.copy_from_container(container, artifact.container_path, artifact.local_path)
120
+ end
103
121
  end
104
122
 
105
123
  namespace :lint do
@@ -107,6 +125,7 @@ module Dev
107
125
  task fix: %w(init_docker up_no_deps) do
108
126
  LOG.debug("Check and fix all php linting errors in the #{application} codebase")
109
127
 
128
+ # Run the lint fix command
110
129
  options = []
111
130
  options << '-T' if Dev::Common.new.running_codebuild?
112
131
  Dev::Docker::Compose.new(services: application, options:).exec(*php.lint_fix_command)
@@ -116,7 +135,9 @@ module Dev
116
135
  end
117
136
  end
118
137
  end
138
+ # rubocop:enable Metrics/MethodLength
119
139
 
140
+ # rubocop:disable Metrics/MethodLength
120
141
  # Create the rake task which runs all tests for the application name
121
142
  def create_test_task!
122
143
  application = @name
@@ -124,6 +145,7 @@ module Dev
124
145
  exclude = @exclude
125
146
  test_isolation = @test_isolation
126
147
  up_cmd = @start_container_dependencies_on_test ? :up : :up_no_deps
148
+ test_artifacts = @test_artifacts
127
149
  return if exclude.include?(:test)
128
150
 
129
151
  DEV_COMMANDS_TOP_LEVEL.instance_eval do
@@ -143,13 +165,22 @@ module Dev
143
165
  desc "Run all php tests against the #{application}'s codebase" \
144
166
  "\n\t(optional) use OPTS=... to pass additional options to the command"
145
167
  task test: %W(test_init_docker #{up_cmd}) do
146
- LOG.debug("Running all php tests in the #{application} codebase")
147
-
148
- options = []
149
- options << '-T' if Dev::Common.new.running_codebuild?
150
- Dev::Docker::Compose.new(services: application, options:).exec(*php.test_command)
151
- php.check_test_coverage(application:)
168
+ begin
169
+ LOG.debug("Running all php tests in the #{application} codebase")
152
170
 
171
+ # Run the test command
172
+ options = []
173
+ options << '-T' if Dev::Common.new.running_codebuild?
174
+ Dev::Docker::Compose.new(services: application, options:).exec(*php.test_command)
175
+ php.check_test_coverage(application:)
176
+ ensure
177
+ # Copy any defined artifacts back
178
+ container = Dev::Docker::Compose.new.container_by_name(application)
179
+ test_artifacts&.each do |artifact|
180
+ Dev::Docker.new.copy_from_container(container, artifact.container_path, artifact.local_path)
181
+ end
182
+ end
183
+ ensure
153
184
  # Clean up resources if we are on an isolated project name
154
185
  if test_isolation
155
186
  Dev::Docker::Compose.new.down
@@ -160,6 +191,7 @@ module Dev
160
191
  end
161
192
  end
162
193
  end
194
+ # rubocop:enable Metrics/MethodLength
163
195
 
164
196
  # Create the rake tasks which runs the install command for the application packages
165
197
  def create_install_task!
@@ -205,7 +237,7 @@ module Dev
205
237
  opts = []
206
238
  opts << '-T' if Dev::Common.new.running_codebuild?
207
239
 
208
- # Retrieve results of the scan.
240
+ # Run the audit command and retrieve the results
209
241
  data = Dev::Docker::Compose.new(services: application, options: opts, capture: true).exec(*php.audit_command)
210
242
  Dev::Php::Audit.new(data).to_report.check
211
243
  end
@@ -17,6 +17,9 @@ module Dev
17
17
  # @param start_container_dependencies_on_test [Boolean] Whether or not to start up container dependencies when running tests
18
18
  # @param test_isolation [Boolean] Whether or not to start tests in an isolated project and clean up after tests are run
19
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
20
23
  def initialize(
21
24
  application,
22
25
  container_path: nil,
@@ -24,20 +27,28 @@ module Dev
24
27
  start_container_dependencies_on_test: false,
25
28
  test_isolation: false,
26
29
  coverage: nil,
30
+ lint_artifacts: nil,
31
+ test_artifacts: nil,
27
32
  exclude: []
28
33
  )
29
34
  @ruby = Dev::Ruby.new(container_path:, local_path:, coverage:)
30
35
  @start_container_dependencies_on_test = start_container_dependencies_on_test
31
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) }
32
41
 
33
42
  super(application, exclude:)
34
43
  end
35
44
 
45
+ # rubocop:disable Metrics/MethodLength
36
46
  # Create the rake task which runs linting for the application name
37
47
  def create_lint_task!
38
48
  application = @name
39
49
  ruby = @ruby
40
50
  exclude = @exclude
51
+ lint_artifacts = @lint_artifacts
41
52
  return if exclude.include?(:lint)
42
53
 
43
54
  DEV_COMMANDS_TOP_LEVEL.instance_eval do
@@ -53,9 +64,16 @@ module Dev
53
64
  task lint: %w(init_docker up_no_deps) do
54
65
  LOG.debug("Check for ruby linting errors in the #{application} codebase")
55
66
 
67
+ # Run the lint command
56
68
  options = []
57
69
  options << '-T' if Dev::Common.new.running_codebuild?
58
70
  Dev::Docker::Compose.new(services: application, options:).exec(*ruby.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
59
77
  end
60
78
 
61
79
  namespace :lint do
@@ -63,6 +81,7 @@ module Dev
63
81
  task fix: %w(init_docker up_no_deps) do
64
82
  LOG.debug("Check and fix all ruby linting errors in the #{application} codebase")
65
83
 
84
+ # Run the lint fix command
66
85
  options = []
67
86
  options << '-T' if Dev::Common.new.running_codebuild?
68
87
  Dev::Docker::Compose.new(services: application, options:).exec(*ruby.lint_fix_command)
@@ -72,7 +91,9 @@ module Dev
72
91
  end
73
92
  end
74
93
  end
94
+ # rubocop:enable Metrics/MethodLength
75
95
 
96
+ # rubocop:disable Metrics/MethodLength
76
97
  # Create the rake task which runs all tests for the application name
77
98
  def create_test_task!
78
99
  application = @name
@@ -80,6 +101,7 @@ module Dev
80
101
  exclude = @exclude
81
102
  test_isolation = @test_isolation
82
103
  up_cmd = @start_container_dependencies_on_test ? :up : :up_no_deps
104
+ test_artifacts = @test_artifacts
83
105
  return if exclude.include?(:test)
84
106
 
85
107
  DEV_COMMANDS_TOP_LEVEL.instance_eval do
@@ -99,13 +121,21 @@ module Dev
99
121
  desc "Run all ruby tests against the #{application}'s codebase" \
100
122
  "\n\t(optional) use OPTS=... to pass additional options to the command"
101
123
  task test: %W(test_init_docker #{up_cmd}) do
102
- LOG.debug("Running all ruby tests in the #{application} codebase")
103
-
104
- options = []
105
- options << '-T' if Dev::Common.new.running_codebuild?
106
- Dev::Docker::Compose.new(services: application, options:).exec(*ruby.test_command)
107
- ruby.check_test_coverage(application:)
124
+ begin
125
+ LOG.debug("Running all ruby tests in the #{application} codebase")
108
126
 
127
+ options = []
128
+ options << '-T' if Dev::Common.new.running_codebuild?
129
+ Dev::Docker::Compose.new(services: application, options:).exec(*ruby.test_command)
130
+ ruby.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
109
139
  # Clean up resources if we are on an isolated project name
110
140
  if test_isolation
111
141
  Dev::Docker::Compose.new.down
@@ -116,6 +146,7 @@ module Dev
116
146
  end
117
147
  end
118
148
  end
149
+ # rubocop:enable Metrics/MethodLength
119
150
 
120
151
  # Create the rake task which runs the install command for the application packages
121
152
  def create_install_task!
@@ -6,6 +6,6 @@ module Dev
6
6
  # Use 'v.v.v.pre.alpha.v' for pre-release vesions
7
7
  # Use 'v.v.v.beta.v for beta versions
8
8
  # Use semantic versioning for any releases (https://semver.org/)
9
- VERSION = '3.0.0.pre.alpha.1'.freeze
9
+ VERSION = '3.0.0.pre.alpha.2'.freeze
10
10
  end
11
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: firespring_dev_commands
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.pre.alpha.1
4
+ version: 3.0.0.pre.alpha.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Firespring
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-11 00:00:00.000000000 Z
11
+ date: 2024-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -338,6 +338,7 @@ files:
338
338
  - lib/firespring_dev_commands/coverage/none.rb
339
339
  - lib/firespring_dev_commands/daterange.rb
340
340
  - lib/firespring_dev_commands/docker.rb
341
+ - lib/firespring_dev_commands/docker/artifact.rb
341
342
  - lib/firespring_dev_commands/docker/compose.rb
342
343
  - lib/firespring_dev_commands/docker/status.rb
343
344
  - lib/firespring_dev_commands/dotenv.rb