openstudio_measure_tester 0.3.3 → 0.4.0

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: 7f5a572a08e1cf50dac9d00cbd082413321ee167bdf987176f0aa57ac8762ffc
4
- data.tar.gz: 2d5465eec4d31216ba26a4a4907998bd29fa9650f592b7369474c2c8e5077820
3
+ metadata.gz: b2154c98870a730a34aec0ea97ae64385c72963384da1486bb4097fd8bcf049e
4
+ data.tar.gz: 2e4addb622ad23fc056aa3f6e41e654f901b971175c5b1e987e036fd444f93c4
5
5
  SHA512:
6
- metadata.gz: 4c7ade21a3fe0b0a77395cb0a4c647b000ef34037c50b67202dfb92662d6659e7c9980569b3ba76da67edba2a4f2a60523f8d933871ea4a0058d9485e1a8bc33
7
- data.tar.gz: d46a3c20cabc1415ca754c3e9b5bffaf09615ae215674fe4555412319de76e02d5a1b4f97ce2da0e1075f41bb4296d9b989c0837e0a73ef207befca1073ca2d5
6
+ metadata.gz: 8d559a442f9a549592ee70666227e2e8c89f8ac14ab0c74a421c2f0d40838f2f98518394f00bfab8a1646a091b07aa29ab72d8e563f98e9c91fd5bd0bac8ac6d
7
+ data.tar.gz: 97a14956b4088ff07b45716864148d78dcdbded3dbe5d27109fbaf490d451efafeeafd8448db278b450093aeafd19a3c14ea65fcc76e4fedb42011fd7ed4955b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # Version 0.4.0
2
+
3
+ * Upgrade to Ruby 3.2.2
4
+ * updaring gem versions of rubocop and simplecov
5
+
1
6
  # Version 0.3.3
2
7
 
3
8
  * Update license
data/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- OpenStudio(R), Copyright (c) 2008, 2023 Alliance for Sustainable Energy, LLC.
1
+ OpenStudio(R), Copyright (c) 2008, 2024 Alliance for Sustainable Energy, LLC.
2
2
 
3
3
  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4
4
 
@@ -22,7 +22,7 @@ module OpenStudioMeasureTester
22
22
  end
23
23
 
24
24
  def render
25
- rendered = ERB.new(@template, 0, nil, '@html').result(binding)
25
+ rendered = ERB.new(@template, trim_mode: nil, eoutvar: '@html').result(binding)
26
26
  save_dir = "#{@test_results_directory}/dashboard"
27
27
 
28
28
  # Render the dashboard
