Repository navigation
Speed up CI: split unit and integration tests, shard simulations, add caching #12
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Why
The Tests job in .github/workflows/ci.yml takes about 1h15m to 1h30m on every run, including PRs that don't touch simulation code.
Past develop runs:
| Date | Duration |
|---|---|
| Jun 25 | 1h 18m |
| Jul 14 | 1h 20m |
| Aug 11 | 55m |
| Aug 17 | 1h 27m |
PR #10 only adds a JSON-parsing unit spec, and its run was still going after 1h20m. This slows review, delays merges, and wastes runner time.
Cause
spec/tests/integration/write_and_run_osws_spec.rbwrites and runs a full baseline workflow for about 20 BuildingSync fixtures, one after another. Each run builds a model with openstudio-standards, sizes it, and runs a full-year EnergyPlus simulation.- All specs run as one job (
bundle exec rspec), so every PR waits for every simulation. - Setup repeats work on each run:
bundle installhas no cache, andrake measures:install_externalre-clonescomstockatmain. - There is no
concurrency:group, so pushing again to a PR doesn't cancel the run already in progress. - Several fixtures overlap and probably add little coverage:
Example_ASHRAE_L2_Report_-_with_Energy_Use_Dataand its_2variantL100_Audit-1.0.0andL100_Audit-1.0.0_and_BSyncr-1.0.0- the two
Example_NYC_Energy_Efficiency_Report_Propertyfiles
Proposed changes
- Split the workflow into two jobs.
unitrunsbundle exec rspec spec/tests/uniton every PR.integrationrunsspec/tests/integrationon pushes todevelop, on a nightly schedule, and on manual dispatch. PRs can opt in with a label such asrun-integration.
- Run a smoke subset on PRs. Run 2-3 fixtures (for example
building_151.xmlandexample-smalloffice-level1.xml) so PRs still get a real write-and-run check. - Shard the full integration run. Use a job matrix of 4-5 shards. The spec filters its fixture list by
BOSS_SHARDandBOSS_SHARDS, so each job runs a share of the files in parallel. - Cache dependencies.
- Cache
.bundle/install, keyed onGemfile.lock. - Cache the external measure checkout, keyed on the pinned
ref. - Pin
comstockto a tag or commit instead ofmainfor reproducibility.
- Cache
- Cancel stale runs. Add
concurrency: { group: ci-${{ github.ref }}, cancel-in-progress: true }. - Remove redundant fixtures from the simulation list, or keep them as parse-only checks in the unit specs.
- Report the slowest tests. Run rspec with
--profile 10so test duration is visible in CI logs.
Sketch
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
unit:
# same container + setup
steps:
- run: bundle exec rspec spec/tests/unit
integration:
if: github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'run-integration')
strategy:
matrix:
shard: [0, 1, 2, 3]
env:
BOSS_SHARD: ${{ matrix.shard }}
BOSS_SHARDS: 4
steps:
- run: bundle exec rspec spec/tests/integrationAcceptance criteria
- PR feedback from the
unitjob (plus the smoke subset, if kept on PRs) arrives in under 10 minutes. - The full integration suite finishes in under 25 minutes on
developand nightly. - Total fixture coverage on
developis unchanged, apart from agreed removals. - A new push to a PR cancels the previous run.
- The README testing section documents how to run unit, smoke and full integration locally.
Out of scope
- Changing what the integration tests assert.
- Changing simulation or baseline workflow behavior.
- Fixing the known
BuildingEQ-1.0.0_gemtest.xmlsizing failure, which is already commented out in the spec.
Notes
- Branch protection: if
Testsis a required check, update it to the new job names (unit, andintegrationif it should be required). - If the nightly schedule is used, make sure failures notify someone, so full-suite regressions aren't found late.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Activity