Skip to content

Commit

Permalink
Merge pull request #153 from NREL/add_gha_ci
Browse files Browse the repository at this point in the history
Add GHA CI to run tests with OpenStudio 3.8.0 beta and Ruby 3.2.2
  • Loading branch information
kflemin authored Apr 19, 2024
2 parents d9f87b8 + 1fbf9c7 commit 32126e9
Show file tree
Hide file tree
Showing 116 changed files with 4,865 additions and 5,016 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Test workflow gem

# trigger action on all branches, pull requests and tags
on:
pull_request:
branches:
- '*'
push:
branches:
- '*'
tags:
- '*'

env:
TEST_WITH_OPENSTUDIO: true

jobs:
test:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4

- name: install openstudio
run: |
wget http://openstudio-ci-builds.s3-website-us-west-2.amazonaws.com/PR-5149/OpenStudio-3.8.0-beta%2B2bc25028a3-Ubuntu-22.04-x86_64.deb
sudo apt-get -qq install -y ./OpenStudio*.deb
rm -Rf ./OpenStudio*.deb
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2.2' # Not needed with a .ruby-version file
bundler: '2.5.5'
bundler-cache: true # runs 'bundle install' and caches installed gems automatically. We should NOT change the Bundler path, because to perform caching, this action will use bundle config --local path $PWD/vendor/bundle.
env:
RUBYLIB: /usr/local/openstudio-3.8.0/Ruby

- name: show enviroment
shell: bash
run: |
begin_group() { echo -e "::group::\033[93m$1\033[0m"; }
begin_group "Ruby and bundler"
echo "Ruby version"
ruby -v
echo "Bundle version"
bundle --version
echo "bundle config get path"
bundle config get path
echo "bundle list"
bundle list
echo "::endgroup::"
begin_group "OpenStudio"
which openstudio
ls -la $(which openstudio)
os_cli=$(readlink -f $(which openstudio))
os_root=$(dirname $(dirname $os_cli))
openstudio --version
openstudio gem_list
echo "::endgroup::"
begin_group "System ruby is connected to openstudio"
# Don't rely on RUBYLIB env var
f=$(ruby -e "puts File.join(RbConfig::CONFIG['sitelibdir'], 'openstudio.rb')")
echo "require '$os_root/Ruby/openstudio.rb'" > $f
ruby -e "require 'openstudio'; puts OpenStudio::openStudioLongVersion"
echo "::endgroup::"
- name: test
shell: bash
run: |
bundle exec rake spec:unit
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ source 'http://rubygems.org'
# Specify your gem's dependencies in OpenStudio-workflow.gemspec
gemspec

gem 'openstudio_measure_tester', '~> 0.4.0', :github => 'NREL/OpenStudio-measure-tester-gem', :ref => '1baa9e70254a0cdb6740ccf14052baada8cf9e1c'

group :test do
gem 'coveralls', require: false
end
2 changes: 1 addition & 1 deletion lib/openstudio/workflow/registry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def keys