@@ -0,0 +1,110 @@
1
+ # frozen_string_literal: true
2
+
3
+ # *******************************************************************************
4
+ # OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC.
5
+ # See also https://openstudio.net/license
6
+ # *******************************************************************************
7
+
8
+ module OpenStudioMeasureTester
9
+ class GithubActionsReport
10
+ attr_reader :minitest_summary_table, :all_annotations
11
+
12
+ # @param test_results_directory [String]: The directory
13
+ def initialize(test_results_directory)
14
+ @test_results_directory = test_results_directory
15
+ file = File.read("#{@test_results_directory}/combined_results.json")
16
+ @hash = JSON.parse(file)
17
+ @minitest_summary_table = nil
18
+ @all_annotations = []
19
+ end
20
+
21
+ def write_step_summary(msg)
22
+ puts msg
23
+ if !ENV['GITHUB_STEP_SUMMARY'].nil?
24
+ File.write(ENV['GITHUB_STEP_SUMMARY'], "#{msg}\n", mode: 'a+')
25
+ end
26
+ end
27
+
28
+ def hash_to_markdown(h, header0, header1)
29
+ n0 = [h.keys.map(&:to_s).map(&:size).max, header0.size].max
30
+ n1 = [h.values.map(&:to_s).map(&:size).max, header1.size].max
31
+
32
+ content = [
33
+ "| #{header0.ljust(n0)} | #{header1.ljust(n1)} |",
34
+ "| " + "-" * n0 + " | " + "-" * n1 + " |",
35
+ ] + h.map{|k, v| "| #{k.ljust(n0)} | #{v.to_s.ljust(n1)} |"}
36
+ return content.join("\n")
37
+ end
38
+
39
+ def make_minitest_step_summary_table
40
+
41
+ write_step_summary("## Minitest")
42
+ write_step_summary("")
43
+
44
+ total_tests = @hash['minitest']['total_tests']
45
+ total_assertions = @hash['minitest']['total_assertions']
46
+ total_errors = @hash['minitest']['total_errors']
47
+ total_failures = @hash['minitest']['total_failures']
48
+ total_skipped = @hash['minitest']['total_skipped']
49
+ total_compatibility_errors = @hash['minitest']['total_compatibility_errors']
50
+ total_load_errors = @hash['minitest'].fetch('total_load_errors', []).count
51
+
52
+ passed = total_tests - (total_failures + total_errors + total_skipped)
53
+ pct = passed.to_f / (total_tests - total_skipped).to_f
54
+
55
+ h = {
56
+ 'Total Tests' => total_tests,
57
+ 'Load Error' => total_load_errors,
58
+ 'Passed' => passed,
59
+ 'Success Rate' => '%.2f%%' % (pct * 100.0),
60
+ 'Failures' => total_failures,
61
+ 'Errors' => total_errors,
62
+ 'Skipped' => total_skipped,
63
+ 'Incompatible' => total_compatibility_errors,
64
+ 'Total Assertions' => total_assertions,
65
+ }
66
+
67
+ @minitest_summary_table = hash_to_markdown(h, "Metric", "Value")
68
+
69
+ write_step_summary(@minitest_summary_table)
70
+ write_step_summary("")
71
+ end
72
+
73
+ def make_minitest_annotations
74
+ @all_annotations = []
75
+
76
+ report_xmls = Dir["#{@test_results_directory}/minitest/reports/TEST-*.xml"]
77
+ report_xmls.each do |report_xml|
78
+ doc = REXML::Document.new(File.open(report_xml)).root
79
+ testsuite_element = doc.elements['testsuite']
80
+ filepath = testsuite_element.attributes['filepath']
81
+ testsuite_element.elements.each('testcase') do |testcase|
82
+ test_name = testcase.attributes['name']
83
+ line = testcase.attributes['lineno'].to_i
84
+ tested_class = testcase.attributes['classname']
85
+
86
+ testcase.elements.each('failure') do |x|
87
+ title = x.attributes['type']
88
+ message = x.attributes['message']
89
+ annot = "::error file=#{filepath},line=#{line},endLine=#{line + 1},title=#{title}::#{tested_class}.#{test_name}: #{message}"
90
+ @all_annotations << annot
91
+ end
92
+ testcase.elements.each('error') do |x|
93
+ title = x.attributes['type']
94
+ message = x.attributes['message']
95
+ annot = "::error file=#{filepath},line=#{line},endLine=#{line + 1},title=#{title}::#{message}"
96
+ @all_annotations << annot
97
+ end
98
+ testcase.elements.each('skipped') do |x|
99
+ title = x.attributes['type']
100
+ message = x.attributes['message']
101
+ annot = "::warning file=#{filepath},line=#{line},endLine=#{line + 1},title=#{title}::#{message}"
102
+ @all_annotations << annot
103
+ end
104
+ end
105
+ end
106
+ @all_annotations.each { |a| puts a}
107
+ nil
108
+ end
109
+ end
110
+ end
@@ -27,7 +27,7 @@ module OpenStudioMeasureTester
27
27
  def setup_subtasks(name)
28
28
  namespace name do
29
29
  ####################################### Minitest and Coverage #######################################
30
- desc 'new test task'
30
+ desc 'Run Minitest and Coverage on Measures'
31
31
  task :test do
32
32
  runner = OpenStudioMeasureTester::Runner.new(Rake.application.original_dir)
33
33
  # Need to pass in the current directory because the results of minitest and coverage end up going into
@@ -90,7 +90,8 @@ module OpenStudioMeasureTester
90
90
  doc.elements.each('//checkstyle/file') do |rc_file|
91
91
  # Allow processing when the file is just the measure.rb
92
92
  if rc_file.attributes['name'] != 'measure.rb'
93
- if !rc_file.attributes['name'].include? measure_name
93
+ parts = rc_file.attributes['name'].split(File::SEPARATOR)
94
+ if !parts.include? measure_name
94
95
  next
95
96
  end
96
97
  end
@@ -32,6 +32,12 @@ module OpenStudioMeasureTester
32
32
  template.render
33
33
  end
34
34
 
35
+ def github_actions_report
36
+ gha_reporter = OpenStudioMeasureTester::GithubActionsReport.new(test_results_dir)
37
+ gha_reporter.make_minitest_step_summary_table
38
+ gha_reporter.make_minitest_annotations
39
+ end
40
+
35
41
  # Prepare the current directory and the root directory to remove old test results before running
36
42
  # the new tests
37
43
  #
@@ -67,8 +73,10 @@ module OpenStudioMeasureTester
67
73
  # copy over the .rubocop.yml file into the root directory of where this is running.
68
74
  shared_rubocop_file = File.expand_path('../../.rubocop.yml', File.dirname(__FILE__))
69
75
  dest_file = "#{File.expand_path(@base_dir)}/.rubocop.yml"
