Skip to content

Commit 4e90ebe

Browse files
committed
fix unit test and add precommit check
1 parent 645f36c commit 4e90ebe

File tree

6 files changed

+96
-19
lines changed

6 files changed

+96
-19
lines changed

.github/workflows/ci.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,35 @@ on:
55
push:
66

77
jobs:
8+
pre-commit:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: actions/setup-python@v5
13+
with:
14+
python-version: '3.11'
15+
- name: Install Poetry
16+
uses: snok/install-poetry@v1
17+
with:
18+
version: latest
19+
virtualenvs-create: true
20+
virtualenvs-in-project: true
21+
- name: Load cached venv
22+
id: cached-poetry-dependencies
23+
uses: actions/cache@v4
24+
with:
25+
path: .venv
26+
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
27+
- name: Install dependencies
28+
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
29+
run: poetry install --no-interaction --no-root
30+
- name: Run pre-commit
31+
run: poetry run pre-commit run --all-files
32+
833
test:
934
runs-on: ubuntu-latest
1035
steps:
11-
- uses: actions/checkout@v2
36+
- uses: actions/checkout@v4
1237
- uses: ruby/setup-ruby@v1
1338
with:
1439
ruby-version: 2.7.2

.gitignore

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,51 @@
1-
.idea/
2-
.bundle
3-
build
4-
Gemfile.lock
5-
gems
6-
.bundle
1+
# Operating System
72
.DS_Store
3+
.DS_Store?
4+
._*
5+
.Spotlight-V100
6+
.Trashes
7+
ehthumbs.db
8+
Thumbs.db
9+
10+
# IDEs and Editors
11+
.idea/
12+
.vscode/
13+
*.swp
14+
*.swo
15+
*~
16+
17+
# Ruby
18+
.bundle/
819
.ruby-version
20+
gems/
21+
Gemfile.lock
22+
23+
# Python
924
.python-version
25+
.venv/
26+
*.egg-info/
27+
__pycache__/
28+
*.py[cod]
29+
*$py.class
30+
*.so
31+
32+
# Jupyter Notebooks
33+
.ipynb_checkpoints/
34+
*.ipynb
35+
36+
# Node.js
37+
node_modules/
38+
39+
# Build artifacts
40+
build/
41+
42+
# Project specific
1043
BuildingSync.xpr
1144
schema_documentation.csv
1245
geojson.xsd
13-
.venv
14-
*.egg-info
15-
.ipynb_checkpoints
46+
gbxml.xsd
47+
48+
# Backup files
1649
*.bak
17-
*.ipynb
18-
node_modules
50+
*.backup
51+
*.tmp

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
BuildingSync®, Copyright (c) 2015-2021, Alliance for Sustainable Energy, LLC, and other contributors.
1+
BuildingSync®, Copyright (c) 2015-2025, Alliance for Sustainable Energy, LLC, and other contributors.
22

33
All rights reserved.
44

spec/validation_spec.rb

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# *********************************************************************************************************
2-
# BuildingSync®, Copyright (c) 2015-2021, Alliance for Sustainable Energy, LLC, and other contributors.
2+
# BuildingSync®, Copyright (c) 2015-2025, Alliance for Sustainable Energy, LLC, and other contributors.
33
#
44
# All rights reserved.
55
#
@@ -46,14 +46,33 @@
4646

4747
GBXML_XSD_PATH = 'gbxml.xsd'
4848
GBXML_IMPORT_PATH = 'xs:schema/xs:import[@namespace = "http://www.gbxml.org/schema"]'
49-
if !File.file?(GBXML_XSD_PATH) then
49+
if !File.file?(GBXML_XSD_PATH) || File.size(GBXML_XSD_PATH) == 0 then
5050
imported_schema_locations = schema_doc.xpath(GBXML_IMPORT_PATH).collect { |nokogiri_xml_node|
5151
nokogiri_xml_node.attribute("schemaLocation").value
5252
}
5353
expect(imported_schema_locations.length).to eq 1
5454

55-
open(GBXML_XSD_PATH, 'wb') do |file|
56-
file << open(imported_schema_locations[0]).read
55+
begin
56+
puts "Downloading gbXML schema from: #{imported_schema_locations[0]}"
57+
File.open(GBXML_XSD_PATH, 'wb') do |file|
58+
file << URI.open(imported_schema_locations[0]).read
59+
end
60+
61+
# Verify the downloaded file is valid XML
62+
if File.size(GBXML_XSD_PATH) == 0
63+
raise "Downloaded file is empty"
64+
end
65+
66+
# Test parse the downloaded XSD to ensure it's valid
67+
Nokogiri::XML(File.read(GBXML_XSD_PATH)) do |config|
68+
config.strict
69+
end
70+
puts "Successfully downloaded and validated gbXML schema"
71+
rescue => e
72+
puts "Failed to download gbXML schema: #{e.message}"
73+
# Clean up empty or invalid file
74+
File.delete(GBXML_XSD_PATH) if File.exist?(GBXML_XSD_PATH)
75+
raise "Could not download valid gbXML schema from #{imported_schema_locations[0]}: #{e.message}"
5776
end
5877
end
5978
schema_doc.xpath(GBXML_IMPORT_PATH).collect { |nokogiri_xml_node|

src/change_log.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# *********************************************************************************************************
2-
# BuildingSync®, Copyright (c) 2015-2021, Alliance for Sustainable Energy, LLC, and other contributors.
2+
# BuildingSync®, Copyright (c) 2015-2025, Alliance for Sustainable Energy, LLC, and other contributors.
33
#
44
# All rights reserved.
55
#

src/data_dictionary.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# *********************************************************************************************************
2-
# BuildingSync®, Copyright (c) 2015-2021, Alliance for Sustainable Energy, LLC, and other contributors.
2+
# BuildingSync®, Copyright (c) 2015-2025, Alliance for Sustainable Energy, LLC, and other contributors.
33
#
44
# All rights reserved.
55
#

0 commit comments

Comments
 (0)