Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial ComStock CI #90

Merged
merged 4 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Author pull request checklist:
- [ ] Changes reflected in example `.yml` files
- [ ] Changes reflected in `README.md` files
- [ ] Added 'See ComStock License' language to first two lines of each code file
- [ ] Implements corresponding measure tests and indexing path in `test/measure_tests.txt` or/and `test/resource_measure_tests.txt`
- [ ] All new and existing tests pass the CI

### Review Checklist
Expand All @@ -41,6 +42,7 @@ This will not be exhaustively relevant to every PR.
- [ ] Reviewed change documentation
- [ ] Ensured code files contain License reference
- [ ] Results differences are reasonable
- [ ] Make sure the newly added measures has been added with tests and indexed properly
- [ ] CI status: all tests pass

#### ComStock Licensing Language - Add to Beginning of Each Code File
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ lib/
/sampling/output-buildstocks
/sampling/truth_data
*.pyc
report.xml
9 changes: 9 additions & 0 deletions Jenkinsfile_main_develop
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/groovy

@Library('cbci_shared_libs@develop') _
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep it as develop for now, once we are getting used to it remove the @develop branch tag.



// Build for PR to main branch only.
if ((env.CHANGE_ID) && (env.CHANGE_TARGET) ) {
building_comstock_all()
}
39 changes: 39 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
require 'rake'
require 'rake/testtask'
require 'minitest/reporters' # Require the gem

# Configure the JUnit reporter

desc 'Perform tasks related to unit tests'
namespace :unit_tests do
desc 'Run measure tests'
Rake::TestTask.new('measure_tests') do |t|
MEASURETESTS_PATH = "test/measure_tests.txt"
if File.exist?(MEASURETESTS_PATH)
# load test files from file.
full_file_list = FileList.new(File.readlines(MEASURETESTS_PATH).map(&:chomp))
full_file_list.select! { |item| item.include?('rb')}
p full_file_list

end
t.test_files = full_file_list
p(full_file_list)
t.verbose = false
t.warning = false
end

Rake::TestTask.new('resource_measure_tests') do |t|
RESOURCE_MEASURETESTS_PATH = "test/resource_measure_tests.txt"
if File.exist?(RESOURCE_MEASURETESTS_PATH)
# load test files from file.
full_file_list = FileList.new(File.readlines(RESOURCE_MEASURETESTS_PATH).map(&:chomp))
full_file_list.select! { |item| item.include?('rb')}
p full_file_list
end
t.test_files = full_file_list
p(full_file_list)
t.verbose = false
t.warning = false
end

end
2 changes: 2 additions & 0 deletions measures/TimeseriesCSVExport/tests/Measure_Test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
require 'open3'

require_relative '../measure.rb'
require_relative '../../../test/helpers/minitest_helper'

require 'minitest/autorun'

class TimeseriesCSVExport_Test < Minitest::Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
require 'minitest/autorun'
require_relative '../measure.rb'
require 'fileutils'
require_relative '../../../test/helpers/minitest_helper'

class ComStockSensitivityReportsTest < Minitest::Test
def run_dir(test_name)
Expand Down Expand Up @@ -150,7 +151,7 @@ def run_test(test_name, osm_path, epw_path)
values << value.string
end
File.write(run_dir(test_name)+"/output.txt", "[\n#{values.join(',').strip}\n]")

assert_equal('Success', result.value.valueName)

# change back directory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
require_relative '../measure.rb'
require 'fileutils'
require 'openstudio-standards'
require_relative '../../../test/helpers/minitest_helper'

class EmissionsReporting_Test < Minitest::Test
def test_number_of_arguments_and_argument_names
Expand Down Expand Up @@ -113,7 +114,7 @@ def print_column_definitions(result_h)

end
result_string << ",TRUE,TRUE,float,co2e_kg,co2e_kg"
case
case
when captures[2].include?('egrid')
result_string << ",\"annual greehouse gas emissions from #{captures[0].gsub("_"," ")} #{captures[1].gsub("_"," ")} use, using #{captures[2].gsub("_"," ")} emissions intensity\""
when captures[2].include?('aer')
Expand Down
1 change: 1 addition & 0 deletions measures/la_100_qaqc/tests/measure_Test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
require "#{File.dirname(__FILE__)}/../measure.rb"
require 'fileutils'
require 'minitest/autorun'
require_relative '../../../test/helpers/minitest_helper'

class LA100QAQC_Test < Minitest::Test
def is_openstudio_2?
Expand Down
4 changes: 3 additions & 1 deletion measures/qoi_report/tests/qoi_report_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@
require_relative '../measure.rb'
require 'fileutils'
require 'openstudio-standards'
require "minitest/reporters"
require_relative '../../../test/helpers/minitest_helper'

