Skip to content

Fix #5711 - Full Build CI: working ccache, faster configure/build/tests, simpler workflow - #5713

Merged
jmarrec merged 54 commits into
NatLabRockies:developfrom
jmarrec:develop
Nov 27, 2026
Merged

jmarrec merged 54 commits into
NatLabRockies:developfrom
jmarrec:develop

Conversation

@jmarrec

@jmarrec jmarrec commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Pull request overview

The Full Build workflow had caching that mostly didn't work: every run rebuilt almost everything, so a run took 1.5 to 3.5 hours per platform. This PR makes ccache actually hit on all platforms, removes a lot of wasted work and cruft from the workflow, and fixes the tests that couldn't run in parallel.

Caching (ccache)

  • ccache on every platform. Windows uses ccache instead of sccache. ccache is installed before its cache is restored.
  • ccache is keyed on the commit SHA (or the PR branch), with the base branch's SHA as a restore-key, and saved even when the build fails.
  • PCH-using translation units can hit the cache: the Clang PCH timestamp is disabled.
  • The build SHA is out of OpenStudio.hxx, which ~30 files include, so a new commit no longer invalidates them and every SWIG module.
  • The Conan cache is saved right after conan install instead of at the end of the job.
  • The external-deps and embedded-files caches are gone: they cost more to save and restore than they saved.

Cache allowance

NOTE: Our cache limit currently is just the free 10GB, and it is not nearly enough: any PR build would evict the develop caches currently.

It is cheap to increase it to say 100GB (about 6 USD/month) and it would be a shame not to.

  • Cache size: one full set of ccache caches is ~1.5 to 1.8 GB per platform, so ~10 GB for the six platforms: that's GitHub's free per-repository limit. A PR's caches therefore evict develop's. Raising the limit costs $0.07 / GB / month (e.g. ~$6 / month for 100 GB) , see the changelog.

@DavidGoldwasser @anchapin @tijcolem if one of you can make this request please

Faster configure and build (embedded files)

  • embed_files() iterates with ZIP_LISTS instead of list(GET ... i), which was quadratic: CMake configure is 3x faster (37 s → 10 s locally).
  • The ~6600 embedded files are generated with one command per embed_files() call (multi-threaded), instead of one process per file: ~6600 fewer build steps (9595 → 3005), and the ninja progress is meaningful again.
  • New embedded_files targets (ninja embedded_files, or ninja embedded_files_ruby_engine...).
  • Everything is configured and built with the conanfile.py presets, as in BUILDING.md: cmake --preset conan-release and cmake --build --preset conan-release. The number of jobs comes from the preset, i.e. the runner's cores (macOS x64 was using 3 of its 4).

Tests

  • All tests run in parallel: there's no more separate pass for "resource locked" tests. Three kinds of tests that weren't safe in parallel are fixed:
    • Tests that copy external files (ScheduleFile, PythonPluginInstance, ChillerElectricASHRAE205...) now use a directory unique to each test.
    • The gbXML tests write each test's output to its own file.
    • MeasureFixture no longer wipes the shared scratch directory for every test.
  • The rerun of failed tests no longer overwrites the full results: ctest --output-junit writes Testing/Results.xml, and Testing/Rerun.xml for the rerun.
  • A "Flaky tests" warning annotation lists the tests that failed and then passed on rerun, so tests that aren't safe in parallel get noticed.
  • [skip tests] in the commit message skips the CTest steps, for faster iteration on CI changes.

