Skip to content
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
98 changes: 94 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,119 @@ name: Continuous Integration

on:
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]
push:
branches:
- "develop"
tags:
- '*'
schedule:
- cron: '0 7 * * *'
workflow_dispatch:

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

jobs:
tests:
name: Tests
unit:
name: unit
container: nrel/openstudio:3.10.0
runs-on: ubuntu-latest
timeout-minutes: 20
env:
LANG: C.UTF-8
LC_ALL: C.UTF-8
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Cache gems
uses: actions/cache@v4
with:
path: .bundle/install
key: gems-${{ runner.os }}-os3.10.0-${{ hashFiles('Gemfile.lock', '*.gemspec') }}
- name: Setup
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
gem install bundler -v 2.4.10
bundle config set --local path "$GITHUB_WORKSPACE/.bundle/install"
bundle install
- name: Run Unit Tests
run: bundle exec rspec spec/tests/unit --profile 10

changes:
name: detect changes
runs-on: ubuntu-latest
outputs:
code: ${{ steps.diff.outputs.code }}
steps:
- name: Checkout Code
if: github.event_name == 'pull_request'
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for non-documentation changes
id: diff
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
if [ "${{ github.event_name }}" != "pull_request" ]; then
echo "code=true" >> "$GITHUB_OUTPUT"
exit 0
fi
# Documentation-only paths; anything else counts as a code change.
code_files=$(git diff --name-only "$BASE_SHA"..."$HEAD_SHA" \
| grep -Ev '(\.md$|^docs/|^LICENSE)' || true)
if [ -n "$code_files" ]; then
echo "code=true" >> "$GITHUB_OUTPUT"
else
echo "code=false" >> "$GITHUB_OUTPUT"
fi

integration:
name: integration (shard ${{ matrix.shard }})
needs: changes
if: >-
needs.changes.outputs.code == 'true' &&
!contains(github.event.pull_request.labels.*.name, 'skip-integration')
container: nrel/openstudio:3.10.0
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
shard: [0, 1, 2, 3]
env:
LANG: C.UTF-8
LC_ALL: C.UTF-8
BOSS_SHARD: ${{ matrix.shard }}
BOSS_SHARDS: '4'
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Cache gems
uses: actions/cache@v4
with:
path: .bundle/install
key: gems-${{ runner.os }}-os3.10.0-${{ hashFiles('Gemfile.lock', '*.gemspec') }}
- name: Cache external measures
uses: actions/cache@v4
with:
path: vendor/external_measures
key: ext-measures-${{ hashFiles('config/external_measure_repos.yml') }}
- name: Setup
run: |
git config --global --add safe.directory '*'
gem install bundler -v 2.4.10
bundle config set --local path "$GITHUB_WORKSPACE/.bundle/install"
bundle install
bundle exec rake measures:install_external
- name: Run Tests
run: bundle exec rspec
- name: Run Integration Tests
run: bundle exec rspec spec/tests/integration --profile 10
- name: Upload output on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: integration-output-shard-${{ matrix.shard }}
path: spec/output
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ GEM
PLATFORMS
arm64-darwin-24
ruby
x64-mingw-ucrt

DEPENDENCIES
BOSS!
Expand Down
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,34 @@ bundle exec boss write_baseline_osw "spec/files/v2.7.0/L100_Audit-1.0.0.xml" -o

## Tests

To run the tests you can use the Rake task:
Integration tests need the external measures installed first:

```bash
bundle exec rake measures:install_external
```

Run the full suite (unit + all integration simulations):

```bash
bundle exec rake
```

Run only the fast unit tests:

```bash
bundle exec rspec spec/tests/unit
```

Run the integration smoke subset (2 simulations):

```bash
BOSS_SMOKE=1 bundle exec rspec spec/tests/integration
```

Run one shard of the full integration suite (here shard 0 of 4, as in CI):

```bash
BOSS_SHARD=0 BOSS_SHARDS=4 bundle exec rspec spec/tests/integration
```

In CI, unit tests run on every pull request. The full integration suite (4 parallel shards) also runs on every pull request, except documentation-only changes (`*.md`, `docs/`, `LICENSE`) or pull requests labeled `skip-integration`. It always runs on pushes to `develop`, tags, nightly, and on manual dispatch.
13 changes: 13 additions & 0 deletions spec/tests/integration/write_and_run_osws_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@
['Reference-PrimarySchool-L100-Audit.xml', ASHRAE90_1, nil, 'v2.7.0'],
]

# BOSS_SMOKE=1 runs a small representative subset (used on pull requests).
SMOKE_FILES = ['building_151.xml', 'example-smalloffice-level1.xml'].freeze
test_configs = test_configs.select { |config| SMOKE_FILES.include?(config[0]) } if ENV['BOSS_SMOKE'] == '1'

# BOSS_SHARD / BOSS_SHARDS split the fixtures across parallel CI jobs.
if ENV['BOSS_SHARDS']
shards = Integer(ENV['BOSS_SHARDS'])
shard = Integer(ENV.fetch('BOSS_SHARD', '0'))
raise ArgumentError, "BOSS_SHARD must be in 0...#{shards}" if shards < 1 || shard.negative? || shard >= shards

test_configs = test_configs.select.with_index { |_config, index| index % shards == shard }
end

RSpec.describe 'BOSS' do
describe 'boss should' do
before do
Expand Down
Loading