class QOIReportTest < MiniTest::Test
class QOIReportTest < Minitest::Test
def run_dir(test_name)
# always generate test output in specially named 'output' directory so result files are not made part of the measure
return "#{File.dirname(__FILE__)}/output/#{test_name}"
Expand Down
1 change: 1 addition & 0 deletions measures/scout_loads_summary/tests/Measure_Test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
require 'open3'

require_relative '../measure.rb'
require_relative '../../../test/helpers/minitest_helper'

require 'fileutils'

Expand Down
1 change: 1 addition & 0 deletions measures/simulation_settings_check/tests/measure_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
require 'openstudio/measure/ShowRunnerOutput'
require 'minitest/autorun'

require_relative '../../../test/helpers/minitest_helper'
require_relative '../measure.rb'

require 'fileutils'
Expand Down
6 changes: 5 additions & 1 deletion resources/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ group :native_ext do
# gem 'cbor', '0.5.9.6' # Cbor will require a ton of patching, so disabling it in favor of msgpack (cbor is a fork of msgpack anyways)
gem 'msgpack', '1.4.2'
end
group :test do
gem 'minitest-reporters', '= 1.4.2'
gem 'minitest-junit', '= 1.1.0'
end

# leave this line in for now as we may try to get nokogiri to compile correctly on windows
# gem 'nokogiri', '= 1.11.0.rc1.20200331222433', :github => 'jmarrec/nokogiri', :ref => 'MSVC_support' # master of 2020-03-31 + gemspec commit
# gem 'nokogiri', '= 1.11.0.rc1.20200331222433', :github => 'jmarrec/nokogiri', :ref => 'MSVC_support' # master of 2020-03-31 + gemspec commit
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

require 'openstudio'
require 'openstudio/measure/ShowRunnerOutput'
require_relative '../../../../test/helpers/minitest_helper'
require 'fileutils'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is missing require 'minitest/autorun', which is in the other measure test files. I think since minitest_helper.rb contains require 'minitest/autorun' it should be fine.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I set all the test related library imported and configurations in the minitest_helper to keep it simper.


require_relative '../measure.rb'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
require 'fileutils'
require 'minitest/autorun'
require_relative '../measure.rb'
require_relative '../../../../test/helpers/minitest_helper'

class Test_AddBlindsToSelectedWindows < Minitest::Test

Expand Down Expand Up @@ -181,4 +182,4 @@ def test_OfL_blinds
run_test(test_name, osm_path, epw_path, blinds_expected)
end

end
end
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
require 'openstudio/measure/ShowRunnerOutput'
require 'minitest/autorun'
require_relative '../measure.rb'
require_relative '../../../../test/helpers/minitest_helper'
require 'fileutils'

class AddHvacNighttimeOperationVariabilityTest < Minitest::Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

require 'openstudio'
require 'openstudio/measure/ShowRunnerOutput'
require_relative '../../../../test/helpers/minitest_helper'
require 'minitest/autorun'
require_relative '../measure.rb'
require 'fileutils'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

require 'openstudio'
require 'openstudio/ruleset/ShowRunnerOutput'
require_relative '../../../../test/helpers/minitest_helper'
require 'minitest/autorun'
require_relative '../measure.rb'
require 'fileutils'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

require 'openstudio'
require 'openstudio/ruleset/ShowRunnerOutput'
require_relative '../../../../test/helpers/minitest_helper'
require 'minitest/autorun'
require_relative '../measure.rb'
require 'fileutils'
Expand Down
1 change: 1 addition & 0 deletions resources/measures/hardsize_model/tests/measure_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
require 'fileutils'
require 'minitest/autorun'
require_relative '../measure.rb'
require_relative '../../../../test/helpers/minitest_helper'

class HardsizeModelTest < Minitest::Test

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require 'openstudio/ruleset/ShowRunnerOutput'
require 'minitest/autorun'
require_relative '../measure.rb'
require_relative '../../../../test/helpers/minitest_helper'
require 'fileutils'

class PrototypeSpaceTypeAssignmentTest < MiniTest::Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
require 'openstudio/measure/ShowRunnerOutput'
require 'fileutils'
require 'minitest/autorun'
require_relative '../../../../test/helpers/minitest_helper'
require_relative '../measure.rb'

class ReplaceBaselineWindowsTest < Minitest::Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
require 'fileutils'
require 'minitest/autorun'
require_relative '../measure.rb'
require_relative '../../../../test/helpers/minitest_helper'

# only necessary to include here if annual simulation request and the measure doesn't require openstudio-standards
require 'openstudio-standards'
Expand Down Expand Up @@ -657,4 +658,4 @@ def test_full_service_restaurant_co
end
end