Workflow cleanup

  • The steps shared by the Linux, macOS and Windows jobs are written once (YAML anchors): checkout, ccache restore/stats/save, the CTest step and its summary and failure steps, diagnostics uploads... The Linux and macOS build steps are shared too. Windows runs the CTest steps in bash, like the others.
  • New setup-conan composite action, used by all three jobs.
  • Removed: BasicTeX, aqtinstall, bundler-cache, the /mnt volume, the "Wait for network stability" and "Cleanup intermediate files" steps, an unused resource monitor and the build heartbeat, redundant ccache flags...
  • NINJA_STATUS (with a percentage, elapsed time and rate) is set once for all platforms, and .ninja_log goes into the build-diag artifacts.
  • Signing and publishing only run on NatLabRockies/OpenStudio, so forks can run the workflow.
  • Publish jobs: they share the S3 upload script and AWS credentials step. Each one only downloads its own platform's installers: the Linux one was also picking up the Windows installers. The macOS installer artifacts are named OS-Installers-<platform>-<type>, like the others.
  • "Fail job on test failures" is the last step on all platforms, so the installers are still uploaded as artifacts when tests fail, and it lists the failed tests.

Unrelated: clang-format

  • ubuntu-latest moved to 26.04, whose clang-format 21 reformats code differently: the clang-format workflow is pinned to Ubuntu 24.04 (clang-format 18). The autocorrects it had already asked for are committed separately (11 files in src/), and that commit is in .git-blame-ignore-revs.

Results

Job and step durations in minutes. Before: the latest upstream develop run, 45733967523. It's the scheduled run of a SHA that the previous night's push had already built, so it's the best case for a cache. After: jmarrec/OpenStudio 45829708891, a push to develop with a warm ccache.

Platform Job before Job after Build before Build after CTest before CTest after
Ubuntu 24.04 x64 105.7 24.9 80.3 4.5 19.6 15.2
Ubuntu 24.04 ARM64 85.2 22.2 66.5 4.3 13.6 13.3
CentOS 9 x64 131.4 30.2 94.3 4.6 25.4 15.9
Windows 2022 x64 145.4 52.4 87.9 12.4 38.4 28.7
macOS x64 216.4 63.7 105.2 15.4 48.8 35.7
macOS ARM64 119.3 (*) 64.5 20.2

(*) Not run: GitHub couldn't acquire a macOS ARM64 runner for that run.

  • Build: 4 to 15 minutes instead of 1 to 1.75 hours. ccache hit rate: 99.96% on Ubuntu ARM64 (2497 / 2498 cacheable calls).
  • Runner time for the five platforms above: 194 minutes instead of 684 (3.5x less). The whole run takes about 1 hour instead of 3.6 hours.
  • CMake configure (Ubuntu ARM64): 33.7 s → 11.9 s. Windows: 60.2 s → 36.4 s.

CTest is now the longest part of every job. About 80% of it (Windows) is the CLI tests, which each spend ~20 s in the embedded Dir.glob. That's fixed in a separate PR, which brings the Windows CTest step from ~29 to ~9 minutes:

Notes

  • Windows still loads the Conan build environment through cmd /c "call conanbuild.bat && ..." via $env:ComSpec. Conan's conanbuild.ps1 can't be used: it calls a bare cmd, which resolves to the MSYS2 cmd script that setup-ruby puts on the PATH.
  • I've tested a LOT of builds on my fork, https://github.com/jmarrec/OpenStudio/actions/workflows/full-build.yml

Pull Request Author

  • Model API Changes / Additions
  • Any new or modified fields have been implemented in the EnergyPlus ForwardTranslator (and ReverseTranslator as appropriate)
  • Model API methods are tested (in src/model/test)
  • EnergyPlus ForwardTranslator Tests (in src/energyplus/Test)
  • If a new object or method, added a test in NREL/OpenStudio-resources: Add Link
  • If needed, added VersionTranslation rules for the objects (src/osversion/VersionTranslator.cpp)
  • Verified that C# bindings built fine on Windows, partial classes used as needed, etc.
  • All new and existing tests passes
  • If methods have been deprecated, update rest of code to use the new methods

Labels:

  • If change to an IDD file, add the label IDDChange
  • If breaking existing API, add the label APIChange
  • If deemed ready, add label Pull Request - Ready for CI so that CI builds your PR

Review Checklist

This will not be exhaustively relevant to every PR.

  • Perform a Code Review on GitHub
  • Code Style, strip trailing whitespace, etc.
  • All related changes have been implemented: model changes, model tests, FT changes, FT tests, VersionTranslation, OS App
  • Labeling is ok
  • If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
  • If feature, test running new feature, try creative ways to break it
  • CI status: all green or justified