# Return the number of elements in this registry
#
# @return [Fixnum]
# @return [Integer]
#
def length
@items.keys.length
Expand Down
3 changes: 2 additions & 1 deletion lib/openstudio/workflow/util/energyplus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,8 @@ def self.monthly_report_idf_text
WaterSystems:DistrictCooling, !- Variable or Meter Name 13
ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 13
Cogeneration:DistrictCooling, !- Variable or Meter Name 14
ValueWhenMaximumOrMinimum; !- Aggregation Type for Variable or Meter 14 HEREDOC
ValueWhenMaximumOrMinimum; !- Aggregation Type for Variable or Meter 14
HEREDOC
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/openstudio/workflow/util/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,8 @@ def apply_measure(registry, step, options = {}, energyplus_output_requests = fal
result = nil
begin
load measure_path.to_s
# load.c in ruby can result in changing dir to root / so preserve cwd here. happens in openstudio cli
Dir.chdir measure_run_dir
# load.c in ruby can result in changing dir to root / so preserve cwd here. happens in openstudio cli
Dir.chdir measure_run_dir
measure_object = Object.const_get(class_name).new
rescue => e

Expand Down Expand Up @@ -382,7 +382,7 @@ def apply_measure(registry, step, options = {}, energyplus_output_requests = fal
else
skip_measure = true
end
elsif argument_value.class == Fixnum
elsif argument_value.class == Integer
skip_measure = (argument_value != 0)
elsif argument_value.class == Float
skip_measure = (argument_value != 0.0)
Expand Down
4 changes: 2 additions & 2 deletions openstudio-workflow.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ Gem::Specification.new do |s|
s.required_ruby_version = '~> 3.2.2'

s.add_development_dependency 'builder', '~> 3.2.4'
s.add_development_dependency 'bundler', '>= 2.5.5'
s.add_development_dependency 'ci_reporter', '~> 2.0.0'
s.add_development_dependency 'bundler', '2.4.10'
s.add_development_dependency 'ci_reporter', '~> 2.1.0'
s.add_development_dependency 'ci_reporter_rspec', '~> 1.0.0'
s.add_development_dependency 'coveralls', '~> 0.8.21'
s.add_development_dependency 'json-schema', '~> 2.8.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@ def run(runner, user_arguments)
end

# determine how to format time series output
msgpack_flag = FALSE
csv_flag = FALSE
msgpack_flag = false
csv_flag = false
if output_format == "MessagePack" || output_format == "Both"
msgpack_flag = TRUE
msgpack_flag = true
end
if output_format == "CSV" || output_format == "Both"
csv_flag = TRUE
csv_flag = true
end

# get the last model and sql file
Expand Down Expand Up @@ -426,7 +426,7 @@ def run(runner, user_arguments)
#todo: find a way for the sql call to not rely on RUN PERIOD 1
timeseries_start = Time.now.to_i
available_meters = sql_file.execAndReturnVectorOfString("SELECT VariableName FROM ReportMeterDataDictionary WHERE VariableType='Sum' AND ReportingFrequency='Hourly'")
get_timeseries_flag = TRUE
get_timeseries_flag = true
if available_meters.empty?
runner.registerWarning("No meters found with Hourly reporting frequency to extract timeseries data from")
else
Expand All @@ -435,19 +435,19 @@ def run(runner, user_arguments)
runner.registerInfo("The following meters were found: #{meter_strings}")
rescue
runner.registerWarning("Unable to retrieve timeseries strings")
get_timeseries_flag = FALSE
get_timeseries_flag = false
end
meter_units = sql_file.execAndReturnVectorOfString("SELECT VariableUnits FROM ReportMeterDataDictionary WHERE VariableType='Sum' AND ReportingFrequency='Hourly'")
begin
meter_units = meter_units.get
runner.registerInfo("Units were found for all available meters")
rescue
runner.registerWarning("Unable to retrieve timeseries unit strings")
get_timeseries_flag = FALSE
get_timeseries_flag = false
end
runner.registerInfo("The following meter units were found: #{meter_units}")
runner.registerError("Timeseries variable names and units of differing lengths. Exiting Dencity Reports.") if meter_units.size != meter_strings.size
get_timeseries_flag = FALSE if meter_units.size != meter_strings.size
get_timeseries_flag = false if meter_units.size != meter_strings.size
end

runner.registerInfo("get_timeseries_flag is set to #{get_timeseries_flag}")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?xml version="1.0"?>
<measure>
<schema_version>3.0</schema_version>
<schema_version>3.1</schema_version>
<name>dencity_reports</name>
<uid>4f939be0-fe1c-11e3-a3ac-0800200c9a66</uid>
<version_id>5dbbecc1-55ab-4113-8c8b-dca006df2d53</version_id>
<version_id>eecc76fb-4203-4b8f-9ac1-108902247fe9</version_id>
<version_modified>2024-04-19T12:01:27Z</version_modified>
<xml_checksum>2C8A3EEF</xml_checksum>
<class_name>DencityReports</class_name>
<display_name>Dencity Reports</display_name>
Expand Down Expand Up @@ -32,7 +34,8 @@
</choices>
</argument>
</arguments>
<provenances/>
<outputs />
<provenances />
<tags>
<tag>Reporting.QAQC</tag>
</tags>
Expand All @@ -58,7 +61,7 @@
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>CAD52B50</checksum>
<checksum>28BF01F7</checksum>
</file>
</files>
</measure>
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?xml version="1.0"?>
<measure>
<schema_version>3.0</schema_version>
<schema_version>3.1</schema_version>
<name>increase_insulation_r_value_for_roofs_by_percentage</name>
<uid>807d3ebf-c89b-4b93-b400-110ca060b2bb</uid>
<version_id>2704be33-ea98-4896-a378-875b8af786f9</version_id>
<version_id>49c11c00-11f6-41b9-a740-967e634ec258</version_id>
<version_modified>2024-04-19T12:12:09Z</version_modified>
<xml_checksum>EB1A0C08</xml_checksum>
<class_name>IncreaseInsulationRValueForRoofsByPercentage</class_name>
<display_name>Increase R-value of Insulation for Roofs by a Specified Percentage.</display_name>
Expand All @@ -18,7 +20,8 @@
<default_value>30</default_value>
</argument>
</arguments>
<provenances/>
<outputs />
<provenances />
<tags>
<tag>Envelope.Opaque</tag>
</tags>
Expand All @@ -45,18 +48,6 @@
</attribute>
</attributes>
<files>
<file>
<filename>EnvelopeAndLoadTestModel_01.osm</filename>
<filetype>osm</filetype>
<usage_type>test</usage_type>
<checksum>10AA8866</checksum>
</file>
<file>
<filename>ReverseTranslatedModel.osm</filename>
<filetype>osm</filetype>
<usage_type>test</usage_type>
<checksum>0B94403D</checksum>
</file>
<file>
<version>
<software_program>OpenStudio</software_program>
Expand All @@ -68,11 +59,5 @@
<usage_type>script</usage_type>
<checksum>DC927612</checksum>
</file>
<file>
<filename>IncreaseInsulationRValueForRoofs_Test.rb</filename>
<filetype>rb</filetype>
<usage_type>test</usage_type>
<checksum>05883904</checksum>
</file>
</files>
</measure>
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?xml version="1.0"?>
<measure>
<schema_version>3.0</schema_version>
<schema_version>3.1</schema_version>
<name>increase_insulation_r_value_for_exterior_walls_by_percentage</name>
<uid>7508c563-22bd-49f4-b646-aac69b02a82d</uid>
<version_id>9dcca162-642a-4a06-a98a-3c9a5567a2b4</version_id>
<version_id>96db8cac-8b42-414f-b2c1-4e32db33828a</version_id>
<version_modified>2024-04-19T12:12:11Z</version_modified>
<xml_checksum>EB1A0C08</xml_checksum>
<class_name>IncreaseInsulationRValueForExteriorWallsByPercentage</class_name>
<display_name>Increase R-value of Insulation for Exterior Walls By a Specified Percentage</display_name>
Expand All @@ -18,7 +20,8 @@
<default_value>30</default_value>
</argument>
</arguments>
<provenances/>
<outputs />
<provenances />
<tags>
<tag>Envelope.Opaque</tag>
</tags>
Expand All @@ -45,18 +48,6 @@
</attribute>
</attributes>
<files>
<file>
<filename>EnvelopeAndLoadTestModel_01.osm</filename>
<filetype>osm</filetype>
<usage_type>test</usage_type>
<checksum>10AA8866</checksum>
</file>
<file>
<filename>ReverseTranslatedModel.osm</filename>
<filetype>osm</filetype>
<usage_type>test</usage_type>
<checksum>0B94403D</checksum>
</file>
<file>
<version>
<software_program>OpenStudio</software_program>
Expand All @@ -68,11 +59,5 @@
<usage_type>script</usage_type>
<checksum>2B0F0D0D</checksum>
</file>
<file>
<filename>IncreaseInsulationRValueForExteriorWalls_Test.rb</filename>
<filetype>rb</filetype>
<usage_type>test</usage_type>
<checksum>9D91D252</checksum>
</file>
</files>
</measure>
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
<?xml version="1.0"?>
<measure>
<schema_version>3.0</schema_version>
<name>Set EnergyPlus Infiltration Flow Rate Per Floor Area</name>
<schema_version>3.1</schema_version>
<name>set_energyplus_infiltration_flow_rate_per_floor_area</name>
<uid>490a2af3-7b64-4915-bf9e-9a3a7b525a17</uid>
<version_id>22c341d1-64e2-486d-a430-f30d3c6f9ad4</version_id>
<version_id>f4f53827-f035-4d75-9bfb-d021dddcbc1c</version_id>
<version_modified>2024-04-19T12:12:11Z</version_modified>
<xml_checksum>2AC0F979</xml_checksum>
<class_name>SetEnergyPlusInfiltrationFlowRatePerFloorArea</class_name>
<display_name>Set EnergyPlus Infiltration Flow Rate Per Floor Area</display_name>
<display_name>SetEnergyPlusInfiltrationFlowRatePerFloorArea</display_name>
<description>Set the flow rate per floor area value for all infiltration objects in the model. Input values are in SI units.</description>
<modeler_description>Affected infiltration objects will have "Design Flor Rate Calculation Method" set to "Flow/Area" and the "Flow per Zone Floor Area" set to the requested SI value.</modeler_description>
<arguments/>
<provenances/>
<arguments>
<argument>
<name>flowPerZoneFloorArea</name>
<display_name>Flow per Zone Floor Area (m^3/s-m^2).</display_name>
<type>Double</type>
<required>true</required>
<model_dependent>false</model_dependent>
</argument>
</arguments>
<outputs />
<provenances />
<tags>
<tag>Envelope.Infiltration</tag>
</tags>
Expand Down Expand Up @@ -37,17 +48,5 @@
<usage_type>script</usage_type>
<checksum>4BCA3C57</checksum>
</file>
<file>
<filename>Test.osm</filename>
<filetype>osm</filetype>
<usage_type>test</usage_type>
<checksum>BCF2DBB8</checksum>
</file>
<file>
<filename>SetEnergyPlusInfiltrationFlowRatePerFloorArea_Test.rb</filename>
<filetype>rb</filetype>
<usage_type>test</usage_type>
<checksum>F47EC348</checksum>
</file>
</files>
</measure>
Loading

0 comments on commit 32126e9

Please sign in to comment.