crucible_ci 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b84a6c1b6239c61202a2be5e0d7e1f7f64171df8
4
+ data.tar.gz: fdad753ff654c84d5498fb34a923a4ef1f2dbcce
5
+ SHA512:
6
+ metadata.gz: b21a798e117d832056d17a808673e1eb685b2c709d4994305a07ba10b010f76ef293dbf9e9510681b3cde763d201823d5d345d5cbe160f7c092ad36be9713a39
7
+ data.tar.gz: 0e922b275390f1b3f1db15b20b19116eaff70168962898e12d71110a4cc433d74ea7c5b33b53d3f5d9cfce82ab30d432cf792acae2147671084538565b4307c0
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ .DS_Store
2
+ results.html
3
+ pkg
4
+ html
5
+ logs/*.log
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in crucible_ci.gemspec
4
+ gemspec
5
+
6
+ gem 'plan_executor', git: 'https://github.com/fhir-crucible/plan_executor.git', :branch => 'master'
7
+ # gem 'plan_executor', path: '../plan_executor'
8
+ gem 'fhir_models', git: 'https://github.com/fhir-crucible/fhir_models.git', branch: 'master'
9
+ gem 'fhir_client', git: 'https://github.com/fhir-crucible/fhir_client.git', branch: 'master'
10
+
11
+ group :test do
12
+ gem 'pry'
13
+ gem 'pry-nav'
14
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,169 @@
1
+ GIT
2
+ remote: https://github.com/fhir-crucible/fhir_client.git
3
+ revision: cf09b77d0264930e99e59b04b739f1eb05521f24
4
+ branch: master
5
+ specs:
6
+ fhir_client (1.8.0)
7
+ activesupport (>= 3)
8
+ addressable (>= 2.3)
9
+ fhir_models (>= 1.8.0)
10
+ nokogiri
11
+ oauth2 (~> 1.1)
12
+ rack (>= 1.5)
13
+ rest-client (~> 1.8)
14
+ tilt (>= 1.1)
15
+
16
+ GIT
17
+ remote: https://github.com/fhir-crucible/fhir_models.git
18
+ revision: 07d952e5a3bfe22c13dd7498ddb256e57ee5776c
19
+ branch: master
20
+ specs:
21
+ fhir_models (1.8.2)
22
+ bcp47 (>= 0.3)
23
+ date_time_precision (>= 0.8)
24
+ mime-types (>= 1.16, < 3)
25
+ nokogiri (>= 1.6)
26
+
27
+ GIT
28
+ remote: https://github.com/fhir-crucible/plan_executor.git
29
+ revision: fc9d014a0c961398185bfa6347734c381c617634
30
+ branch: master
31
+ specs:
32
+ plan_executor (1.8.0)
33
+ ansi
34
+ fhir_client
35
+ fhir_models
36
+ jsonpath
37
+ method_source
38
+ nokogiri
39
+ nokogiri-diff
40
+
41
+ PATH
42
+ remote: .
43
+ specs:
44
+ crucible_ci (0.1.0)
45
+ methadone (~> 1.9.2)
46
+
47
+ GEM
48
+ remote: https://rubygems.org/
49
+ specs:
50
+ activesupport (5.0.1)
51
+ concurrent-ruby (~> 1.0, >= 1.0.2)
52
+ i18n (~> 0.7)
53
+ minitest (~> 5.1)
54
+ tzinfo (~> 1.1)
55
+ addressable (2.5.0)
56
+ public_suffix (~> 2.0, >= 2.0.2)
57
+ ansi (1.5.0)
58
+ aruba (0.14.2)
59
+ childprocess (~> 0.5.6)
60
+ contracts (~> 0.9)
61
+ cucumber (>= 1.3.19)
62
+ ffi (~> 1.9.10)
63
+ rspec-expectations (>= 2.99)
64
+ thor (~> 0.19)
65
+ bcp47 (0.3.3)
66
+ i18n
67
+ builder (3.2.3)
68
+ childprocess (0.5.9)
69
+ ffi (~> 1.0, >= 1.0.11)
70
+ coderay (1.1.1)
71
+ concurrent-ruby (1.0.4)
72
+ contracts (0.14.0)
73
+ cucumber (2.4.0)
74
+ builder (>= 2.1.2)
75
+ cucumber-core (~> 1.5.0)
76
+ cucumber-wire (~> 0.0.1)
77
+ diff-lcs (>= 1.1.3)
78
+ gherkin (~> 4.0)
79
+ multi_json (>= 1.7.5, < 2.0)
80
+ multi_test (>= 0.1.2)
81
+ cucumber-core (1.5.0)
82
+ gherkin (~> 4.0)
83
+ cucumber-wire (0.0.1)
84
+ date_time_precision (0.8.1)
85
+ diff-lcs (1.3)
86
+ domain_name (0.5.20161129)
87
+ unf (>= 0.0.5, < 1.0.0)
88
+ faraday (0.10.1)
89
+ multipart-post (>= 1.2, < 3)
90
+ ffi (1.9.17)
91
+ gherkin (4.0.0)
92
+ http-cookie (1.0.3)
93
+ domain_name (~> 0.5)
94
+ i18n (0.8.0)
95
+ jsonpath (0.5.8)
96
+ multi_json
97
+ jwt (1.5.6)
98
+ methadone (1.9.5)
99
+ bundler
100
+ method_source (0.8.2)
101
+ mime-types (2.99.3)
102
+ mini_portile2 (2.1.0)
103
+ minitest (5.10.1)
104
+ multi_json (1.12.1)
105
+ multi_test (0.1.2)
106
+ multi_xml (0.6.0)
107
+ multipart-post (2.0.0)
108
+ netrc (0.11.0)
109
+ nokogiri (1.7.0.1)
110
+ mini_portile2 (~> 2.1.0)
111
+ nokogiri-diff (0.2.0)
112
+ nokogiri (~> 1.5)
113
+ tdiff (~> 0.3, >= 0.3.2)
114
+ oauth2 (1.3.0)
115
+ faraday (>= 0.8, < 0.11)
116
+ jwt (~> 1.0)
117
+ multi_json (~> 1.3)
118
+ multi_xml (~> 0.5)
119
+ rack (>= 1.2, < 3)
120
+ power_assert (1.0.1)
121
+ pry (0.10.4)
122
+ coderay (~> 1.1.0)
123
+ method_source (~> 0.8.1)
124
+ slop (~> 3.4)
125
+ pry-nav (0.2.4)
126
+ pry (>= 0.9.10, < 0.11.0)
127
+ public_suffix (2.0.5)
128
+ rack (2.0.1)
129
+ rake (12.0.0)
130
+ rdoc (5.0.0)
131
+ rest-client (1.8.0)
132
+ http-cookie (>= 1.0.2, < 2.0)
133
+ mime-types (>= 1.16, < 3.0)
134
+ netrc (~> 0.7)
135
+ rspec-expectations (3.5.0)
136
+ diff-lcs (>= 1.2.0, < 2.0)
137
+ rspec-support (~> 3.5.0)
138
+ rspec-support (3.5.0)
139
+ slop (3.6.0)
140
+ tdiff (0.3.3)
141
+ test-unit (3.2.3)
142
+ power_assert
143
+ thor (0.19.4)
144
+ thread_safe (0.3.5)
145
+ tilt (2.0.6)
146
+ tzinfo (1.2.2)
147
+ thread_safe (~> 0.1)
148
+ unf (0.1.4)
149
+ unf_ext
150
+ unf_ext (0.0.7.2)
151
+
152
+ PLATFORMS
153
+ ruby
154
+
155
+ DEPENDENCIES
156
+ aruba
157
+ bundler (~> 1.12)
158
+ crucible_ci!
159
+ fhir_client!
160
+ fhir_models!
161
+ plan_executor!
162
+ pry
163
+ pry-nav
164
+ rake
165
+ rdoc
166
+ test-unit
167
+
168
+ BUNDLED WITH
169
+ 1.14.4
data/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright {yyyy} {name of copyright owner}
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # CrucibleCI
2
+
3
+ CrucibleCI is a gem to run Crucible's [Plan Executor](https://github.com/fhir-crucible/plan_executor) tests against a FHIR server. It's intended for use in Continuous Integration and other testing systems to validate servers during development.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile
8
+
9
+ ```ruby
10
+ gem 'crucible_ci'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install crucible_ci
20
+
21
+ ## Usage
22
+
23
+ ```shell
24
+ ./bin/crucible_ci [options] server_url
25
+
26
+ ```
27
+ Where `server_url` is the URL of a FHIR server accessible to the current computer.
28
+
29
+ ### Options
30
+
31
+ * `-h`, `--help` - Displays this help message
32
+ * `-r`, `--resource` `VALUE` - The name of a FHIR Resource to be tested (such as `Patient` or `Encounter`)
33
+ * `-t`, `--test` `VALUE` - The name of a Plan Executor test to be tested (such as `HistoryTest`)
34
+ * `-a`, `--allowed-failures` `VALUE` - The number of failures allowed in the test suite (default: `0`)
35
+ * `-v`, `--version` - Show help/version info
36
+ * `--log-level` `LEVEL` Set the logging level (`debug`|`info`|`warn`|`error`|`fatal`) (default: `info`)
37
+
38
+ ## Development
39
+
40
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
41
+
42
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
43
+
44
+ ## Contributing
45
+
46
+ Bug reports and pull requests are welcome on GitHub at https://github.com/fhir-crucible/crucible_ci.
47
+
48
+ Copyright (C) 2017 The MITRE Corporation.
data/Rakefile ADDED
@@ -0,0 +1,56 @@
1
+ def dump_load_path
2
+ puts $LOAD_PATH.join("\n")
3
+ found = nil
4
+ $LOAD_PATH.each do |path|
5
+ next unless File.exist?(File.join(path, 'rspec'))
6
+ puts "Found rspec in #{path}"
7
+ if File.exist?(File.join(path, 'rspec', 'core'))
8
+ puts 'Found core'
9
+ if File.exist?(File.join(path, 'rspec', 'core', 'rake_task'))
10
+ puts 'Found rake_task'
11
+ found = path
12
+ else
13
+ puts '!! no rake_task'
14
+ end
15
+ else
16
+ puts '!!! no core'
17
+ end
18
+ end
19
+ if found.nil?
20
+ puts "Didn't find rspec/core/rake_task anywhere"
21
+ else
22
+ puts "Found in #{path}"
23
+ end
24
+ end
25
+ require 'bundler'
26
+ require 'rake/clean'
27
+
28
+ require 'rake/testtask'
29
+
30
+ require 'cucumber'
31
+ require 'cucumber/rake/task'
32
+ gem 'rdoc' # we need the installed RDoc gem, not the system one
33
+ require 'rdoc/task'
34
+
35
+ include Rake::DSL
36
+
37
+ Bundler::GemHelper.install_tasks
38
+
39
+ Rake::TestTask.new do |t|
40
+ t.pattern = 'test/tc_*.rb'
41
+ end
42
+
43
+ CUKE_RESULTS = 'results.html'.freeze
44
+ CLEAN << CUKE_RESULTS
45
+ Cucumber::Rake::Task.new(:features) do |t|
46
+ t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty --no-source -x"
47
+ t.fork = false
48
+ end
49
+
50
+ Rake::RDocTask.new do |rd|
51
+ rd.main = 'README.rdoc'
52
+
53
+ rd.rdoc_files.include('README.rdoc', 'lib/**/*.rb', 'bin/**/*')
54
+ end
55
+
56
+ task default: [:test, :features]
data/bin/console ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'crucible_ci'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ require 'pry'
11
+ Pry.start
data/bin/crucible_ci ADDED
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require 'methadone'
5
+ require 'bundler/setup'
6
+ require 'crucible_ci'
7
+
8
+ class App
9
+ include Methadone::Main
10
+ include Methadone::CLILogging
11
+
12
+ main do |server_url|
13
+ allowed_failures = options['allowed-failures'] ? options['allowed-failures'].to_i : 0
14
+ if options[:resource] || options[:test]
15
+ CrucibleCi::Executor.execute(server_url, allowed_failures, options[:test], options[:resource])
16
+ else
17
+ CrucibleCi::Executor.execute_all(server_url, allowed_failures)
18
+ end
19
+ end
20
+
21
+ on('-r', '--resource VALUE', 'The name of a FHIR Resource to be tested')
22
+ on('-t', '--test VALUE', 'The name of a Plan Executor test to be tested')
23
+ on('-a', '--allowed-failures VALUE', 'The number of failures allowed in the test suite (Default: 0)')
24
+
25
+ arg :server_url
26
+
27
+ version CrucibleCi::VERSION
28
+
29
+ use_log_level_option toggle_debug_on_signal: 'USR1'
30
+
31
+ go!
32
+ end
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'crucible_ci/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'crucible_ci'
8
+ spec.license = 'Apache-2.0'
9
+ spec.version = CrucibleCi::VERSION
10
+ spec.authors = ["Michael O'Keefe"]
11
+ spec.email = ['mokeefe@mitre.org']
12
+
13
+ spec.summary = 'A way to run Plan Executor tests in the command line'
14
+ spec.homepage = 'https://github.com/fhir-crucible/crucible_ci'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = 'exe'
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.12'
22
+ spec.add_development_dependency('rdoc')
23
+ spec.add_development_dependency('aruba')
24
+ spec.add_development_dependency('rake')
25
+ spec.add_dependency('methadone', '~> 1.9.2')
26
+ spec.add_development_dependency('test-unit')
27
+ end
@@ -0,0 +1,3 @@
1
+ module CrucibleCi
2
+ VERSION = '0.1.0'.freeze
3
+ end
@@ -0,0 +1,143 @@
1
+ require 'crucible_ci/version'
2
+ require 'plan_executor'
3
+ require 'benchmark'
4
+
5
+ module CrucibleCi
6
+ class Executor
7
+ def self.execute(url, allowed_failures, test = nil, resource = nil)
8
+ results = nil
9
+ FHIR.logger = Logger.new("logs/crucible_ci.log", 10, 1024000)
10
+ b = Benchmark.measure do
11
+ client = FHIR::Client.new(url)
12
+ client.conformance_statement
13
+ # options = client.get_oauth2_metadata_from_conformance
14
+ # set_client_secrets(client, options) unless options.empty?
15
+ results = execute_test(client, test, resource)
16
+ end
17
+ puts "Execute #{test} completed in #{b.real} seconds."
18
+ passing?(results, allowed_failures)
19
+ end
20
+
21
+ def self.execute_all(url, allowed_failures)
22
+ results = nil
23
+ FHIR.logger = Logger.new("logs/crucible_ci.log", 10, 1024000)
24
+ b = Benchmark.measure do
25
+ client = FHIR::Client.new(url)
26
+ client.conformance_statement
27
+ # options = client.get_oauth2_metadata_from_conformance
28
+ # set_client_secrets(client, options) unless options.empty?
29
+ results = execute_all(client)
30
+ end
31
+ puts "Execute All completed in #{b.real} seconds."
32
+ passing?(results, allowed_failures)
33
+ end
34
+
35
+ def self.num_failures(results)
36
+ statuses = results.collect { |_, v| v.collect { |r| r['status'] } }.flatten
37
+ return statuses.count('fail') + statuses.count('error')
38
+ end
39
+
40
+ def self.passing?(results, allowed_failures)
41
+ failures = num_failures(results)
42
+ if failures > allowed_failures
43
+ return 64
44
+ else
45
+ return 0
46
+ end
47
+ end
48
+
49
+ def self.set_client_secrets(client, options)
50
+ puts "Using OAuth2 Options: #{options}"
51
+ print 'Enter client id: '
52
+ client_id = STDIN.gets.chomp
53
+ print 'Enter client secret: '
54
+ client_secret = STDIN.gets.chomp
55
+ if client_id != '' && client_secret != ''
56
+ options[:client_id] = client_id
57
+ options[:client_secret] = client_secret
58
+ client.set_oauth2_auth(options[:client_id], options[:client_secret], options[:authorize_url], options[:token_url])
59
+ else
60
+ puts 'Ignoring OAuth2 credentials: empty id or secret. Using unsecured client...'
61
+ end
62
+ end
63
+
64
+ def self.execute_test(client, key, resourceType = nil)
65
+ executor = Crucible::Tests::Executor.new(client)
66
+ test = executor.find_test(key)
67
+ if test.nil?
68
+ puts "Unable to find test: #{key}"
69
+ return -1
70
+ end
71
+ results = nil
72
+ if !resourceType.nil? && test.respond_to?(:resource_class=) && FHIR::RESOURCES.include?(resourceType)
73
+ results = test.execute("FHIR::#{resourceType}".constantize)
74
+ end
75
+ results = executor.execute(test) if results.nil?
76
+ output_results results
77
+ end
78
+
79
+ def self.execute_all(client)
80
+ executor = Crucible::Tests::Executor.new(client)
81
+ all_results = {}
82
+ executor.tests.each do |test|
83
+ next if test.multiserver
84
+ results = executor.execute(test)
85
+ all_results.merge! results
86
+ output_results results
87
+ end
88
+ all_results
89
+ end
90
+
91
+ def self.execute_multiserver_test(client, client2, key)
92
+ executor = Crucible::Tests::Executor.new(client, client2)
93
+ output_results executor.execute(executor.find_test(key))
94
+ end
95
+
96
+ def self.collect_metadata(client, test)
97
+ output_results Crucible::Tests::Executor.new(client).metadata(test), true
98
+ end
99
+
100
+ def self.write_result(status, test_name, message)
101
+ tab_size = 10
102
+ "#{' ' * (tab_size - status.length)}#{colorize(status)} #{test_name}: #{message}"
103
+ end
104
+
105
+ def self.colorize(status)
106
+ case status.upcase
107
+ when 'PASS'
108
+ ANSI.green { status.upcase }
109
+ when 'SKIP'
110
+ ANSI.blue { status.upcase }
111
+ when 'FAIL'
112
+ ANSI.red { status.upcase }
113
+ else
114
+ ANSI.white_on_red { status.upcase }
115
+ end
116
+ end
117
+
118
+ def self.output_results(results, metadata_only = false)
119
+ require 'ansi'
120
+ results.keys.each do |suite_key|
121
+ puts suite_key
122
+ results[suite_key].each do |test|
123
+ puts write_result(test['status'], test[:test_method], test['message'])
124
+ if test['status'].casecmp('ERROR').zero?
125
+ puts ' ' * 12 + '-' * 40
126
+ puts ' ' * 12 + test['data'].gsub("\n", "\n" + ' ' * 12).to_s
127
+ puts ' ' * 12 + '-' * 40
128
+ end
129
+ next unless metadata_only == true
130
+ # warnings
131
+ puts (test['warnings'].map { |w| "#{(' ' * 10)}WARNING: #{w}" }).join("\n") if test['warnings']
132
+ # metadata
133
+ puts (test['links'].map { |w| "#{(' ' * 10)}Link: #{w}" }).join("\n") if test['links']
134
+ puts (test['requires'].map { |w| "#{(' ' * 10)}Requires: #{w[:resource]}: #{w[:methods]}" }).join("\n") if test['requires']
135
+ puts (test['validates'].map { |w| "#{(' ' * 10)}Validates: #{w[:resource]}: #{w[:methods]}" }).join("\n") if test['validates']
136
+ # data
137
+ puts (' ' * 10) + test['data'] if test['data']
138
+ end
139
+ end
140
+ results
141
+ end
142
+ end
143
+ end
data/logs/.gitkeep ADDED
File without changes
metadata ADDED
@@ -0,0 +1,141 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: crucible_ci
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Michael O'Keefe
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-02-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rdoc
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: aruba
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: methadone
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 1.9.2
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 1.9.2
83
+ - !ruby/object:Gem::Dependency
84
+ name: test-unit
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description:
98
+ email:
99
+ - mokeefe@mitre.org
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - Gemfile
106
+ - Gemfile.lock
107
+ - LICENSE
108
+ - README.md
109
+ - Rakefile
110
+ - bin/console
111
+ - bin/crucible_ci
112
+ - bin/setup
113
+ - crucible_ci.gemspec
114
+ - lib/crucible_ci.rb
115
+ - lib/crucible_ci/version.rb
116
+ - logs/.gitkeep
117
+ homepage: https://github.com/fhir-crucible/crucible_ci
118
+ licenses:
119
+ - Apache-2.0
120
+ metadata: {}
121
+ post_install_message:
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ requirements: []
136
+ rubyforge_project:
137
+ rubygems_version: 2.4.8
138
+ signing_key:
139
+ specification_version: 4
140
+ summary: A way to run Plan Executor tests in the command line
141
+ test_files: []