70
- if shared_rubocop_file != dest_file
76
+ if !File.exist?(dest_file)
71
77
  FileUtils.copy(shared_rubocop_file, dest_file)
78
+ elsif File.read(shared_rubocop_file) != File.read(dest_file)
79
+ puts "Using specific custom .rubocop.yml rather than the OpenStudio-measure-tester-gem's one"
72
80
  end
73
81
 
74
82
  puts "Current directory is #{@base_dir}"
@@ -96,6 +104,8 @@ module OpenStudioMeasureTester
96
104
  # call the create dashboard command now that we have results
97
105
  dashboard
98
106
 
107
+ github_actions_report if ENV["GITHUB_ACTIONS"]
108
+
99
109
  # return the results exit code
100
110
  return results.exit_code
101
111
  end
@@ -146,6 +156,9 @@ module OpenStudioMeasureTester
146
156
  # output_path: 'junk.xml',
147
157
  auto_correct: auto_correct,
148
158
  color: false,
159
+ # cf #76 - Because we pass a glob to the Runner.run, we must pass
160
+ # force_exclusion to respect the files excluded in the .rubocop.yml
161
+ force_exclusion: true,
149
162
  formatters: ['simple', ['RuboCop::Formatter::CheckstyleFormatter', rubocop_results_file]]
150
163
  }
151
164
 
@@ -6,5 +6,5 @@
6
6
  # *******************************************************************************
7
7
 
8
8
  module OpenStudioMeasureTester
9
- VERSION = '0.3.3'.freeze
9
+ VERSION = '0.4.0'.freeze
10
10
  end
@@ -11,6 +11,7 @@ require 'pp'
11
11
  require 'rexml/document'
12
12
  require 'minitest'
13
13
  require 'simplecov'
14
+ require 'json'
14
15
 
15
16
  begin
16
17
  require 'git'
@@ -36,6 +37,7 @@ require_relative 'openstudio_measure_tester/coverage'
36
37
  require_relative 'openstudio_measure_tester/rubocop_result'
37
38
  require_relative 'openstudio_measure_tester/openstudio_testing_result'
38
39
  require_relative 'openstudio_measure_tester/dashboard'
40
+ require_relative 'openstudio_measure_tester/github_actions_report'
39
41
  require_relative 'openstudio_measure_tester/runner'
40
42
 
41
43
  require_relative 'openstudio_measure_tester/rake_task'
@@ -27,18 +27,18 @@ Gem::Specification.new do |spec|
27
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
28
  spec.require_paths = ['lib']
29
29
 
30
- spec.required_ruby_version = '~> 2.7.0'
30
+ spec.required_ruby_version = '~> 3.2.2'
31
31
 
32
32
  spec.add_dependency 'git', '~> 1.12.0'
33
33
  spec.add_dependency 'minitest', '~> 5.14.0'
34
34
  spec.add_dependency 'minitest-reporters', '~> 1.4.2'
35
35
  spec.add_dependency 'rake', '~> 13.0'
36
36
  spec.add_dependency 'parser', '3.2.2.2'
37
- spec.add_dependency 'rubocop', '~> 1.15.0'
38
- spec.add_dependency 'rubocop-performance', '~> 1.11.3'
39
- spec.add_dependency 'rubocop-checkstyle_formatter', '~> 0.4.0'
40
- spec.add_dependency 'simplecov', '~> 0.18.2'
37
+ spec.add_dependency 'rubocop', '1.50'
38
+ spec.add_dependency 'rubocop-performance', '1.20.0'
39
+ spec.add_dependency 'rubocop-checkstyle_formatter', '0.6.0'
40
+ spec.add_dependency 'simplecov', '0.22.0'
41
41
 
42
- spec.add_development_dependency 'bundler', '>= 2.1.0'
42
+ spec.add_development_dependency 'bundler', '2.4.10'
43
43
  spec.add_development_dependency 'rspec', '~> 3.9'
44
44
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openstudio_measure_tester
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Long
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2024-02-19 00:00:00.000000000 Z
14
+ date: 2024-05-03 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: git
@@ -87,72 +87,72 @@ dependencies:
87
87
  name: rubocop
88
88
  requirement: !ruby/object:Gem::Requirement
89
89
  requirements:
90
- - - "~>"
90
+ - - '='
91
91
  - !ruby/object:Gem::Version
92
- version: 1.15.0
92
+ version: '1.50'
93
93
  type: :runtime
94
94
  prerelease: false
95
95
  version_requirements: !ruby/object:Gem::Requirement
96
96
  requirements:
97
- - - "~>"
97
+ - - '='
98
98
  - !ruby/object:Gem::Version