…ly instead of through symlinks

actions/cache archived the ~/.ccache and ~/.conan2 symlinks rather than their /mnt contents, leaving ~200 B entries that blocked any later save. Point CCACHE_DIR/CONAN_HOME and the cache paths at /mnt directly.

(Would need deleting the caches manually right now, I didn't change the key)
The conan.lock-keyed ccache got an exact hit on every run after the first, so it was never refreshed. Key it on the commit SHA for pushes and on the head ref for PRs (falling back to the current base branch tip), and save it in a separate step under always(
actions/cache only saves in its post step when the job succeeds, so a conan.lock change followed by any build/test failure lost the rebuilt dependencies. Save it explicitly after conan install (on a key miss only), after cleaning build/source/download/temp folders to keep it small
Clang embeds a timestamp in the .pch, so its content differs every build and every TU including it is a ccache miss (macOS CI: 98/2484 hits, i.e. only the non-PCH TUs)
sccache refuses to cache MSVC compiles that use precompiled headers (/Fp, /Yc), which is ~95% of them (2370/2484 non-cacheable on develop). ccache handles them. Use the same SHA / head_ref keying and separate always() save as on Linux.

Also set CCACHE_COMPILERCHECK=content: the default mtime check is unreliable across fresh runner VMs.
The OpenStudio/ subfolder checkout made every hashFiles() in cache keys resolve to an empty string, so conan / external-deps / embedded-files keys never changed and those caches were frozen forever. Drop OPENSTUDIO_SOURCE and use the same layout as Linux.
… end

Same as on Linux: actions/cache only saves when the job succeeds, so a conan.lock change followed by any build/test failure lost the rebuilt dependencies.

macOS CI: replace hendrikmuhs/ccache-action with the same restore/save as Linux/Windows

Same SHA / head_ref keying with base branch tip fallback and always() save, instead of a timestamped key saved on every run (including every PR push).
Nothing uses LaTeX: BUILD_DOCUMENTATION is OFF and the docs only need Doxygen anyway.
It imported Kitware's apt key without adding the repo and nothing installs from apt afterwards. ca-certificates is already installed in both openstudio-cmake-tools images (Dockerfile and Dockerfile_centos9).
aqtinstall is never called (Qt IFW is downloaded as a zip), and there is no Gemfile for bundler-cache to cache
GitHub-hosted Linux runners now have a single disk (actions/runner-images#13587), so /mnt is the same filesystem as / and no longer buys any space. Keep caches in $HOME (/github/home) and the swapfile in RUNNER_TEMP (bind-mounted; swapon doesn't work on the container overlayfs).
….directory and tool-existence guards

CMakeLists.txt already picks up ccache as compiler launcher, CCACHE_MAXSIZE already sets the max size, and Windows set safe.directory twice. ccache, git and ninja are always installed, so the command -v / Get-Command guards only hid failures (e.g. silently building without ccache).
Downloads are negligible on a 2h build, and the external-deps key (conan.lock) never tracked the E+/Radiance versions anyway.

Restoring generated embedded files into a fresh build dir is either redundant or risks stale outputs. Frees ~2.3 GB of cache quota for ccache.
embedded-files-* keys use matrix.os only. CentOS and Ubuntu x64 both run on ubuntu-24.04, so they share the same key, e.g. external-deps-ubuntu-24.04-23f4...
…oved to 26.04 (clang-format 21), which reformats code
… macOS (installers still uploaded as artifact)
The fork (tcl-tk fixup) was copied from E+'s release_mac.yml, where the build Python's stdlib gets bundled. OpenStudio bundles E+'s python_lib/libpython instead, so upstream 3.12.2 is fine here; drop the toolcache removal hack too.
BUILD_PYTHON_PIP_PACKAGE=ON compiles every SWIG python binding a second time, but nothing ever ran `ninja python_package && cd Products/python_package && python setup.py bdist_wheel` so no wheel was produced or uploaded (python_bindings.yml builds the wheels). Ubuntu x64 built in 104 min vs 63 min on ARM64 / 65 min on CentOS.
os.version isn't set when the deps are built and uploaded (jmarrec/conan-recipes upload_deps.yml) nor in python_bindings.yml, so the package IDs never matched nrel-v2 and every compiled dependency was rebuilt from source. MACOSX_DEPLOYMENT_TARGET / CMAKE_OSX_DEPLOYMENT_TARGET still set OpenStudio's own minimum macOS. readline/*:with_library=termcap is the recipe default, so it was a no-op.
… python requirements on all platforms

Restore cache, install Conan, configure it (default profile with cppstd=20 / build_type for both contexts like jmarrec/conan-recipes upload_deps.yml so package IDs match nrel-v2, global.conf, nrel-v2 first), conan install, and save the cache right away on a key miss. Replaces the three diverging copies: remote order (conancenter was first on Linux), -s host-only settings, the Windows lockfile rewrite, and the CentOS glibc step (now config-install / extra-args inputs). macOS passes the same cxxflags conf as upload_deps.yml for deps built from source.

Python deps: install only python/requirements.txt on all three platforms (Linux relied on the image, with pytest-xdist unpinned and jinja2 only there as a conan dependency); setuptools/wheel are only needed for the pip package, which Full Build doesn't build.
Deleting *.o / *.obj right before the job ends frees nothing useful (only artifact uploads follow and the runner is discarded), and the recursive scan of the build tree costs time, especially on Windows
conanfile.py now picks RPM instead of DEB on Red Hat-like systems, so Linux no longer passes CPACK_GENERATOR, and Windows now configures with `cmake --preset conan-release` (toolchain, Ninja, build type and CPack generators come from the preset). The DEB/RPM uploads now error if the expected installer is missing instead of silently skipping
Toolchain, Ninja, build type, testing, bindings, Python version/root (from the python running conan) and CPack generators come from the preset; on macOS the libc++ flags come from the tools.build:cxxflags conf and the deployment target from MACOSX_DEPLOYMENT_TARGET. Drop the redundant -D options and the Locate Ruby/Python steps.

SYSTEM_RUBY_EXECUTABLE is still passed on macOS/Windows since ruby/test/CMakeLists.txt only searches hardcoded locations (not setup-ruby's toolcache). macOS never passed it before, so the Ruby tests were never created there.
On forks, develop pushes ran the code signing, keychain and S3/docker publish steps without the secrets and failed. Add a repository check to each of those conditions. Also limit macOS Setup Keychain to develop/master/v* tags like the apple-signing environment: the Apple secrets only exist there, so publish_to_s3 dispatches from other branches failed instead of publishing an unsigned DMG
sed -i writes its temp file in the current dir; on Windows the workspace (D:) and the Conan home (C:) are on different drives so the rename failed with "Invalid cross-device link"
… 'sort: Broken pipe' in the macOS build heartbeat
…of them, or one embed_files() call's)

CMake Configure: 37.0s
time ninja embedded_files: 48s
…mbed_files() call instead of one per file

CreateEmbeddedSource now takes a list file (one "<infile>\t<outfile>\t<filenum>\t<embeddedname>" line per file) and processes all of them on all cores. embed_files() writes that list (only when its content changes, so re-running CMake doesn't regenerate everything) and adds a single custom command per call.

- About 6600 build steps become 6 (a full build goes from ~9600 to ~2900 steps), so ninja's progress percentage and ETA reflect the real work instead of being dominated by thousands of tiny steps
- About 13000 process launches fewer (CreateEmbeddedSource plus a cmake -E make_directory per file), which is slow, especially on Windows
- The tool creates the output directories itself
- Output is byte-identical to the previous per-file generation (checked on all 6597 files)
- Changing one embedded file regenerates all the files of its embed_files() call, but they're all included in the same embedded_files.cxx, which had to be recompiled anyway. Also, worse case is a few seconds for the worst (ruby), About 2.2–2.5 s for all 6379 files on 16 cores locally.
… instead of list(GET) by index

list(GET ... ${i}) re-parses the whole list on every iteration, which made embed_files() quadratic in the number of files: ~33 s at every CMake configure for the 6379 ruby engine files (on Linux, worse on Windows). It now takes ~2.8 s, with identical output
…e uses the line number instead

Original was 38s for CMake configure, previous commit was 11s, now it's down to 10s

CMake Configure: 37.0s -> 10.1s
time ninja embedded_files: 48s -> 2.9s
…so they can run in parallel

CI: run all tests in parallel, the "sequential" ModelFixture tests no longer clash
…nd Testing/Rerun.xml for the rerun), so the rerun no longer overwrites the full results and LastTest.log/LastTestsFailed.log exist for the summary steps
…it runs for every test (one process each) and deleted the files of tests running in parallel
…(YAML anchors in the Linux job), and reuse them in the other two
…e it for macOS and Windows; Windows now runs it in bash, and macOS installs bundler in a separate step
…n test failures steps across platforms (YAML anchors), Windows now runs them in bash
…> like the others, and only download each platform's installers in its publish job (Linux was also picking up the Windows ones)

In practice Linux didn't pick the windows up, because it runs while windows is still building since it's slower
…ownloads with merge-multiple like the others, and the redundant AWS_S3_BUCKET env is gone
…an-release" as in BUILDING.md (drops the unused resource monitor and the heartbeat)
…e --preset / cmake --build --preset), still through cmd /c "call conanbuild.bat && ..." via $env:ComSpec (conan's conanbuild.ps1 calls a bare 'cmd', which resolves to the MSYS2 cmd script setup-ruby puts on the PATH)
…of a hard-coded max_jobs per platform (macOS x64 was using 3 of its 4); max_jobs can still be set on a matrix entry to limit it, eg after an OOM
…ck needed for now... can readd if really needed)
@jmarrec

jmarrec commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator Author
image

The same can be demonstrated by looking at Scheduled builds (nightly) on days where nothing was pushed to develop: four nightly runs in a row built the exact same commit (35a3465fb3, Nov 20 to 23), and each one rebuilt everything from scratch: the Build step alone took 57 to 100 minutes on Linux, 66 to 87 on Windows, and 36 to 73 on macOS, every night.

Build Step minutes only:

Platform Nov 20 Nov 21 Nov 22 Nov 23
Ubuntu 24.04 x64 70.8 100.6 81.5 71.3
Ubuntu 24.04 ARM64 60.5 62.7 - 57.5
CentOS 9 x64 62.5 88.1 66.0 64.3
Windows 2022 x64 68.0 - 86.7 65.9
macOS x64 67.5 72.7 53.1 57.2
macOS ARM64 39.7 45.2 36.3 38.2

and whole-job minutes:

Platform Nov 20 Nov 21 Nov 22 Nov 23
Ubuntu 24.04 x64 91.7 130.6 106.6 92.2
Ubuntu 24.04 ARM64 77.8 80.3 - 74.6
CentOS 9 x64 86.7 121.4 91.9 105.2
Windows 2022 x64 116.1 - 144.0 115.0
macOS x64 122.6 139.5 108.3 120.7
macOS ARM64 69.1 71.0 66.4 67.1

@jmarrec
jmarrec merged commit 0390427 into NatLabRockies:develop Nov 27, 2026
13 checks passed
@jmarrec

jmarrec commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator Author

Geeeeeeeez, I'm sorry but I messed up badly, I tried to push another commit to jmarrec/develop but it went to NatLabRockies/develop, and it did accept it (I thought that would be prohibited too...)... Except now I can't revert because while a direct push to develop is ok, a FORCE push isn't allowed for me...

I am quite confident in these changes though, so we could keep it that way.

Or, otherwise @anchapin @tijcolem @DavidGoldwasser do you have admin rights to do a force push?

git push --force-with-lease=develop:e6724559d1 origin 23eaa14ccf:develop

and we need to request a cache allowance increase (for reference E+ has one)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

1 participant