end
end
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
require 'minitest/autorun'
require_relative '../measure.rb'
require 'fileutils'
require_relative '../../../../test/helpers/minitest_helper'

class SetExteriorLightingTemplateTest < Minitest::Test
def test_same_template
Expand Down
1 change: 1 addition & 0 deletions resources/measures/set_heating_fuel/tests/measure_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
require 'openstudio/measure/ShowRunnerOutput'
require 'minitest/autorun'
require_relative '../measure.rb'
require_relative '../../../../test/helpers/minitest_helper'
require 'fileutils'

class MeasureTest < Minitest::Test
Expand Down
1 change: 1 addition & 0 deletions resources/measures/set_hvac_template/tests/measure_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
require 'openstudio'
require 'openstudio/measure/ShowRunnerOutput'
require 'minitest/autorun'
require_relative '../../../../test/helpers/minitest_helper'
require_relative '../measure.rb'
require 'fileutils'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
require 'openstudio'
require 'openstudio/measure/ShowRunnerOutput'
require 'minitest/autorun'
require_relative '../../../../test/helpers/minitest_helper'
require_relative '../measure.rb'
require 'fileutils'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
require 'fileutils'
require 'minitest/autorun'
require_relative '../measure.rb'
require_relative '../../../../test/helpers/minitest_helper'

# only necessary to include here if annual simulation request and the measure doesn't require openstudio-standards
require 'openstudio-standards'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require 'openstudio/ruleset/ShowRunnerOutput'
require 'minitest/autorun'
require_relative '../measure.rb'
require_relative '../../../../test/helpers/minitest_helper'
require 'fileutils'

class SetInteriorLightingTechnologyTest < MiniTest::Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
require 'openstudio'
require 'openstudio/measure/ShowRunnerOutput'
require 'minitest/autorun'
require_relative '../../../../test/helpers/minitest_helper'
require_relative '../measure.rb'
require 'fileutils'

Expand Down Expand Up @@ -99,7 +100,7 @@ def test_bad_airtightness_value

# make an empty model
model = OpenStudio::Model::Model.new

# create hash of argument values
args_hash = {}
args_hash['airtightness_value'] = -1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
require 'openstudio'
require 'openstudio/measure/ShowRunnerOutput'
require 'minitest/autorun'
require_relative '../../../../test/helpers/minitest_helper'
require_relative '../measure.rb'
require 'fileutils'

Expand Down
1 change: 1 addition & 0 deletions resources/measures/set_roof_template/tests/measure_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
require 'minitest/autorun'
require_relative '../measure.rb'
require 'fileutils'
require_relative '../../../../test/helpers/minitest_helper'

class SetRoofTemplateTest < Minitest::Test
def test_same_template
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
require 'openstudio/measure/ShowRunnerOutput'
require 'minitest/autorun'
require_relative '../measure.rb'
require_relative '../../../../test/helpers/minitest_helper'
require 'fileutils'

class MeasureTest < Minitest::Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
require 'minitest/autorun'
require_relative '../measure.rb'
require 'fileutils'
require_relative '../../../../test/helpers/minitest_helper'

class SetServiceWaterHeatingTemplateTest < Minitest::Test
def setup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
require 'openstudio/ruleset/ShowRunnerOutput'
require 'minitest/autorun'
require_relative '../measure.rb'
require_relative '../../../../test/helpers/minitest_helper'
require 'fileutils'

class SetSpaceTypeLoadSubcategoriesTest < MiniTest::Test
Expand Down
1 change: 1 addition & 0 deletions resources/measures/set_wall_template/tests/measure_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
require 'openstudio/measure/ShowRunnerOutput'
require 'minitest/autorun'
require_relative '../measure.rb'
require_relative '../../../../test/helpers/minitest_helper'
require 'fileutils'

class SetWallTemplateTest < Minitest::Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
require 'openstudio/measure/ShowRunnerOutput'
require 'minitest/autorun'
require_relative '../measure.rb'
require_relative '../../../../test/helpers/minitest_helper'
require 'fileutils'

class SimulationSettingsTest < Minitest::Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
require 'openstudio/measure/ShowRunnerOutput'
require 'fileutils'
require 'minitest/autorun'
require_relative '../../../../test/helpers/minitest_helper'
require_relative '../measure.rb'

class EnvStormWindowsTest < Minitest::Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
require 'fileutils'
require 'minitest/autorun'
require_relative '../measure.rb'
require_relative '../../../../test/helpers/minitest_helper'

class EnvRoofInsulAedgTest < Minitest::Test
# all tests are a sub definition of this class, e.g.:
Expand Down
Loading