99
- version: 1.15.0
99
+ version: '1.50'
100
100
  - !ruby/object:Gem::Dependency
101
101
  name: rubocop-performance
102
102
  requirement: !ruby/object:Gem::Requirement
103
103
  requirements:
104
- - - "~>"
104
+ - - '='
105
105
  - !ruby/object:Gem::Version
106
- version: 1.11.3
106
+ version: 1.20.0
107
107
  type: :runtime
108
108
  prerelease: false
109
109
  version_requirements: !ruby/object:Gem::Requirement
110
110
  requirements:
111
- - - "~>"
111
+ - - '='
112
112
  - !ruby/object:Gem::Version
113
- version: 1.11.3
113
+ version: 1.20.0
114
114
  - !ruby/object:Gem::Dependency
115
115
  name: rubocop-checkstyle_formatter
116
116
  requirement: !ruby/object:Gem::Requirement
117
117
  requirements:
118
- - - "~>"
118
+ - - '='
119
119
  - !ruby/object:Gem::Version
120
- version: 0.4.0
120
+ version: 0.6.0
121
121
  type: :runtime
122
122
  prerelease: false
123
123
  version_requirements: !ruby/object:Gem::Requirement
124
124
  requirements:
125
- - - "~>"
125
+ - - '='
126
126
  - !ruby/object:Gem::Version
127
- version: 0.4.0
127
+ version: 0.6.0
128
128
  - !ruby/object:Gem::Dependency
129
129
  name: simplecov
130
130
  requirement: !ruby/object:Gem::Requirement
131
131
  requirements:
132
- - - "~>"
132
+ - - '='
133
133
  - !ruby/object:Gem::Version
134
- version: 0.18.2
134
+ version: 0.22.0
135
135
  type: :runtime
136
136
  prerelease: false
137
137
  version_requirements: !ruby/object:Gem::Requirement
138
138
  requirements:
139
- - - "~>"
139
+ - - '='
140
140
  - !ruby/object:Gem::Version
141
- version: 0.18.2
141
+ version: 0.22.0
142
142
  - !ruby/object:Gem::Dependency
143
143
  name: bundler
144
144
  requirement: !ruby/object:Gem::Requirement
145
145
  requirements:
146
- - - ">="
146
+ - - '='
147
147
  - !ruby/object:Gem::Version
148
- version: 2.1.0
148
+ version: 2.4.10
149
149
  type: :development
150
150
  prerelease: false
151
151
  version_requirements: !ruby/object:Gem::Requirement
152
152
  requirements:
153
- - - ">="
153
+ - - '='
154
154
  - !ruby/object:Gem::Version
155
- version: 2.1.0
155
+ version: 2.4.10
156
156
  - !ruby/object:Gem::Dependency
157
157
  name: rspec
158
158
  requirement: !ruby/object:Gem::Requirement
@@ -200,6 +200,7 @@ files:
200
200
  - lib/openstudio_measure_tester/core_ext.rb
201
201
  - lib/openstudio_measure_tester/coverage.rb
202
202
  - lib/openstudio_measure_tester/dashboard.rb
203
+ - lib/openstudio_measure_tester/github_actions_report.rb
203
204
  - lib/openstudio_measure_tester/minitest_result.rb
204
205
  - lib/openstudio_measure_tester/openstudio_style.rb
205
206
  - lib/openstudio_measure_tester/openstudio_testing_result.rb
@@ -214,7 +215,7 @@ licenses: []
214
215
  metadata:
215
216
  bug_tracker_uri: https://github.com/NREL/OpenStudio-measure-tester-gem/issues
216
217
  changelog_uri: https://github.com/NREL/OpenStudio-measure-tester-gem/blob/develop/CHANGELOG.md
217
- source_code_uri: https://github.com/NREL/OpenStudio-measure-tester-gem/tree/v0.3.3
218
+ source_code_uri: https://github.com/NREL/OpenStudio-measure-tester-gem/tree/v0.4.0
218
219
  post_install_message:
219
220
  rdoc_options: []
220
221
  require_paths:
@@ -223,14 +224,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
223
224
  requirements:
224
225
  - - "~>"
225
226
  - !ruby/object:Gem::Version
226
- version: 2.7.0
227
+ version: 3.2.2
227
228
  required_rubygems_version: !ruby/object:Gem::Requirement
228
229
  requirements:
229
230
  - - ">="
230
231
  - !ruby/object:Gem::Version
231
232
  version: '0'
232
233
  requirements: []
233
- rubygems_version: 3.1.4
234
+ rubygems_version: 3.4.10
234
235
  signing_key:
235
236
  specification_version: 4
236
237
  summary: Testing framework for OpenStudio measures