diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 302c5ecd2f8..d08253d9370 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -161,3 +161,6 @@ ae602de89105983bf762cf1e6afd33d63d81b4a6 # [chore] Org and copyright year updates for OS 311 [David Goldwasser, 2026-01-05] 7a409fb41f6b0602ef2a6a018c9b3d33934571af 3c5a13b05d17ad83bca6ee84ca130b5c1c7f1dda + +# [chore] Commit clang-format autocorrects [Julien Marrec, 2026-11-25] +50b8da4eadd3588e3c9bb8a0fdc25f79f0721699 diff --git a/.github/actions/setup-conan/action.yml b/.github/actions/setup-conan/action.yml new file mode 100644 index 00000000000..a507e974a65 --- /dev/null +++ b/.github/actions/setup-conan/action.yml @@ -0,0 +1,124 @@ +name: Setup Conan +description: > + Restore the Conan cache, configure the remotes, run conan install, and save the cache right away when the lockfile changed + (so a later build or test failure doesn't lose it). Installs Conan with pip, so Python must already be set up. + +inputs: + cache-key-prefix: + description: "Cache key prefix, eg conan--. The hash of conan.lock is appended" + required: true + build-folder: + description: "Output folder for conan install" + default: build + build-type: + description: "CMake build type" + default: Release + build-policy: + description: "Value passed to conan install --build to specify what to build from source" + default: missing + config-install: + description: "Optional path passed to 'conan config install' (eg extra profiles)" + default: "" + extra-args: + description: "Extra arguments passed to conan install" + default: "" + +outputs: + cache-hit: + description: "Whether the Conan cache was restored from an exact key match" + value: ${{ steps.restore.outputs.cache-hit }} + +runs: + using: composite + steps: + - name: Restore Conan cache + id: restore + uses: actions/cache/restore@v6 + with: + path: ${{ env.CONAN_HOME || '~/.conan2' }} + key: ${{ inputs.cache-key-prefix }}-${{ hashFiles('conan.lock') }} + restore-keys: | + ${{ inputs.cache-key-prefix }}- + + - name: Install Conan + shell: bash + run: | + begin_group() { echo -e "::group::\033[93m$1\033[0m"; } + + begin_group "Install Conan" + python -m pip install "conan>=2" + conan --version + echo "::endgroup::" + + - name: Configure Conan + shell: bash + run: | + begin_group() { echo -e "::group::\033[93m$1\033[0m"; } + + begin_group "Conan home" + conan config home + echo "::endgroup::" + + begin_group "Default profile" + # Same default profile as jmarrec/conan-recipes upload_deps.yml, so the package IDs match what's on nrel-v2. + # It's used for both the host and build contexts. + conan profile detect --force --name default + CONAN_PROFILES_DIR=$(dirname "$(conan profile path default)") + # On Windows, sed -i creates its temp file in the current directory (D: workspace) and fails to move it to the + # Conan home (C:): "Invalid cross-device link". So run the edits from the profiles directory, in a subshell. + ( + cd "$CONAN_PROFILES_DIR" + # Mac has the BSD flavor of sed and MUST take a backup suffix + sed -i.bak 's/cppstd=.*$/cppstd=20/g' default + sed -i.bak 's/build_type=.*$/build_type=${{ inputs.build-type }}/g' default + # Windows only + sed -i.bak 's/compiler.runtime_type=.*$/compiler.runtime_type=${{ inputs.build-type }}/g' default + rm -f default.bak + ) + conan profile show + echo "::endgroup::" + + begin_group "Global.conf" + # Overwrite (not append): global.conf comes back with the restored cache + CONAN_GLOBAL_CONF="$(conan config home)/global.conf" + echo "core:non_interactive = True" > "$CONAN_GLOBAL_CONF" + echo "core.download:parallel = {{os.cpu_count() - 2}}" >> "$CONAN_GLOBAL_CONF" + cat "$CONAN_GLOBAL_CONF" + echo "::endgroup::" + + begin_group "Remotes" + # nrel-v2 first: that's where our prebuilt binaries are + conan remote add --index 0 --force nrel-v2 https://conan.openstudio.net/artifactory/api/conan/conan-v2 + conan remote list + echo "::endgroup::" + + if [ -n "${{ inputs.config-install }}" ]; then + begin_group "Config install" + conan config install "${{ inputs.config-install }}" + echo "::endgroup::" + fi + + - name: Conan install + shell: bash + run: | + begin_group() { echo -e "::group::\033[93m$1\033[0m"; } + + begin_group "Conan install" + conan install . \ + --output-folder="${{ inputs.build-folder }}" \ + --build="${{ inputs.build-policy }}" \ + -c tools.cmake.cmaketoolchain:generator=Ninja \ + ${{ inputs.extra-args }} + echo "::endgroup::" + + - name: Clean Conan cache before saving + if: steps.restore.outputs.cache-hit != 'true' + shell: bash + run: conan cache clean "*" --source --build --download --temp + + - name: Save Conan cache + if: steps.restore.outputs.cache-hit != 'true' + uses: actions/cache/save@v6 + with: + path: ${{ env.CONAN_HOME || '~/.conan2' }} + key: ${{ steps.restore.outputs.cache-primary-key }} diff --git a/.github/workflows/clangformat.yml b/.github/workflows/clangformat.yml index f0d92ac46fb..f7dbda60b4b 100644 --- a/.github/workflows/clangformat.yml +++ b/.github/workflows/clangformat.yml @@ -6,7 +6,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 permissions: contents: write # Needed to push a commit diff --git a/.github/workflows/full-build.yml b/.github/workflows/full-build.yml index de5163ac55d..75faa371ce7 100644 --- a/.github/workflows/full-build.yml +++ b/.github/workflows/full-build.yml @@ -72,7 +72,6 @@ env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} BUILD_TYPE: Release OPENSTUDIO_BUILD: build - OPENSTUDIO_SOURCE: OpenStudio PYTHON_REQUIRED_VERSION: "3.12.2" SDKROOT: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk AWS_S3_BUCKET: openstudio-ci-builds @@ -85,10 +84,12 @@ env: CCACHE_MAXSIZE: "10G" CCACHE_DEPEND: "true" CCACHE_NOHASHDIR: "true" - SCCACHE_GHA_ENABLED: "false" - SCCACHE_DIR: "${{ github.workspace }}\\.sccache" - SCCACHE_CACHE_SIZE: "10G" + # mtime-based compiler check is unreliable across fresh runner VMs, where the compiler binary's mtime can differ even though its content doesn't + CCACHE_COMPILERCHECK: content ENABLE_PCH: ON + NINJA_STATUS: "[%p][%f/%t | %es elapsed | %o objs/sec] " + # Put [skip tests] in the commit message to skip the CTest steps (only on push: always false on pull requests) + SKIP_TESTS: ${{ contains(github.event.head_commit.message, '[skip tests]') }} jobs: linux-build: @@ -97,7 +98,7 @@ jobs: runs-on: ${{ matrix.os }} container: image: ${{ matrix.container_image }} - options: ${{ matrix.container_options }} --volume /mnt:/mnt + options: ${{ matrix.container_options }} strategy: fail-fast: false matrix: @@ -109,13 +110,10 @@ jobs: container_image: nrel/openstudio-cmake-tools:almalinux9-main container_options: "--privileged -u root" test_suffix: CentOS-9 - pip_package: false docker_trigger: false upload_globs: | *.rpm *OpenStudio*x86_64.tar.gz - cpack_generators: "RPM;TGZ" - max_jobs: 4 exclude_regex: "BCLFixture.RemoteBCLMetaSearchTest" - platform: ubuntu-2404-x64 pretty: Ubuntu 24.04 x64 @@ -123,13 +121,10 @@ jobs: container_image: nrel/openstudio-cmake-tools:noble-main container_options: "--privileged -u root" test_suffix: Ubuntu-2404 - pip_package: true docker_trigger: true upload_globs: | *.deb *OpenStudio*x86_64.tar.gz - cpack_generators: "DEB;TGZ" - max_jobs: 4 exclude_regex: "" - platform: ubuntu-2404-arm64 pretty: Ubuntu 24.04 ARM64 @@ -137,20 +132,19 @@ jobs: container_image: nrel/openstudio-cmake-tools:noble-main container_options: "--privileged -u root" test_suffix: Ubuntu-2404-ARM64 - pip_package: false docker_trigger: false upload_globs: | *.deb *OpenStudio*arm64.tar.gz - cpack_generators: "DEB;TGZ" - max_jobs: 4 # SqlFileFixture.AnnualTotalCosts needed until E+ itself disables ffp-contract on arm64 GCC exclude_regex: "SqlFileFixture.AnnualTotalCosts|OpenStudioCLI.*test_measure_manager" defaults: run: shell: bash env: - MAX_BUILD_THREADS: ${{ matrix.max_jobs }} + # $HOME in GHA containers. Explicit so the tools and actions/cache agree on the paths (#5711) + CCACHE_DIR: /github/home/.ccache + CONAN_HOME: /github/home/.conan2 permissions: # Needed permission to upload the release asset @@ -161,10 +155,12 @@ jobs: run: | echo "Enabling Swap..." # Create and enable 8GB swap file to prevent OOM kills - dd if=/dev/zero of=/mnt/swapfile_extra bs=1M count=8192 status=progress - chmod 600 /mnt/swapfile_extra - mkswap /mnt/swapfile_extra - swapon /mnt/swapfile_extra + # RUNNER_TEMP is bind-mounted from the host disk: swapon doesn't work on the container's overlayfs + SWAPFILE="$RUNNER_TEMP/swapfile_extra" + dd if=/dev/zero of="$SWAPFILE" bs=1M count=8192 status=progress + chmod 600 "$SWAPFILE" + mkswap "$SWAPFILE" + swapon "$SWAPFILE" echo echo "Memory and swap:" @@ -181,55 +177,38 @@ jobs: df -h || true echo - - name: Checkout repository + - &checkout + name: Checkout repository uses: actions/checkout@v7 with: fetch-depth: 1 - - name: Restore ccache cache - uses: actions/cache@v6 - with: - path: ~/.ccache - key: ccache-${{ matrix.os }}-${{ matrix.platform }}-${{ hashFiles('conan.lock') }} - restore-keys: | - ccache-${{ matrix.os }}-${{ matrix.platform }}- - - - name: Restore Conan cache - uses: actions/cache@v6 + - &get_base_sha + name: Get base branch SHA + if: github.event_name == 'pull_request' + shell: bash + run: | + # github.event.pull_request.base.sha is the base at PR creation, not the current tip + BASE_SHA=$(git ls-remote "https://github.com/$GITHUB_REPOSITORY.git" "refs/heads/${{ github.base_ref }}" | cut -f1) + echo "BASE_SHA=$BASE_SHA" >> "$GITHUB_ENV" + + - &restore_ccache + name: Restore ccache cache + id: ccache-restore + uses: actions/cache/restore@v6 with: - path: ~/.conan2 - key: conan-${{ matrix.os }}-${{ matrix.platform }}-${{ hashFiles('conan.lock') }} + path: ${{ env.CCACHE_DIR }} + key: ccache-${{ matrix.os }}-${{ matrix.platform }}-pch=${{ env.ENABLE_PCH }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} restore-keys: | - conan-${{ matrix.os }}-${{ matrix.platform }}- + ccache-${{ matrix.os }}-${{ matrix.platform }}-pch=${{ env.ENABLE_PCH }}-${{ env.BASE_SHA }} + ccache-${{ matrix.os }}-${{ matrix.platform }}-pch=${{ env.ENABLE_PCH }}- - name: Prepare workspace run: | - # Git safe directory - if command -v git >/dev/null 2>&1; then - git config --global --add safe.directory '*' - fi - - # Use /mnt for build and caches to avoid running out of space on root partition - prepare_dir() { - local target=$1 - local dest=$2 - mkdir -p "$dest" - if [ -d "$target" ] && [ ! -L "$target" ]; then - echo "Moving existing $target to $dest" - cp -a "$target/." "$dest/" - rm -rf "$target" - fi - mkdir -p "$(dirname "$target")" - ln -sfn "$dest" "$target" - } + git config --global --add safe.directory '*' - prepare_dir "$HOME/.ccache" "/mnt/.ccache" - prepare_dir "$HOME/.conan2" "/mnt/.conan2" - if command -v ccache >/dev/null 2>&1; then - ccache -M ${{ env.CCACHE_MAXSIZE }} || true - echo "Configured ccache:"; ccache -s | sed -n '1,10p' - fi + mkdir -p "$CCACHE_DIR" "$CONAN_HOME" - name: Fix CMake Path (CentOS) if: matrix.platform == 'centos-9-x64' @@ -239,123 +218,85 @@ jobs: echo "/usr/local/cmake/bin" >> $GITHUB_PATH fi - - name: Cache External Dependencies - uses: actions/cache@v6 - with: - path: | - ${{ env.OPENSTUDIO_BUILD }}/EnergyPlus*.tar.gz - ${{ env.OPENSTUDIO_BUILD }}/EnergyPlus*.zip - ${{ env.OPENSTUDIO_BUILD }}/radiance*.tar.gz - ${{ env.OPENSTUDIO_BUILD }}/radiance*.zip - ${{ env.OPENSTUDIO_BUILD }}/openstudio*gems*.tar.gz - key: external-deps-${{ matrix.os }}-${{ hashFiles('conan.lock') }} - restore-keys: | - external-deps-${{ matrix.os }}- + - &install_python_deps + name: Install Python dependencies + shell: bash + run: python -m pip install -r python/requirements.txt - - name: Restore Generated Embedded Files - uses: actions/cache@v6 + - name: Setup Conan + uses: ./.github/actions/setup-conan with: - path: | - ${{ env.OPENSTUDIO_BUILD }}/src/*/embedded_files - ${{ env.OPENSTUDIO_BUILD }}/ruby/engine/embedded_files - key: embedded-files-${{ matrix.os }}-${{ hashFiles('resources/**', 'ruby/engine/**', 'src/airflow/**', 'src/energyplus/**', 'src/gbxml/**', 'src/isomodel/**', 'src/model/**', 'src/radiance/**', 'src/sdd/**', 'src/utilities/**') }} - restore-keys: | - embedded-files-${{ matrix.os }}- + cache-key-prefix: conan-${{ matrix.os }}-${{ matrix.platform }} + build-folder: ${{ env.OPENSTUDIO_BUILD }} + build-type: ${{ env.BUILD_TYPE }} + build-policy: ${{ contains(inputs.conan_build_all, matrix.platform) && '*' || 'missing' }} + # nrel-v2's gcc 14 binaries are built on ubuntu-24.04 with GLIBC 2.39 (AlmaLinux 9 has 2.34). Making the libc version part of the + # package_id means they never match, so we build from source (or pull the glibc 2.34 ones once uploaded to nrel-v2). + # See https://github.com/NatLabRockies/openstudio-cmake-tools/issues/6 + config-install: ${{ matrix.platform == 'centos-9-x64' && 'developer/conan/config' || '' }} + extra-args: ${{ matrix.platform == 'centos-9-x64' && '-pr:a glibc' || '' }} - - name: Configure Conan remotes + - name: Configure with CMake run: | - conan remote remove conancenter || true - conan remote add conancenter https://center2.conan.io - conan remote remove nrel-v2 || true - conan remote add nrel-v2 https://conan.openstudio.net/artifactory/api/conan/conan-v2 - if [ ! -f "$HOME/.conan2/profiles/default" ]; then - conan profile detect - fi + # Build type, testing, bindings, Python version/root and CPack generators all come from the conanfile.py preset + cmake --preset conan-release \ + -DENABLE_PCH:BOOL=${{ env.ENABLE_PCH }} \ + -DCMAKE_JOB_POOL_LINK:STRING=console - - name: Install CA Certificates - if: startsWith(matrix.platform, 'ubuntu') - run: | - apt-get update || true - apt-get install -y ca-certificates gnupg wget - wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null - apt-get update - - - name: Add libc setting to Conan (CentOS) - # nrel-v2's gcc 14 binaries are built on ubuntu-24.04 with GLIBC 2.39 (AlmaLinux 9 has 2.34). Making the libc version part of the - # package_id means they never match, so we build from source (or pull the glibc 2.34 ones once uploaded to nrel-v2). - # See https://github.com/NatLabRockies/openstudio-cmake-tools/issues/6 - if: matrix.platform == 'centos-9-x64' + - &show_restored_ccache_stats + name: Show restored ccache stats + shell: bash run: | - conan config install developer/conan/config - conan profile show -pr:a glibc | grep "os.libc" - echo "CONAN_EXTRA_ARGS=-pr:a glibc" >> $GITHUB_ENV + # Stats live in the cache dir, so they come back with the restore: show them, then zero them for this run + ccache --show-stats -vv + ccache --zero-stats + ccache --show-config - - name: Conan install - env: - CONAN_BUILD_POLICY: ${{ contains(inputs.conan_build_all, matrix.platform) && '*' || 'missing' }} - run: | - conan install . \ - --output-folder="${{ env.OPENSTUDIO_BUILD }}" \ - --build="$CONAN_BUILD_POLICY" \ - -c tools.cmake.cmaketoolchain:generator=Ninja \ - -s compiler.cppstd=20 \ - -s build_type=${{ env.BUILD_TYPE }} \ - ${CONAN_EXTRA_ARGS:-} - - - name: Locate Ruby + - &build_with_ninja + name: Build with Ninja + shell: bash run: | - ruby_path=$(command -v ruby) - echo "SYSTEM_RUBY_PATH=$ruby_path" >> $GITHUB_ENV + # Run from the source dir, where CMakeUserPresets.json is. The preset carries the Conan build environment (SWIG_LIB, ...) + cmake --build --preset conan-release 2>&1 | tee ${{ env.OPENSTUDIO_BUILD }}/build.log + build_exit=${PIPESTATUS[0]} + ninja -C ${{ env.OPENSTUDIO_BUILD }} -d stats || true + exit $build_exit + + - &show_ccache_stats + name: Show ccache stats + if: always() + shell: bash + run: ccache --show-stats -vv - - name: Locate Python - run: | - python_path=$(command -v python3) - echo "SYSTEM_PYTHON_PATH=$python_path" >> $GITHUB_ENV + - &save_ccache + name: Save ccache cache + if: always() && steps.ccache-restore.outputs.cache-hit != 'true' + uses: actions/cache/save@v6 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache-restore.outputs.cache-primary-key }} - - name: Configure with CMake - run: | - # Use absolute path for ccache to avoid resolution issues in containers with symlinked build dirs - CCACHE_ARGS=() - if command -v ccache >/dev/null 2>&1; then - CCACHE_EXE=$(command -v ccache) - CCACHE_ARGS=("-DCMAKE_C_COMPILER_LAUNCHER=$CCACHE_EXE" "-DCMAKE_CXX_COMPILER_LAUNCHER=$CCACHE_EXE") - fi - cmake --preset conan-release \ - "${CCACHE_ARGS[@]}" \ - -DCMAKE_BUILD_TYPE:STRING=${{ env.BUILD_TYPE }} \ - -DBUILD_TESTING:BOOL=ON \ - -DCPACK_GENERATOR:STRING="${{ matrix.cpack_generators }}" \ - -DBUILD_PYTHON_BINDINGS:BOOL=ON \ - -DBUILD_PYTHON_PIP_PACKAGE:BOOL=${{ matrix.pip_package }} \ - -DPython_EXECUTABLE:FILEPATH="$SYSTEM_PYTHON_PATH" \ - -DPYTHON_VERSION:STRING=${{ env.PYTHON_REQUIRED_VERSION }} \ - -DSYSTEM_RUBY_EXECUTABLE="$SYSTEM_RUBY_PATH" \ - -DENABLE_PCH:BOOL=${{ env.ENABLE_PCH }} \ - -DCMAKE_JOB_POOL_LINK:STRING=console + - &upload_build_diagnostics + name: Upload build diagnostics + if: always() + uses: actions/upload-artifact@v7 + with: + name: build-diag-${{ matrix.platform }}-${{ github.sha }} + path: | + ${{ env.OPENSTUDIO_BUILD }}/build.log + ${{ env.OPENSTUDIO_BUILD }}/.ninja_log + ${{ env.OPENSTUDIO_BUILD }}/CTestTestfile.cmake + if-no-files-found: warn + # .ninja_log is a hidden file, skipped by default + include-hidden-files: true - - name: Build with Ninja - working-directory: ${{ env.OPENSTUDIO_BUILD }} - run: | - . ./conanbuild.sh - export NINJA_STATUS="[%f/%t | %es elapsed | %o objs/sec]" - # Start resource monitor (records RSS samples for later summary) - echo "timestamp PID RSS_KB COMM" > mem_samples.log - ( while true; do - sleep 60; - stamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ"); - if command -v ps >/dev/null 2>&1; then ps -eo pid,rsz,comm --sort=-rsz | head -n 5 | awk -v s="$stamp" '{print s" "$1" "$2" "$3}' >> mem_samples.log; fi; - done ) & - HB_PID=$! - cmake --build . --parallel ${{ matrix.max_jobs }} 2>&1 | tee build.log - BUILD_EXIT=${PIPESTATUS[0]} - kill $HB_PID || true - command -v ninja >/dev/null 2>&1 && ninja -d stats || true - exit $BUILD_EXIT - - - name: Run CTest suite + - &run_ctest + name: Run CTest suite + if: env.SKIP_TESTS != 'true' id: ctest continue-on-error: true working-directory: ${{ env.OPENSTUDIO_BUILD }} + shell: bash run: | overall_exit_code=0 @@ -364,79 +305,48 @@ jobs: export CTEST_OUTPUT_ON_FAILURE=1 exclude_pattern="${{ matrix.exclude_regex }}" - . ./conanbuild.sh - - # Conflicting tests that must run sequentially - resource_locked_tests=( - ModelFixture.ScheduleFile - ModelFixture.ScheduleFileAltCtor - ModelFixture.PythonPluginInstance - ModelFixture.PythonPluginInstance_NotPYFile - ModelFixture.PythonPluginInstance_ClassNameValidation - ModelFixture.ChillerElectricASHRAE205_GettersSetters - ModelFixture.ChillerElectricASHRAE205_Loops - ModelFixture.ChillerElectricASHRAE205_NotCBORFile - ModelFixture.ChillerElectricASHRAE205_Clone - ) - resource_locked_pattern=$(IFS='|'; echo "${resource_locked_tests[*]}") - - ctest_command=(ctest -C ${{ env.BUILD_TYPE }} -T test --no-compress-output) - seq_exclude_args=() + ctest_command=(ctest -C ${{ env.BUILD_TYPE }}) if [ -n "$exclude_pattern" ]; then - seq_exclude_args=(-E "^($exclude_pattern)$") - final_exclude="$exclude_pattern|$resource_locked_pattern" - else - final_exclude="$resource_locked_pattern" + ctest_command+=(-E "^($exclude_pattern)$") fi - begin_group "Running sequential tests..." - echo "Running: ${ctest_command[@]} ${seq_exclude_args[@]} -R '^($resource_locked_pattern)$' -j 1" - "${ctest_command[@]}" "${seq_exclude_args[@]}" -R "^($resource_locked_pattern)$" -j 1 || overall_exit_code=$? - echo "::endgroup::" - + jobs=$(nproc 2>/dev/null || sysctl -n hw.logicalcpu) - ctest_command+=(-E "^($final_exclude)$") - - begin_group "Running all other tests in parallel..." - echo "Running: ${ctest_command[@]} -j ${{ matrix.max_jobs }}" - "${ctest_command[@]}" -j ${{ matrix.max_jobs }} || overall_exit_code=$? + begin_group "Running tests..." + echo "Running: ${ctest_command[@]} -j $jobs --output-junit Testing/Results.xml" + "${ctest_command[@]}" -j $jobs --output-junit Testing/Results.xml || overall_exit_code=$? echo "::endgroup::" if [ $overall_exit_code -ne 0 ]; then + first_failed=$(cut -d: -f2 Testing/Temporary/LastTestsFailed.log | tr '\n' ' ') + begin_group "Rerunning failing tests..." - echo "Running: ${ctest_command[@]} --rerun-failed --output-on-failure" - "${ctest_command[@]}" --rerun-failed --output-on-failure && overall_exit_code=0 || overall_exit_code=$? + echo "Running: ${ctest_command[@]} --rerun-failed --output-on-failure --output-junit Testing/Rerun.xml" + "${ctest_command[@]}" --rerun-failed --output-on-failure --output-junit Testing/Rerun.xml && overall_exit_code=0 || overall_exit_code=$? echo "::endgroup::" + + if [ $overall_exit_code -eq 0 ]; then + echo "::warning title=Flaky tests::Failed, then passed on rerun (probably not safe to run in parallel): $first_failed" + fi fi echo "exit_code=${overall_exit_code}" >> $GITHUB_OUTPUT - - name: Wait for network stability - if: always() - run: sleep 5 - - - name: Upload build diagnostics - if: always() - uses: actions/upload-artifact@v7 - with: - name: build-diag-${{ matrix.platform }}-${{ github.sha }} - path: | - ${{ env.OPENSTUDIO_BUILD }}/build.log - ${{ env.OPENSTUDIO_BUILD }}/.ninja_log - ${{ env.OPENSTUDIO_BUILD }}/CTestTestfile.cmake - if-no-files-found: warn - - - name: Copy Testing tree with suffix - if: always() + - ©_testing_tree + name: Copy Testing tree with suffix + if: always() && env.SKIP_TESTS != 'true' working-directory: ${{ env.OPENSTUDIO_BUILD }} + shell: bash run: | if [ -d "Testing" ]; then cp -r Testing "Testing-${{ matrix.test_suffix }}" fi - - name: Generate test summary - if: always() + - &generate_test_summary + name: Generate test summary + if: always() && env.SKIP_TESTS != 'true' working-directory: ${{ env.OPENSTUDIO_BUILD }} + shell: bash run: | # Generate a simple markdown summary from CTest results @@ -458,8 +368,9 @@ jobs: fi continue-on-error: true - - name: Upload Testing artifact - if: always() + - &upload_testing_artifact + name: Upload Testing artifact + if: always() && env.SKIP_TESTS != 'true' uses: actions/upload-artifact@v7 with: name: Testing-${{ matrix.platform }}-${{ github.sha }} @@ -474,34 +385,22 @@ jobs: . ./conanbuild.sh cpack -C ${{ env.BUILD_TYPE }} - - name: Cleanup intermediate files - if: always() - working-directory: ${{ env.OPENSTUDIO_BUILD }} - run: | - find . -name "*.o" -type f -delete || true - df -h . - - - name: Fail job on test failures - if: ${{ steps.ctest.outputs.exit_code != '0' }} - run: | - echo "::error::CTest suite failed with exit code ${{ steps.ctest.outputs.exit_code }}" - exit 1 - - name: Upload DEB installer - if: contains(matrix.cpack_generators, 'DEB') + # The generators come from the conanfile.py CMakePresets: DEB on Ubuntu, RPM on Red Hat-like + if: startsWith(matrix.platform, 'ubuntu') uses: actions/upload-artifact@v7 with: name: OS-Installers-${{ matrix.platform }}-DEB-${{ github.sha }} path: ${{ env.OPENSTUDIO_BUILD }}/*.deb - if-no-files-found: ignore + if-no-files-found: error - name: Upload RPM installer - if: contains(matrix.cpack_generators, 'RPM') + if: startsWith(matrix.platform, 'centos') uses: actions/upload-artifact@v7 with: name: OS-Installers-${{ matrix.platform }}-RPM-${{ github.sha }} path: ${{ env.OPENSTUDIO_BUILD }}/*.rpm - if-no-files-found: ignore + if-no-files-found: error - name: Upload TGZ installer uses: actions/upload-artifact@v7 @@ -510,128 +409,25 @@ jobs: path: ${{ env.OPENSTUDIO_BUILD }}/OpenStudio-*.tar.gz if-no-files-found: ignore - - name: Upload WHEEL installer - if: matrix.pip_package - uses: actions/upload-artifact@v7 - with: - name: OS-Installers-${{ matrix.platform }}-WHEEL-${{ github.sha }} - path: ${{ env.OPENSTUDIO_BUILD }}/*.whl - if-no-files-found: ignore - - linux-publish: - name: Publish Linux Artifacts - needs: [linux-build] - runs-on: ubuntu-latest - if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') || inputs.publish_to_s3 == true || github.event.inputs.publish_to_s3 == 'true' - steps: - - name: Download all installers - uses: actions/download-artifact@v8 - with: - pattern: OS-Installers-* - merge-multiple: true - path: installers - - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v6 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: ${{ secrets.AWS_REGION || 'us-west-2' }} - - - name: Publish to S3 - working-directory: installers - env: - S3_PREFIX: ${{ github.ref_type == 'tag' && format('releases/{0}', github.ref_name) || format('{0}', github.ref_name) }} - run: | - echo "Uploading artifacts to s3://${AWS_S3_BUCKET}/${S3_PREFIX}" - for file in *; do - [ -e "$file" ] || continue - [ -f "$file" ] || continue - filename=$(basename "$file") - key="${S3_PREFIX}/${filename}" - aws s3 cp "$file" "s3://${AWS_S3_BUCKET}/${key}" --acl public-read - if command -v md5sum >/dev/null 2>&1; then md5sum "$file"; else md5 "$file"; fi - done - - - name: Trigger Docker Build - if: inputs.skip_docker_trigger != true && github.event.inputs.skip_docker_trigger != 'true' - working-directory: installers - env: - GH_TOKEN: ${{ secrets.DOCKER_OPENSTUDIO_PAT }} - BRANCH_NAME: ${{ github.ref_name }} - S3_PREFIX: ${{ github.ref_type == 'tag' && format('releases/{0}', github.ref_name) || format('{0}', github.ref_name) }} + - &fail_on_test_failures + name: Fail job on test failures + if: env.SKIP_TESTS != 'true' && steps.ctest.outputs.exit_code != '0' + working-directory: ${{ env.OPENSTUDIO_BUILD }} + shell: bash run: | - - # Find the 24.04 deb file locally - DEB_FILE=$(find . -name "*24.04*.deb" | head -n 1) - if [ -z "$DEB_FILE" ]; then - echo "::error::Could not find Ubuntu 24.04 deb file in installers directory" - ls -la - exit 1 + cat "${{ env.TEST_DASHBOARD_RELATIVE }}" || true + if [ -f Testing/Temporary/LastTestsFailed.log ]; then + echo; echo "Failed tests:"; cat Testing/Temporary/LastTestsFailed.log fi - - FILENAME=$(basename "$DEB_FILE") - echo "Found file: $FILENAME" - - # Construct S3 URL - # Replace + with %2B - ENCODED_FILENAME=${FILENAME//+/%2B} - BINARY_URL="https://${AWS_S3_BUCKET}.s3.amazonaws.com/${S3_PREFIX}/${ENCODED_FILENAME}" - echo "Binary URL: $BINARY_URL" - - # Parse version from filename - # Expected format: OpenStudio--.deb - if [[ "$FILENAME" =~ OpenStudio-(.+)-Ubuntu-24\.04.*\.deb ]]; then - OS_VERSION_FULL=${BASH_REMATCH[1]} - elif [[ "$FILENAME" =~ OpenStudio-(.+)-Linux.*\.deb ]]; then - OS_VERSION_FULL=${BASH_REMATCH[1]} - else - echo "::error::Could not parse version from filename: $FILENAME" - exit 1 - fi - - echo "Full Version: $OS_VERSION_FULL" - - # Logic from Jenkins: - # Split by + - IFS='+' read -r VER_PART SHA_PART <<< "$OS_VERSION_FULL" - - if [[ "$VER_PART" == *"-"* ]]; then - # 3.3.0-rc1 -> Ver: 3.3.0, Ext: rc1 - IFS='-' read -r OS_VERSION OS_VERSION_EXT <<< "$VER_PART" - else - # 3.3.0+sha -> Ver: 3.3.0, Ext: sha - OS_VERSION="$VER_PART" - OS_VERSION_EXT="$SHA_PART" - fi - - echo "OS Version: $OS_VERSION" - echo "OS Version Ext: $OS_VERSION_EXT" - - # Docker Tag Logic - if [[ "$BRANCH_NAME" == "develop" ]]; then - DOCKER_IMAGE_TAG="develop" - else - DOCKER_IMAGE_TAG="${OS_VERSION}-${OS_VERSION_EXT}" - fi - echo "Docker Image Tag: $DOCKER_IMAGE_TAG" - - # Trigger Workflow - echo "Triggering manual_update_develop workflow in NatLabRockies/docker-openstudio..." - gh workflow run 'manual_update_develop' \ - --repo NatLabRockies/docker-openstudio \ - --ref develop \ - -f docker_image_tag="$DOCKER_IMAGE_TAG" \ - -f os_installer_link="$BINARY_URL" \ - -f os_version="$OS_VERSION" \ - -f os_version_ext="$OS_VERSION_EXT" + echo "::error::CTest suite failed with exit code ${{ steps.ctest.outputs.exit_code }}" + exit 1 macos-build: name: Build Packages for ${{ matrix.pretty }} if: (!inputs.jobs || contains(inputs.jobs, 'macos-build')) # Apple signing secrets live in the apple-signing environment, which only these refs may use. # Other refs (PRs, feature branches) get no environment and fall back to ad-hoc signing. - environment: ${{ (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) && 'apple-signing' || '' }} + environment: ${{ github.repository == 'NatLabRockies/OpenStudio' && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) && 'apple-signing' || '' }} runs-on: ${{ matrix.os }} timeout-minutes: 720 continue-on-error: ${{ matrix.allow_failure }} @@ -651,7 +447,6 @@ jobs: dmg_glob: "*.dmg" tar_glob: "*OpenStudio*x86_64.tar.gz" exclude_regex: "" - max_jobs: 3 - macos_dev_target: "13.0" platform: macos-arm64 pretty: "macOS ARM64" @@ -663,20 +458,15 @@ jobs: dmg_glob: "*.dmg" tar_glob: "*OpenStudio*arm64.tar.gz" exclude_regex: "" - max_jobs: 3 env: - MAX_BUILD_THREADS: ${{ matrix.max_jobs }} + CCACHE_DIR: ${{ github.workspace }}/.ccache permissions: # Needed permission to upload the release asset contents: write steps: - - name: Checkout repository - uses: actions/checkout@v7 - with: - path: ${{ env.OPENSTUDIO_SOURCE }} - fetch-depth: 1 + - *checkout - name: Verify space shell: bash @@ -693,49 +483,31 @@ jobs: echo - name: Git safe directory - working-directory: ${{ env.OPENSTUDIO_SOURCE }} run: git config --global --add safe.directory '*' - - name: Setup ccache - uses: hendrikmuhs/ccache-action@v1.2 - with: - key: ccache-${{ matrix.os }}-${{ matrix.platform }}-${{ hashFiles('conan.lock') }} - max-size: ${{ env.CCACHE_MAXSIZE }} + - name: Install System dependencies + shell: bash + run: | + # The MACOSX_DEPLOYMENT_TARGET environment variable sets the default value for the CMAKE_OSX_DEPLOYMENT_TARGET variable. + # We use cmake commands to build some subprojects, so setting it globally + echo MACOSX_DEPLOYMENT_TARGET=${{ matrix.macos_dev_target }} >> $GITHUB_ENV + brew install ninja ccache - - name: Restore Conan cache - uses: actions/cache@v6 - with: - path: ~/.conan2 - key: conan-${{ matrix.os }}-${{ matrix.platform }}-${{ hashFiles('conan.lock') }} - restore-keys: | - conan-${{ matrix.os }}-${{ matrix.platform }}- + - *get_base_sha - - name: Remove python ${{ env.PYTHON_REQUIRED_VERSION }} from the toolcache - run: | - ls $RUNNER_TOOL_CACHE/Python || true - rm -Rf "$RUNNER_TOOL_CACHE/Python/${{ env.PYTHON_REQUIRED_VERSION }}" - rm -Rf "$RUNNER_TOOL_CACHE/Python/${{ env.PYTHON_REQUIRED_VERSION }}*/" + - *restore_ccache - name: Set up Python ${{ env.PYTHON_REQUIRED_VERSION }} - id: setup-python - uses: jmarrec/setup-python@v5.4.0 + uses: actions/setup-python@v7 with: python-version: ${{ env.PYTHON_REQUIRED_VERSION }} - # check-latest: true # Force pick up the python I built instead of the (potential) toolcache one. I could also do `rm -Rf $RUNNER_TOOL_CACHE/Python/3.12.2` before this action - - name: Install Python dependencies - working-directory: ${{ env.OPENSTUDIO_SOURCE }} - run: | - python -m pip install --upgrade pip - pip install setuptools wheel - pip install -r python/requirements.txt - pip install conan aqtinstall + - *install_python_deps - name: Install Ruby uses: ruby/setup-ruby@v1 with: ruby-version: '3.2.2' - bundler-cache: true - name: Set up Qt IFW run: | @@ -749,209 +521,50 @@ jobs: ./installerbase --version echo "$(pwd)" >> $GITHUB_PATH - - name: Install System dependencies - shell: bash - run: | - # The MACOSX_DEPLOYMENT_TARGET environment variable sets the default value for the CMAKE_OSX_DEPLOYMENT_TARGET variable. - # We use cmake commands to build some subprojects, so setting it globally - echo MACOSX_DEPLOYMENT_TARGET=${{ matrix.macos_dev_target }} >> $GITHUB_ENV - brew install ninja - - name: Create Build Directory run: cmake -E make_directory ${{ env.OPENSTUDIO_BUILD }} - - name: Cache External Dependencies - uses: actions/cache@v6 - with: - path: | - ${{ env.OPENSTUDIO_BUILD }}/EnergyPlus*.tar.gz - ${{ env.OPENSTUDIO_BUILD }}/EnergyPlus*.zip - ${{ env.OPENSTUDIO_BUILD }}/radiance*.tar.gz - ${{ env.OPENSTUDIO_BUILD }}/radiance*.zip - ${{ env.OPENSTUDIO_BUILD }}/openstudio*gems*.tar.gz - key: external-deps-${{ matrix.os }}-${{ hashFiles('conan.lock') }} - restore-keys: | - external-deps-${{ matrix.os }}- - - - name: Restore Generated Embedded Files - uses: actions/cache@v6 + - name: Setup Conan + uses: ./.github/actions/setup-conan with: - path: | - ${{ env.OPENSTUDIO_BUILD }}/src/*/embedded_files - ${{ env.OPENSTUDIO_BUILD }}/ruby/engine/embedded_files - key: embedded-files-${{ matrix.os }}-${{ hashFiles('resources/**', 'ruby/engine/**', 'src/airflow/**', 'src/energyplus/**', 'src/gbxml/**', 'src/isomodel/**', 'src/radiance/**', 'src/sdd/**', 'src/model/**', 'src/utilities/**') }} - restore-keys: | - embedded-files-${{ matrix.os }}- - - - name: Configure Conan remotes - run: | - conan remote remove nrel-v2 || true - conan remote add --index 0 nrel-v2 https://conan.openstudio.net/artifactory/api/conan/conan-v2 - conan remote remove conancenter || true - conan remote add conancenter https://center2.conan.io - if [ ! -f "$HOME/.conan2/profiles/default" ]; then - conan profile detect - fi - conan config home - - - name: Conan install - working-directory: ${{ env.OPENSTUDIO_SOURCE }} - env: - CONAN_BUILD_POLICY: ${{ contains(inputs.conan_build_all, matrix.platform) && '*' || 'missing' }} - run: | - conan install . \ - --output-folder=../${{ env.OPENSTUDIO_BUILD }} \ - --build="$CONAN_BUILD_POLICY" \ - -c tools.cmake.cmaketoolchain:generator=Ninja \ - -s compiler.cppstd=20 \ - -s build_type=${{ env.BUILD_TYPE }} \ - -s os.version=${{ matrix.macos_dev_target }} \ - -o readline/*:with_library=termcap - - - name: Locate Ruby - run: | - ruby_path=$(command -v ruby) - echo "SYSTEM_RUBY_PATH=$ruby_path" >> $GITHUB_ENV - - - name: Locate Python - run: | - python_path=$(command -v python3) - echo "SYSTEM_PYTHON_PATH=$python_path" >> $GITHUB_ENV - - - name: Install Documentation Dependencies (Mac) - run: | - brew install --cask basictex - echo "/Library/TeX/texbin" >> $GITHUB_PATH + cache-key-prefix: conan-${{ matrix.os }}-${{ matrix.platform }} + build-folder: ${{ env.OPENSTUDIO_BUILD }} + build-type: ${{ env.BUILD_TYPE }} + build-policy: ${{ contains(inputs.conan_build_all, matrix.platform) && '*' || 'missing' }} + # Same as jmarrec/conan-recipes upload_deps.yml, for the deps that have to be built from source (boost with recent clang) + extra-args: -c tools.build:cxxflags="['-D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION', '-Wno-enum-constexpr-conversion']" - name: Configure with CMake - working-directory: ${{ env.OPENSTUDIO_BUILD }} run: | - set -e - chmod +x ./conanbuild.sh - . ./conanbuild.sh - # Use absolute path for ccache to avoid resolution issues in containers with symlinked build dirs - CCACHE_ARGS=() - if command -v ccache >/dev/null 2>&1; then - CCACHE_EXE=$(command -v ccache) - CCACHE_ARGS=("-DCMAKE_C_COMPILER_LAUNCHER=$CCACHE_EXE" "-DCMAKE_CXX_COMPILER_LAUNCHER=$CCACHE_EXE") - fi - - # Signing identity is passed to cpack only when the keychain exists (see Create packages) - cmake -G Ninja \ - "${CCACHE_ARGS[@]}" \ - -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake \ - -DCMAKE_CXX_FLAGS="-D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION -Wno-enum-constexpr-conversion" \ - -DENABLE_COVERAGE:BOOL=OFF \ - -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${{ matrix.macos_dev_target }} \ - -DCMAKE_BUILD_TYPE:STRING=${{ env.BUILD_TYPE }} \ - -DBUILD_TESTING:BOOL=ON \ - -DCPACK_BINARY_TGZ:BOOL=ON \ - -DCPACK_BINARY_IFW:BOOL=ON \ - -DBUILD_PYTHON_BINDINGS:BOOL=ON \ - -DBUILD_PYTHON_PIP_PACKAGE:BOOL=OFF \ - -DPYTHON_VERSION:STRING=${{ env.PYTHON_REQUIRED_VERSION }} \ - -DPython_ROOT_DIR:PATH="$(dirname $(dirname $SYSTEM_PYTHON_PATH))" \ + # Build type, testing, bindings, Python version/root and CPack generators all come from the conanfile.py preset, + # the libc++ CXX flags from the tools.build:cxxflags conf (see Setup Conan), the deployment target from MACOSX_DEPLOYMENT_TARGET. + # ruby/test/CMakeLists.txt only looks in hardcoded locations (NO_DEFAULT_PATH, to avoid the conan ruby), not in setup-ruby's toolcache + cmake --preset conan-release \ + -DSYSTEM_RUBY_EXECUTABLE:FILEPATH="$(command -v ruby)" \ -DENABLE_PCH:BOOL=${{ env.ENABLE_PCH }} \ - -DCMAKE_JOB_POOL_LINK:STRING=console \ - ../${{ env.OPENSTUDIO_SOURCE }} + -DCMAKE_JOB_POOL_LINK:STRING=console - - name: Build with Ninja - working-directory: ${{ env.OPENSTUDIO_BUILD }} - run: | - . ./conanbuild.sh - export NINJA_STATUS="[%f/%t | %es elapsed | %o objs/sec]" - while true; do - sleep 300 - echo "[heartbeat] $(date -u +"%H:%M:%S")" - if command -v top >/dev/null 2>&1; then top -l 1 -s 0 | grep PhysMem || true; fi - df -h . | tail -1 | awk '{print "[disk] used=" $3 "/" $2 " (" $5 ")"}' - if command -v ps >/dev/null 2>&1; then ps -eo pid,pmem,rss,comm | sort -rn -k2 | head -n 5; fi - done & - heartbeat_pid=$! - cmake --build . --parallel ${MAX_BUILD_THREADS} 2>&1 | tee build.log - build_exit=${PIPESTATUS[0]} - kill $heartbeat_pid || true - command -v ninja >/dev/null 2>&1 && ninja -d stats || true - if [ -f build.log ]; then tail -n 40 build.log; fi - exit $build_exit - - - name: Wait for network stability - if: always() - run: sleep 5 + - *show_restored_ccache_stats - - name: Upload build diagnostics - if: always() - uses: actions/upload-artifact@v7 - with: - name: build-diag-${{ matrix.platform }}-${{ github.sha }} - path: | - ${{ env.OPENSTUDIO_BUILD }}/build.log - ${{ env.OPENSTUDIO_BUILD }}/.ninja_log - ${{ env.OPENSTUDIO_BUILD }}/CTestTestfile.cmake - if-no-files-found: warn - - - name: Run CTest suite - id: mac_ctest - working-directory: ${{ env.OPENSTUDIO_BUILD }} - shell: bash - continue-on-error: true - run: | - gem install bundler -v 2.4.10 --conservative --no-document - - overall_exit_code=0 - - begin_group() { echo -e "::group::\033[93m$1\033[0m"; } - - export CTEST_OUTPUT_ON_FAILURE=1 - exclude_pattern="${{ matrix.exclude_regex }}" - - # Conflicting tests that must run sequentially - resource_locked_tests=( - ModelFixture.ScheduleFile - ModelFixture.ScheduleFileAltCtor - ModelFixture.PythonPluginInstance - ModelFixture.PythonPluginInstance_NotPYFile - ModelFixture.PythonPluginInstance_ClassNameValidation - ModelFixture.ChillerElectricASHRAE205_GettersSetters - ModelFixture.ChillerElectricASHRAE205_Loops - ModelFixture.ChillerElectricASHRAE205_NotCBORFile - ModelFixture.ChillerElectricASHRAE205_Clone - ) - resource_locked_pattern=$(IFS='|'; echo "${resource_locked_tests[*]}") - - ctest_command=(ctest -C ${{ env.BUILD_TYPE }} -T test --no-compress-output) - seq_exclude_args=() - if [ -n "$exclude_pattern" ]; then - seq_exclude_args=(-E "^($exclude_pattern)$") - final_exclude="$exclude_pattern|$resource_locked_pattern" - else - final_exclude="$resource_locked_pattern" - fi + - *build_with_ninja - begin_group "Running sequential tests..." - echo "Running: ${ctest_command[@]} ${seq_exclude_args[@]} -R '^($resource_locked_pattern)$' -j 1" - "${ctest_command[@]}" "${seq_exclude_args[@]}" -R "^($resource_locked_pattern)$" -j 1 || overall_exit_code=$? - echo "::endgroup::" + - *show_ccache_stats - ctest_command+=(-E "^($final_exclude)$") + - *save_ccache - begin_group "Running all other tests in parallel..." - echo "Running: ${ctest_command[@]} -j ${{ matrix.max_jobs }}" - "${ctest_command[@]}" -j ${{ matrix.max_jobs }} || overall_exit_code=$? - echo "::endgroup::" + - *upload_build_diagnostics - if [ $overall_exit_code -ne 0 ]; then - begin_group "Rerunning failing tests..." - echo "Running: ${ctest_command[@]} --rerun-failed --output-on-failure" - "${ctest_command[@]}" --rerun-failed --output-on-failure && overall_exit_code=0 || overall_exit_code=$? - echo "::endgroup::" - fi + - name: Install bundler + if: env.SKIP_TESTS != 'true' + shell: bash + run: gem install bundler -v 2.4.10 --conservative --no-document - echo "exit_code=${overall_exit_code}" >> $GITHUB_OUTPUT + - *run_ctest - name: Setup Keychain - # Same refs as macos-publish, so everything published to S3 is signed - if: success() && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') || inputs.publish_to_s3 == true || github.event.inputs.publish_to_s3 == 'true') + # Same refs as the job's environment: the Apple secrets are apple-signing environment secrets, which can only deploy to develop/master/v* tags. + # So a publish_to_s3 dispatch from another branch publishes an unsigned DMG instead of failing here. + if: success() && github.repository == 'NatLabRockies/OpenStudio' && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) env: APPLE_CERT_DATA: ${{ secrets.APPLE_CERT_DATA }} APPLE_CERT_PASSWORD: ${{ secrets.APPLE_CERT_PASSWORD }} @@ -1009,13 +622,6 @@ jobs: fi cpack -C ${{ env.BUILD_TYPE }} "${SIGNING_ARGS[@]}" - - name: Cleanup intermediate files - if: always() - working-directory: ${{ env.OPENSTUDIO_BUILD }} - run: | - find . -name "*.o" -type f -delete || true - df -h . - - name: Ad-hoc Sign Inner Installer (Fix "Killed" Error) if: ${{ success() && !cancelled() }} working-directory: ${{ env.OPENSTUDIO_BUILD }} @@ -1031,7 +637,7 @@ jobs: # Loop through all generated DMGs find . -maxdepth 1 -name "*.dmg" -print0 | while IFS= read -r -d '' dmg_file; do - ../${{ env.OPENSTUDIO_SOURCE }}/developer/scripts/patch_adhoc_dmg.sh "$dmg_file" + ../developer/scripts/patch_adhoc_dmg.sh "$dmg_file" done - name: Sign DMG and Notarize @@ -1101,46 +707,11 @@ jobs: security delete-keychain "$KEYCHAIN_PATH" || true fi - - name: Copy Testing tree with suffix - if: always() - working-directory: ${{ env.OPENSTUDIO_BUILD }} - run: | - if [ -d "Testing" ]; then - cp -r Testing "Testing-${{ matrix.test_suffix }}" - fi - - - name: Generate test summary - if: always() - working-directory: ${{ env.OPENSTUDIO_BUILD }} - run: | + - *copy_testing_tree - # Generate a simple markdown summary from CTest results - mkdir -p "$(dirname '${{ env.TEST_DASHBOARD_RELATIVE }}')" - - echo "# OpenStudio Test Results - ${{ matrix.test_suffix }}" > "${{ env.TEST_DASHBOARD_RELATIVE }}" - echo "" >> "${{ env.TEST_DASHBOARD_RELATIVE }}" - echo "**Build:** \`${{ github.sha }}\`" >> "${{ env.TEST_DASHBOARD_RELATIVE }}" - echo "**Branch:** \`${{ github.ref_name }}\`" >> "${{ env.TEST_DASHBOARD_RELATIVE }}" - echo "**Platform:** ${{ matrix.pretty }}" >> "${{ env.TEST_DASHBOARD_RELATIVE }}" - echo "**Date:** $(date -u)" >> "${{ env.TEST_DASHBOARD_RELATIVE }}" - echo "" >> "${{ env.TEST_DASHBOARD_RELATIVE }}" - - if [ -f Testing/Temporary/LastTest.log ]; then - echo "## Test Log (Last 50 lines)" >> "${{ env.TEST_DASHBOARD_RELATIVE }}" - echo '```' >> "${{ env.TEST_DASHBOARD_RELATIVE }}" - tail -50 Testing/Temporary/LastTest.log >> "${{ env.TEST_DASHBOARD_RELATIVE }}" - echo '```' >> "${{ env.TEST_DASHBOARD_RELATIVE }}" - fi - continue-on-error: true + - *generate_test_summary - - name: Upload Testing artifact - if: always() - uses: actions/upload-artifact@v7 - with: - name: Testing-${{ matrix.platform }}-${{ github.sha }} - path: | - ${{ env.OPENSTUDIO_BUILD }}/Testing-${{ matrix.test_suffix }}/ - ${{ env.OPENSTUDIO_BUILD }}/${{ env.TEST_DASHBOARD_RELATIVE }} + - *upload_testing_artifact - name: Determine installer path id: installer_path @@ -1158,7 +729,7 @@ jobs: if: always() uses: actions/upload-artifact@v7 with: - name: OS-IFW-${{ matrix.platform }}-${{ github.sha }} + name: OS-Installers-${{ matrix.platform }}-IFW-${{ github.sha }} path: ${{ steps.installer_path.outputs.path }} if-no-files-found: ignore @@ -1166,50 +737,11 @@ jobs: if: always() uses: actions/upload-artifact@v7 with: - name: OS-TGZ-${{ matrix.platform }}-${{ github.sha }} + name: OS-Installers-${{ matrix.platform }}-TGZ-${{ github.sha }} path: ${{ env.OPENSTUDIO_BUILD }}/OpenStudio-*.tar.gz if-no-files-found: ignore - - name: Fail job on test failures - if: ${{ steps.mac_ctest.outputs.exit_code != '0' }} - run: | - echo "::error::CTest suite failed with exit code ${{ steps.mac_ctest.outputs.exit_code }}" - exit 1 - macos-publish: - name: Publish MacOS Artifacts - needs: [macos-build] - runs-on: ubuntu-latest - if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') || inputs.publish_to_s3 == true || github.event.inputs.publish_to_s3 == 'true' - steps: - - name: Download all installers - uses: actions/download-artifact@v8 - with: - pattern: OS-*-macos* - merge-multiple: true - path: installers - - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v6 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: ${{ secrets.AWS_REGION || 'us-west-2' }} - - - name: Publish to S3 - working-directory: installers - env: - S3_PREFIX: ${{ github.ref_type == 'tag' && format('releases/{0}/signed', github.ref_name) || format('{0}/signed', github.ref_name) }} - AWS_S3_BUCKET: openstudio-ci-builds - run: | - echo "Uploading artifacts to s3://${AWS_S3_BUCKET}/${S3_PREFIX}" - for file in *; do - [ -e "$file" ] || continue - [ -f "$file" ] || continue - filename=$(basename "$file") - key="${S3_PREFIX}/${filename}" - aws s3 cp "$file" "s3://${AWS_S3_BUCKET}/${key}" --acl public-read - if command -v md5sum >/dev/null 2>&1; then md5sum "$file"; else md5 "$file"; fi - done + - *fail_on_test_failures windows-build: name: Build ${{ matrix.pretty }} @@ -1229,87 +761,59 @@ jobs: arch: x86_64 python-arch: x64 allow_failure: false - max_jobs: 4 exclude_regex: "" defaults: run: shell: pwsh env: - MAX_BUILD_THREADS: ${{ matrix.max_jobs }} + CCACHE_DIR: ${{ github.workspace }}\.ccache RUBYOPT: "-Eutf-8:utf-8" PYTHONUTF8: "1" permissions: contents: write steps: - - name: Checkout repository - uses: actions/checkout@v7 - with: - path: ${{ env.OPENSTUDIO_SOURCE }} - fetch-depth: 1 + - *checkout - name: Verify space run: | - Get-PSDrive C | Select-Object Used,Free + # Workspace, build and ccache are on D:, the Conan home on C: + Get-PSDrive C, D | Select-Object Name, @{n='UsedGB';e={[math]::Round($_.Used/1GB,1)}}, @{n='FreeGB';e={[math]::Round($_.Free/1GB,1)}} Get-CimInstance Win32_OperatingSystem | Select-Object TotalVisibleMemorySize,FreePhysicalMemory,TotalVirtualMemorySize,FreeVirtualMemory - name: Git safe directory - working-directory: ${{ env.OPENSTUDIO_SOURCE }} run: git config --global --add safe.directory '*' - name: Test signing scripts - working-directory: ${{ env.OPENSTUDIO_SOURCE }} run: | ./.github/signing-client/Test-SigningWithRetry.ps1 if ($LASTEXITCODE) { exit 1 } ./.github/signing-client/Test-AssertAuthenticodeSigned.ps1 - - name: Restore sccache cache - uses: actions/cache@v6 - with: - path: ${{ github.workspace }}\.sccache - key: sccache-${{ matrix.os }}-${{ matrix.platform }}-${{ hashFiles('conan.lock') }} - restore-keys: | - sccache-${{ matrix.os }}-${{ matrix.platform }}- + - name: Install ccache + # Not sccache: it refuses to cache MSVC compiles using PCH (/Yc, /Fp), i.e. ~95% of them + run: choco install ccache -y --no-progress + + - *get_base_sha + + - *restore_ccache - name: Prepare workspace run: | - git config --global --add safe.directory "*" New-Item -ItemType Directory -Path "${{ env.OPENSTUDIO_BUILD }}" -Force - - name: Setup sccache - uses: Mozilla-Actions/sccache-action@v0.0.5 - - - name: Restore Conan cache - uses: actions/cache@v6 - with: - path: ~/.conan2 - key: conan-${{ matrix.os }}-windows-${{ hashFiles('conan.lock') }} - restore-keys: | - conan-${{ matrix.os }}-windows- - - name: Set up Python 3.12.2 uses: actions/setup-python@v7 with: python-version: '3.12.2' cache: 'pip' - - name: Install Python dependencies - working-directory: ${{ env.OPENSTUDIO_SOURCE }} - run: | - python -m pip install --upgrade pip setuptools wheel - python -m pip install -r python/requirements.txt - - - name: Install Conan - working-directory: ${{ env.OPENSTUDIO_SOURCE }} - run: | - python -m pip install conan + - *install_python_deps - name: Install Ruby uses: ruby/setup-ruby@v1 with: ruby-version: '3.2.2' - bundler-cache: true - name: Setup QtIFW 4.x uses: jmarrec/setup-qtifw@v1 @@ -1319,220 +823,67 @@ jobs: - name: Create Build Directory run: cmake -E make_directory ${{ env.OPENSTUDIO_BUILD }} - - name: Configure Conan remotes - run: | - conan remote remove nrel-v2 - if ($LASTEXITCODE -ne 0) { $LASTEXITCODE = 0 } - conan remote add nrel-v2 https://conan.openstudio.net/artifactory/api/conan/conan-v2 - if ($LASTEXITCODE -ne 0) { throw "Failed to add nrel-v2 remote" } - conan remote enable nrel-v2 - - conan remote remove conancenter - if ($LASTEXITCODE -ne 0) { $LASTEXITCODE = 0 } - conan remote add conancenter https://center2.conan.io - if ($LASTEXITCODE -ne 0) { throw "Failed to add conancenter remote" } - conan remote enable conancenter - - if (-not (Test-Path "$env:USERPROFILE/.conan2/profiles/default")) { - conan profile detect - } - conan config home - - - name: Conan install - working-directory: ${{ env.OPENSTUDIO_SOURCE }} - env: - CONAN_BUILD_POLICY: ${{ contains(inputs.conan_build_all, matrix.platform) && '*' || 'missing' }} - run: | - conan install . ` - --output-folder="../${{ env.OPENSTUDIO_BUILD }}" ` - --build="$env:CONAN_BUILD_POLICY" ` - -c tools.cmake.cmaketoolchain:generator=Ninja ` - -s compiler.cppstd=20 ` - -s build_type=${{ env.BUILD_TYPE }} ` - --lockfile-partial --lockfile-out=conan.lock - git diff conan.lock - - - name: Locate Ruby - run: | - $rubyPath = (Get-Command ruby).Source - "SYSTEM_RUBY_PATH=$rubyPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - - - name: Locate Python - run: | - $pythonPath = (Get-Command python).Source - "SYSTEM_PYTHON_PATH=$pythonPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + - name: Setup Conan + uses: ./.github/actions/setup-conan + with: + cache-key-prefix: conan-${{ matrix.os }}-${{ matrix.platform }} + build-folder: ${{ env.OPENSTUDIO_BUILD }} + build-type: ${{ env.BUILD_TYPE }} + build-policy: ${{ contains(inputs.conan_build_all, matrix.platform) && '*' || 'missing' }} - name: Configure with CMake - working-directory: ${{ env.OPENSTUDIO_BUILD }} - run: | - $sccacheExe = (Get-Command sccache).Source - & $env:ComSpec /c "call conanbuild.bat && cmake -G Ninja -DCMAKE_C_COMPILER_LAUNCHER=`"$sccacheExe`" -DCMAKE_CXX_COMPILER_LAUNCHER=`"$sccacheExe`" -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE:STRING=${{ env.BUILD_TYPE }} -DBUILD_TESTING:BOOL=ON -DCPACK_GENERATOR:STRING=`"IFW;TGZ`" -DBUILD_PYTHON_BINDINGS:BOOL=ON -DBUILD_PYTHON_PIP_PACKAGE:BOOL=OFF -DPython_EXECUTABLE:FILEPATH=`"$env:SYSTEM_PYTHON_PATH`" -DPYTHON_VERSION:STRING=${{ env.PYTHON_REQUIRED_VERSION }} -DSYSTEM_RUBY_EXECUTABLE=`"%SYSTEM_RUBY_PATH%`" -DENABLE_PCH:BOOL=${{ env.ENABLE_PCH }} -DCMAKE_JOB_POOL_LINK:STRING=console `"../${{ env.OPENSTUDIO_SOURCE }}"`" - - - name: Build with Ninja - working-directory: ${{ env.OPENSTUDIO_BUILD }} - shell: pwsh + # From the source dir: that's where conan put the CMakeUserPresets.json. Toolchain, Ninja, build type, testing, bindings, Python version/root and CPack generators all come from the conanfile.py preset run: | - if (Get-Command sccache -ErrorAction SilentlyContinue) { sccache -s } - # Use $env:ComSpec to ensure we call the Windows Command Prompt, not the MSYS2 cmd found in PATH - & $env:ComSpec /c "call conanbuild.bat && cmake --build . --parallel ${{ matrix.max_jobs }} -- -d stats 2>&1" | Tee-Object -FilePath "build.log" + # ruby/test/CMakeLists.txt only looks in hardcoded locations (NO_DEFAULT_PATH, to avoid the conan ruby), not in setup-ruby's toolcache + $rubyExe = (Get-Command ruby).Source + # $env:ComSpec, not cmd: setup-ruby puts its MSYS2 usr/bin, which has a 'cmd' script, ahead in the PATH (that's also why we can't use conan's conanbuild.ps1) + & $env:ComSpec /c "call ${{ env.OPENSTUDIO_BUILD }}\conanbuild.bat && cmake --preset conan-release -DSYSTEM_RUBY_EXECUTABLE:FILEPATH=`"$rubyExe`" -DENABLE_PCH:BOOL=${{ env.ENABLE_PCH }} -DCMAKE_JOB_POOL_LINK:STRING=console" - # Check the exit code of the cmd process, not Tee-Object - if ($LASTEXITCODE -ne 0) { - Write-Error "Build failed with exit code $LASTEXITCODE" - exit $LASTEXITCODE - } - if (Get-Command sccache -ErrorAction SilentlyContinue) { sccache -s } - - - name: Wait for network stability - if: always() - run: Start-Sleep -Seconds 5 + - *show_restored_ccache_stats - - name: Upload build diagnostics - if: always() - uses: actions/upload-artifact@v7 - with: - name: build-diag-${{ matrix.platform }}-${{ github.sha }} - path: | - ${{ env.OPENSTUDIO_BUILD }}/build.log - ${{ env.OPENSTUDIO_BUILD }}/.ninja_log - ${{ env.OPENSTUDIO_BUILD }}/CTestTestfile.cmake - if-no-files-found: warn - - - name: Run CTest suite - id: ctest - continue-on-error: true - working-directory: ${{ env.OPENSTUDIO_BUILD }} - shell: pwsh + - name: Build with Ninja run: | - $env_vars = & $env:ComSpec /c "call conanbuild.bat && set" - foreach ($line in $env_vars) { - if ($line -match '^(.*?)=(.*)$') { - $name = $matches[1] - $value = $matches[2] - if ($name -ne "" -and $name -notmatch "^=") { - [Environment]::SetEnvironmentVariable($name, $value, "Process") - } - } - } + # $env:ComSpec, not cmd: see Configure with CMake + & $env:ComSpec /c "call ${{ env.OPENSTUDIO_BUILD }}\conanbuild.bat && cmake --build --preset conan-release -- -d stats 2>&1" | Tee-Object -FilePath "${{ env.OPENSTUDIO_BUILD }}\build.log" + # The exit code of the cmd process, not Tee-Object's + exit $LASTEXITCODE - # Conflicting tests that must run sequentially - $resource_locked_tests = @( - "ModelFixture.ScheduleFile", - "ModelFixture.ScheduleFileAltCtor", - "ModelFixture.PythonPluginInstance", - "ModelFixture.PythonPluginInstance_NotPYFile", - "ModelFixture.PythonPluginInstance_ClassNameValidation", - "ModelFixture.ChillerElectricASHRAE205_GettersSetters", - "ModelFixture.ChillerElectricASHRAE205_Loops", - "ModelFixture.ChillerElectricASHRAE205_NotCBORFile", - "ModelFixture.ChillerElectricASHRAE205_Clone" - ) - $resource_locked_pattern = $resource_locked_tests -join "|" - - $overall_exit_code = 0 - $exclude_pattern = "${{ matrix.exclude_regex }}" - - $env:CTEST_OUTPUT_ON_FAILURE = "1" - - function begin_group($msg) { Write-Host "::group::$([char]27)[93m$msg$([char]27)[0m" } - - $ctest_command = @("ctest", "-C", "${{ env.BUILD_TYPE }}", "-T", "test", "--no-compress-output") - - $seq_exclude_args = @() - if (-not [string]::IsNullOrEmpty($exclude_pattern)) { - $seq_exclude_args = @("-E", "^($exclude_pattern)$") - $final_exclude = "$exclude_pattern|$resource_locked_pattern" - } else { - $final_exclude = $resource_locked_pattern - } + - *show_ccache_stats - begin_group "Running sequential tests..." - Write-Host "Running: $($ctest_command -join ' ') $($seq_exclude_args -join ' ') -R '^($resource_locked_pattern)$' -j 1" - & $ctest_command[0] $ctest_command[1..($ctest_command.Length-1)] @seq_exclude_args -R "^($resource_locked_pattern)$" -j 1 - if ($LASTEXITCODE -ne 0) { $overall_exit_code = $LASTEXITCODE } - Write-Host "::endgroup::" + - *save_ccache - $ctest_command += @("-E", "^($final_exclude)$") + - *upload_build_diagnostics - begin_group "Running all other tests in parallel..." - Write-Host "Running: $($ctest_command -join ' ') -j ${{ matrix.max_jobs }}" - & $ctest_command[0] $ctest_command[1..($ctest_command.Length-1)] -j ${{ matrix.max_jobs }} - if ($LASTEXITCODE -ne 0) { $overall_exit_code = $LASTEXITCODE } - Write-Host "::endgroup::" + - *run_ctest - if ($overall_exit_code -ne 0) { - begin_group "Rerunning failing tests..." - Write-Host "Running: $($ctest_command -join ' ') --rerun-failed --output-on-failure" - & $ctest_command[0] $ctest_command[1..($ctest_command.Length-1)] --rerun-failed --output-on-failure - if ($LASTEXITCODE -eq 0) { $overall_exit_code = 0 } else { $overall_exit_code = $LASTEXITCODE } - Write-Host "::endgroup::" - } - "exit_code=$overall_exit_code" | Out-File -FilePath $env:GITHUB_OUTPUT -Append + - *copy_testing_tree - - name: Copy Testing tree with suffix - if: always() - working-directory: ${{ env.OPENSTUDIO_BUILD }} - run: | - if (Test-Path "Testing") { - Copy-Item -Path "Testing" -Destination "Testing-${{ matrix.test_suffix }}" -Recurse -Force - } + - *generate_test_summary - - name: Generate test summary - if: always() - working-directory: ${{ env.OPENSTUDIO_BUILD }} - run: | - $dashboardPath = "${{ env.TEST_DASHBOARD_RELATIVE }}" - $dashboardDir = Split-Path -Parent $dashboardPath - if (-not (Test-Path $dashboardDir)) { New-Item -ItemType Directory -Path $dashboardDir -Force } - - "# OpenStudio Test Results - ${{ matrix.test_suffix }}" | Out-File -FilePath $dashboardPath -Encoding utf8 - "" | Out-File -FilePath $dashboardPath -Encoding utf8 -Append - "**Build:** ``${{ github.sha }}``" | Out-File -FilePath $dashboardPath -Encoding utf8 -Append - "**Branch:** ``${{ github.ref_name }}``" | Out-File -FilePath $dashboardPath -Encoding utf8 -Append - "**Platform:** ${{ matrix.pretty }}" | Out-File -FilePath $dashboardPath -Encoding utf8 -Append - "**Date:** $(Get-Date -Format u)" | Out-File -FilePath $dashboardPath -Encoding utf8 -Append - "" | Out-File -FilePath $dashboardPath -Encoding utf8 -Append - - if (Test-Path "Testing/Temporary/LastTest.log") { - "## Test Log (Last 50 lines)" | Out-File -FilePath $dashboardPath -Encoding utf8 -Append - '```' | Out-File -FilePath $dashboardPath -Encoding utf8 -Append - Get-Content "Testing/Temporary/LastTest.log" -Tail 50 | Out-File -FilePath $dashboardPath -Encoding utf8 -Append - '```' | Out-File -FilePath $dashboardPath -Encoding utf8 -Append - } - continue-on-error: true - - - name: Upload Testing artifact - if: always() - uses: actions/upload-artifact@v7 - with: - name: Testing-${{ matrix.platform }}-${{ github.sha }} - path: | - ${{ env.OPENSTUDIO_BUILD }}/Testing-${{ matrix.test_suffix }}/ - ${{ env.OPENSTUDIO_BUILD }}/${{ env.TEST_DASHBOARD_RELATIVE }} + - *upload_testing_artifact # CODE SIGNING SETUP - name: Setup Node.js - if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') || inputs.publish_to_s3 == true || github.event.inputs.publish_to_s3 == 'true' + if: github.repository == 'NatLabRockies/OpenStudio' && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') || inputs.publish_to_s3 == true || github.event.inputs.publish_to_s3 == 'true') uses: actions/setup-node@v7 with: node-version: "18" - - name: Create .env file for Signing - if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') || inputs.publish_to_s3 == true || github.event.inputs.publish_to_s3 == 'true' + if: github.repository == 'NatLabRockies/OpenStudio' && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') || inputs.publish_to_s3 == true || github.event.inputs.publish_to_s3 == 'true') working-directory: ${{ env.OPENSTUDIO_BUILD }} run: | echo "ACCESS_KEY=${{ secrets.AWS_SIGNING_ACCESS_KEY }}" >> .env echo "SECRET_KEY=${{ secrets.AWS_SIGNING_SECRET_KEY }}" >> .env - name: Code sign binaries - if: success() && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') || inputs.publish_to_s3 == true || github.event.inputs.publish_to_s3 == 'true') + if: success() && github.repository == 'NatLabRockies/OpenStudio' && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') || inputs.publish_to_s3 == true || github.event.inputs.publish_to_s3 == 'true') # Caps a hung signing service; Invoke-SigningWithRetry.ps1 sizes its 3 attempts to fit inside this timeout-minutes: 60 working-directory: ${{ env.OPENSTUDIO_BUILD }} run: | # This step only runs on refs that publish, so a missing client or secret must fail rather than ship unsigned - $signingDir = "../${{ env.OPENSTUDIO_SOURCE }}/.github/signing-client" + $signingDir = "../.github/signing-client" if (-not (Test-Path "$signingDir/code-signing.js")) { Write-Host "::error::Code signing client not found at .github/signing-client/code-signing.js" exit 1 @@ -1591,13 +942,13 @@ jobs: & $env:ComSpec /c "call conanbuild.bat && cpack -C ${{ env.BUILD_TYPE }}" - name: Code sign installer - if: success() && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') || inputs.publish_to_s3 == true || github.event.inputs.publish_to_s3 == 'true') + if: success() && github.repository == 'NatLabRockies/OpenStudio' && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') || inputs.publish_to_s3 == true || github.event.inputs.publish_to_s3 == 'true') # Caps a hung signing service; Invoke-SigningWithRetry.ps1 sizes its 3 attempts to fit inside this timeout-minutes: 60 working-directory: ${{ env.OPENSTUDIO_BUILD }} run: | # The binaries step already failed if the client or secret is missing - $signingDir = "../${{ env.OPENSTUDIO_SOURCE }}/.github/signing-client" + $signingDir = "../.github/signing-client" Write-Host "------------------------------------------------------------" Write-Host "Signing Final Installer" @@ -1646,19 +997,6 @@ jobs: Remove-Item $signedInstallerZip -Force Write-Host "Installer signed successfully." - - name: Cleanup intermediate files - if: always() - working-directory: ${{ env.OPENSTUDIO_BUILD }} - run: | - Get-ChildItem -Path . -Include "*.obj" -Recurse -Force | Remove-Item -Force -ErrorAction SilentlyContinue - Get-PSDrive C | Select-Object Used,Free - - - name: Fail job on test failures - if: ${{ steps.ctest.outputs.exit_code != '0' }} - run: | - echo "::error::CTest suite failed with exit code ${{ steps.ctest.outputs.exit_code }}" - exit 1 - - name: Upload Signed EXE installer uses: actions/upload-artifact@v7 with: @@ -1682,19 +1020,23 @@ jobs: path: ${{ env.OPENSTUDIO_BUILD }}/_CPack_Packages/win64/TGZ/*.tar.gz if-no-files-found: ignore - windows-publish: - name: Publish Windows Artifacts - needs: [windows-build] + - *fail_on_test_failures + + linux-publish: + name: Publish Linux Artifacts + needs: [linux-build] runs-on: ubuntu-latest - if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') || inputs.publish_to_s3 == true || github.event.inputs.publish_to_s3 == 'true' + if: &publish_if github.repository == 'NatLabRockies/OpenStudio' && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') || inputs.publish_to_s3 == true || github.event.inputs.publish_to_s3 == 'true') steps: - name: Download all installers uses: actions/download-artifact@v8 with: - pattern: OS-Installers-windows-2022-x64-* + pattern: OS-Installers-{ubuntu,centos}-* + merge-multiple: true path: installers - - name: Configure AWS credentials + - &configure_aws_credentials + name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v6 with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} @@ -1704,20 +1046,129 @@ jobs: - name: Publish to S3 working-directory: installers env: - S3_PREFIX: ${{ github.ref_type == 'tag' && format('releases/{0}/signed', github.ref_name) || format('{0}/signed', github.ref_name) }} - AWS_S3_BUCKET: openstudio-ci-builds - run: | + S3_PREFIX: ${{ github.ref_type == 'tag' && format('releases/{0}', github.ref_name) || format('{0}', github.ref_name) }} + run: &s3_upload | echo "Uploading artifacts to s3://${AWS_S3_BUCKET}/${S3_PREFIX}" - - # windows-build only uploads the EXE after signing and verifying it - find . -name "*.exe" | while read -r file; do - echo "Uploading signed installer: $file" - aws s3 cp "$file" "s3://${AWS_S3_BUCKET}/${S3_PREFIX}/$(basename "$file")" --acl public-read - done - - # Upload tarballs - for file in $(find . -name "*.tar.gz"); do + for file in *; do + [ -e "$file" ] || continue + [ -f "$file" ] || continue filename=$(basename "$file") - aws s3 cp "$file" "s3://${AWS_S3_BUCKET}/${S3_PREFIX}/${filename}" --acl public-read + key="${S3_PREFIX}/${filename}" + aws s3 cp "$file" "s3://${AWS_S3_BUCKET}/${key}" --acl public-read + if command -v md5sum >/dev/null 2>&1; then md5sum "$file"; else md5 "$file"; fi done + - name: Trigger Docker Build + if: inputs.skip_docker_trigger != true && github.event.inputs.skip_docker_trigger != 'true' + working-directory: installers + env: + GH_TOKEN: ${{ secrets.DOCKER_OPENSTUDIO_PAT }} + BRANCH_NAME: ${{ github.ref_name }} + S3_PREFIX: ${{ github.ref_type == 'tag' && format('releases/{0}', github.ref_name) || format('{0}', github.ref_name) }} + run: | + + # Find the 24.04 deb file locally + DEB_FILE=$(find . -name "*24.04*.deb" | head -n 1) + if [ -z "$DEB_FILE" ]; then + echo "::error::Could not find Ubuntu 24.04 deb file in installers directory" + ls -la + exit 1 + fi + + FILENAME=$(basename "$DEB_FILE") + echo "Found file: $FILENAME" + + # Construct S3 URL + # Replace + with %2B + ENCODED_FILENAME=${FILENAME//+/%2B} + BINARY_URL="https://${AWS_S3_BUCKET}.s3.amazonaws.com/${S3_PREFIX}/${ENCODED_FILENAME}" + echo "Binary URL: $BINARY_URL" + + # Parse version from filename + # Expected format: OpenStudio--.deb + if [[ "$FILENAME" =~ OpenStudio-(.+)-Ubuntu-24\.04.*\.deb ]]; then + OS_VERSION_FULL=${BASH_REMATCH[1]} + elif [[ "$FILENAME" =~ OpenStudio-(.+)-Linux.*\.deb ]]; then + OS_VERSION_FULL=${BASH_REMATCH[1]} + else + echo "::error::Could not parse version from filename: $FILENAME" + exit 1 + fi + + echo "Full Version: $OS_VERSION_FULL" + + # Logic from Jenkins: + # Split by + + IFS='+' read -r VER_PART SHA_PART <<< "$OS_VERSION_FULL" + + if [[ "$VER_PART" == *"-"* ]]; then + # 3.3.0-rc1 -> Ver: 3.3.0, Ext: rc1 + IFS='-' read -r OS_VERSION OS_VERSION_EXT <<< "$VER_PART" + else + # 3.3.0+sha -> Ver: 3.3.0, Ext: sha + OS_VERSION="$VER_PART" + OS_VERSION_EXT="$SHA_PART" + fi + + echo "OS Version: $OS_VERSION" + echo "OS Version Ext: $OS_VERSION_EXT" + + # Docker Tag Logic + if [[ "$BRANCH_NAME" == "develop" ]]; then + DOCKER_IMAGE_TAG="develop" + else + DOCKER_IMAGE_TAG="${OS_VERSION}-${OS_VERSION_EXT}" + fi + echo "Docker Image Tag: $DOCKER_IMAGE_TAG" + + # Trigger Workflow + echo "Triggering manual_update_develop workflow in NatLabRockies/docker-openstudio..." + gh workflow run 'manual_update_develop' \ + --repo NatLabRockies/docker-openstudio \ + --ref develop \ + -f docker_image_tag="$DOCKER_IMAGE_TAG" \ + -f os_installer_link="$BINARY_URL" \ + -f os_version="$OS_VERSION" \ + -f os_version_ext="$OS_VERSION_EXT" + + macos-publish: + name: Publish MacOS Artifacts + needs: [macos-build] + runs-on: ubuntu-latest + if: *publish_if + steps: + - name: Download all installers + uses: actions/download-artifact@v8 + with: + pattern: OS-Installers-macos-* + merge-multiple: true + path: installers + + - *configure_aws_credentials + + - name: Publish to S3 + working-directory: installers + env: + S3_PREFIX: ${{ github.ref_type == 'tag' && format('releases/{0}/signed', github.ref_name) || format('{0}/signed', github.ref_name) }} + run: *s3_upload + + windows-publish: + name: Publish Windows Artifacts + needs: [windows-build] + runs-on: ubuntu-latest + if: *publish_if + steps: + - name: Download all installers + uses: actions/download-artifact@v8 + with: + pattern: OS-Installers-windows-* + merge-multiple: true + path: installers + + - *configure_aws_credentials + + - name: Publish to S3 + working-directory: installers + env: + S3_PREFIX: ${{ github.ref_type == 'tag' && format('releases/{0}/signed', github.ref_name) || format('{0}/signed', github.ref_name) }} + run: *s3_upload diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b7f80cbae2..5f48af1f549 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -216,6 +216,7 @@ set(RADIANCE_VERSION "5.0.a.12") # configure file with version information configure_file(${PROJECT_SOURCE_DIR}/OpenStudio.hxx.in ${PROJECT_BINARY_DIR}/src/OpenStudio.hxx) +configure_file(${PROJECT_SOURCE_DIR}/OpenStudio.cxx.in ${PROJECT_BINARY_DIR}/src/OpenStudio.cxx) # Deployment target if(APPLE) @@ -415,6 +416,14 @@ endif() option(ENABLE_PCH "Enable Precompiled Headers" ON) mark_as_advanced(ENABLE_PCH) +if(ENABLE_PCH AND CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # Without this, Clang embeds a timestamp in the generated .pch, so its content hash differs + # on every build even when sources/headers are unchanged. ccache hashes that .pch content for + # both the direct-mode manifest and the preprocessor-mode result key, so every TU using + # -include-pch becomes a guaranteed cache miss. See ccache manual, "Precompiled Headers". + add_compile_options("$<$:SHELL:-Xclang -fno-pch-timestamp>") +endif() + option(USE_LTO "Use Link-Time-Optimization" OFF) if (USE_LTO) @@ -1060,6 +1069,8 @@ else() endif() include("embedded/EmbedFiles.cmake") +# Each embed_files() call adds its own embedded_files_ target as a dependency of this one +add_custom_target(embedded_files) add_subdirectory("embedded") if(BUILD_PAT) add_subdirectory("pat") diff --git a/OpenStudio.cxx.in b/OpenStudio.cxx.in new file mode 100644 index 00000000000..51d50c63980 --- /dev/null +++ b/OpenStudio.cxx.in @@ -0,0 +1,14 @@ +/*********************************************************************************************************************** +* OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC. +* See also https://openstudio.net/license +***********************************************************************************************************************/ + +#include + +std::string openStudioLongVersion() { + return "${OPENSTUDIO_LONG_VERSION}"; +} + +std::string openStudioVersionBuildSHA() { + return "${PROJECT_VERSION_BUILD}"; +} diff --git a/OpenStudio.hxx.in b/OpenStudio.hxx.in index 41fbd082893..3b34574a102 100644 --- a/OpenStudio.hxx.in +++ b/OpenStudio.hxx.in @@ -9,6 +9,8 @@ #include #include +#include + // Support for Ninja on Windows (Ninja isn't multi-configuration while MSVC is) #cmakedefine NINJA @@ -18,9 +20,9 @@ inline std::string openStudioVersion() { } // Includes prerelease tag if any, and build sha, eg: '3.0.0-rc1+baflkdhsia' -inline std::string openStudioLongVersion() { - return "${OPENSTUDIO_LONG_VERSION}"; -} +// The functions that return the build sha are defined in OpenStudio.cxx, so a new commit doesn't change this header +// (included by many files and parsed by SWIG for every module) and only that one file needs to be rebuilt +UTILITIES_API std::string openStudioLongVersion(); inline std::string openStudioVersionMajor() { return "${PROJECT_VERSION_MAJOR}"; @@ -38,9 +40,7 @@ inline std::string openStudioVersionPrerelease() { return "${PROJECT_VERSION_PRERELEASE}"; } -inline std::string openStudioVersionBuildSHA() { - return "${PROJECT_VERSION_BUILD}"; -} +UTILITIES_API std::string openStudioVersionBuildSHA(); inline int energyPlusVersionMajor() { return ${ENERGYPLUS_VERSION_MAJOR}; diff --git a/conanfile.py b/conanfile.py index 09c9fc6324f..fc8599ce9c9 100644 --- a/conanfile.py +++ b/conanfile.py @@ -87,13 +87,16 @@ def generate(self): tc.cache_variables["CPACK_BINARY_TGZ"] = True tc.cache_variables["CPACK_BINARY_IFW"] = False tc.cache_variables["CPACK_BINARY_DEB"] = False + tc.cache_variables["CPACK_BINARY_RPM"] = False if self.settings.build_type == "Release": if is_apple_os(self) or self.settings.os == "Windows": tc.cache_variables["CPACK_BINARY_IFW"] = True + elif Path("/etc/redhat-release").exists(): + # Red Hat-like (CentOS, AlmaLinux, ...) + tc.cache_variables["CPACK_BINARY_RPM"] = True else: tc.cache_variables["CPACK_BINARY_DEB"] = True tc.cache_variables["CPACK_BINARY_NSIS"] = False - tc.cache_variables["CPACK_BINARY_RPM"] = False tc.cache_variables["CPACK_BINARY_STGZ"] = False tc.cache_variables["CPACK_BINARY_TBZ2"] = False tc.cache_variables["CPACK_BINARY_TXZ"] = False diff --git a/embedded/CreateEmbeddedSource.cpp b/embedded/CreateEmbeddedSource.cpp index 86be69accb8..df7beca4d89 100644 --- a/embedded/CreateEmbeddedSource.cpp +++ b/embedded/CreateEmbeddedSource.cpp @@ -3,9 +3,14 @@ * See also https://openstudio.net/license ***********************************************************************************************************************/ -#include +#include +#include +#include #include #include +#include +#include +#include #include #include @@ -21,15 +26,22 @@ #define CHUNK 16384 -int main(int argc, char* argv[]) { - if (argc != 5) { - return 1; - } +struct EmbeddedFile +{ + std::string infile; + std::string outfile; + std::string filenum; + std::string embeddedname; +}; + +static int embedFile(const EmbeddedFile& file) { + const auto* infile = file.infile.c_str(); + const auto* outfile = file.outfile.c_str(); + const auto* filenum = file.filenum.c_str(); + const auto* embeddedname = file.embeddedname.c_str(); - const auto* infile = argv[1]; - auto* outfile = argv[2]; - const auto* filenum = argv[3]; - const auto* embeddedname = argv[4]; + std::error_code ec; + std::filesystem::create_directories(std::filesystem::path(file.outfile).parent_path(), ec); z_stream strm; unsigned char in[CHUNK]; @@ -44,7 +56,7 @@ int main(int argc, char* argv[]) { FILE* source = fopen(infile, "rb"); if (source == NULL) { - fputs("File error", stderr); + std::cerr << "Could not open '" << infile << "' for reading" << std::endl; return EXIT_FAILURE; } @@ -107,3 +119,60 @@ int main(int argc, char* argv[]) { return 0; } + +// Usage: CreateEmbeddedSource +// Each line of the list file is: \t\t, the line index is the file number +// All files are processed in one go (on all cores), rather than one process per file +int main(int argc, char* argv[]) { + if (argc != 2) { + std::cerr << "Usage: " << argv[0] << " " << std::endl; + return EXIT_FAILURE; + } + + std::ifstream list(argv[1]); + if (!list.is_open()) { + std::cerr << "Could not open '" << argv[1] << "' for reading" << std::endl; + return EXIT_FAILURE; + } + + std::vector files; + std::string line; + while (std::getline(list, line)) { + if (line.empty()) { + continue; + } + EmbeddedFile file; + size_t start = 0; + for (auto* field : {&file.infile, &file.outfile}) { + const size_t tab = line.find('\t', start); + if (tab == std::string::npos) { + std::cerr << "Malformed line in '" << argv[1] << "': " << line << std::endl; + return EXIT_FAILURE; + } + *field = line.substr(start, tab - start); + start = tab + 1; + } + file.embeddedname = line.substr(start); + file.filenum = std::to_string(files.size()); + files.push_back(std::move(file)); + } + + std::atomic next{0}; + std::atomic failed{false}; + const unsigned nThreads = std::max(1U, std::thread::hardware_concurrency()); + std::vector threads; + for (unsigned t = 0; t < nThreads; ++t) { + threads.emplace_back([&]() { + for (size_t i = next++; i < files.size(); i = next++) { + if (embedFile(files[i]) != 0) { + failed = true; + } + } + }); + } + for (auto& thread : threads) { + thread.join(); + } + + return failed ? EXIT_FAILURE : 0; +} diff --git a/embedded/EmbedFiles.cmake b/embedded/EmbedFiles.cmake index 4fed64f5b97..7ca5be1106a 100644 --- a/embedded/EmbedFiles.cmake +++ b/embedded/EmbedFiles.cmake @@ -6,7 +6,7 @@ This module defines functions to embed some files as binary into the executable. .. command:: embed_files - This is the command responsible for calling CreateEmbeddedSource:: + This is the command responsible for calling CreateEmbeddedSource (once, for all the files):: embed_files( ) @@ -72,9 +72,8 @@ function(embed_files FILES EMBEDDED_LOCATIONS CXX_OUTPUT_FILES) math(EXPR END "${FILES_LENGTH} - 1") set(NUMFILES ${FILES_LENGTH}) - foreach(i RANGE ${END}) - list(GET FILES ${i} FILE) - list(GET EMBEDDED_LOCATIONS ${i} EMBEDDED_LOCATION) + # ZIP_LISTS rather than list(GET ... ${i}), which re-parses the whole list every time: that was taking ~30s for the 6000+ ruby files + foreach(FILE EMBEDDED_LOCATION IN ZIP_LISTS FILES EMBEDDED_LOCATIONS) get_filename_component(BASE_PATH ${EMBEDDED_LOCATION} DIRECTORY) get_filename_component(BASE_FILENAME ${EMBEDDED_LOCATION} NAME_WE) @@ -86,7 +85,6 @@ function(embed_files FILES EMBEDDED_LOCATIONS CXX_OUTPUT_FILES) # EMBED_SOURCE_FILE is the fully qualified path to a cxx file with the embedded data set(EMBED_SOURCE_FILE "${CMAKE_CURRENT_BINARY_DIR}/embedded_files/${BASE_PATH}/${BASE_FILENAME}${EXTENSION}.cxx") - set(EMBED_SOURCE_PATH "${CMAKE_CURRENT_BINARY_DIR}/embedded_files/${BASE_PATH}") file(RELATIVE_PATH EMBED_SOURCE_FILE_REL_PATH ${PROJECT_BINARY_DIR} ${EMBED_SOURCE_FILE}) list(APPEND EMBED_SOURCE_FILES ${EMBED_SOURCE_FILE}) @@ -101,19 +99,31 @@ function(embed_files FILES EMBEDDED_LOCATIONS CXX_OUTPUT_FILES) set( EMBEDDED_LOCATION ":/${EMBEDDED_LOCATION}" ) endif() - add_custom_command(OUTPUT ${EMBED_SOURCE_FILE} - COMMAND ${CMAKE_COMMAND} -E make_directory ${EMBED_SOURCE_PATH} - COMMAND CreateEmbeddedSource - ${FILE} - ${EMBED_SOURCE_FILE} - ${i} - ${EMBEDDED_LOCATION} - DEPENDS ${FILE} - ) + # One line per file for CreateEmbeddedSource: \t\t. The line index is the file number + string(APPEND EMBED_LIST_CONTENT "${FILE}\t${EMBED_SOURCE_FILE}\t${EMBEDDED_LOCATION}\n") - set(EMBEDDED_FILE_INCLUDES "${EMBEDDED_FILE_INCLUDES}#include <${EMBED_SOURCE_FILE_REL_PATH}>\n") + string(APPEND EMBEDDED_FILE_INCLUDES "#include <${EMBED_SOURCE_FILE_REL_PATH}>\n") endforeach() + # A single command generates all the files (CreateEmbeddedSource uses all cores), rather than one command per file: + # thousands fewer build steps and processes. Changing one file regenerates all of them, but they're all included + # in the same embedded_files.cxx, which has to be recompiled anyway. + # Only rewrite the list when it changes, so that re-running CMake doesn't regenerate everything + set(EMBED_LIST_FILE "${CMAKE_CURRENT_BINARY_DIR}/embedded_files.list") + set(EXISTING_EMBED_LIST_CONTENT "") + if(EXISTS "${EMBED_LIST_FILE}") + file(READ "${EMBED_LIST_FILE}" EXISTING_EMBED_LIST_CONTENT) + endif() + if(NOT EMBED_LIST_CONTENT STREQUAL EXISTING_EMBED_LIST_CONTENT) + file(WRITE "${EMBED_LIST_FILE}" "${EMBED_LIST_CONTENT}") + endif() + + add_custom_command(OUTPUT ${EMBED_SOURCE_FILES} + COMMAND CreateEmbeddedSource "${EMBED_LIST_FILE}" + DEPENDS ${FILES} "${EMBED_LIST_FILE}" + COMMENT "Generating ${NUMFILES} embedded files in ${CMAKE_CURRENT_BINARY_DIR}/embedded_files" + ) + # file names foreach (arg RANGE ${END}) set(EMBEDDED_FILE_NAMES "${EMBEDDED_FILE_NAMES} embedded_file_name_${arg}") @@ -143,6 +153,12 @@ function(embed_files FILES EMBEDDED_LOCATIONS CXX_OUTPUT_FILES) set_source_files_properties(${EMBED_SOURCE_FILES} PROPERTIES HEADER_FILE_ONLY TRUE) + # Named targets to generate just the embedded files: eg 'ninja embedded_files' (all of them), or 'ninja embedded_files_src_utilities' + file(RELATIVE_PATH EMBED_TARGET_DIR "${PROJECT_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}") + string(MAKE_C_IDENTIFIER "embedded_files_${EMBED_TARGET_DIR}" EMBED_TARGET) + add_custom_target(${EMBED_TARGET} DEPENDS ${EMBED_SOURCE_FILES}) + add_dependencies(embedded_files ${EMBED_TARGET}) + if( NAMESPACE ) set(BEGIN_NAMESPACE "namespace ${NAMESPACE} {") set(END_NAMESPACE "}") diff --git a/src/energyplus/ForwardTranslator.cpp b/src/energyplus/ForwardTranslator.cpp index 1cd57a0753d..8e32a6336e4 100644 --- a/src/energyplus/ForwardTranslator.cpp +++ b/src/energyplus/ForwardTranslator.cpp @@ -3744,38 +3744,21 @@ namespace energyplus { void ForwardTranslator::translateConstructions(const model::Model& model) { std::vector iddObjectTypes{ - IddObjectType::OS_MaterialProperty_GlazingSpectralData, - IddObjectType::OS_Material, - IddObjectType::OS_Material_AirGap, - IddObjectType::OS_Material_InfraredTransparent, - IddObjectType::OS_Material_NoMass, - IddObjectType::OS_Material_RoofVegetation, - - IddObjectType::OS_WindowMaterial_Blind, - IddObjectType::OS_WindowMaterial_DaylightRedirectionDevice, - IddObjectType::OS_WindowMaterial_Gas, - IddObjectType::OS_WindowMaterial_GasMixture, - IddObjectType::OS_WindowMaterial_Glazing, - IddObjectType::OS_WindowMaterial_GlazingGroup_Thermochromic, - IddObjectType::OS_WindowMaterial_Glazing_RefractionExtinctionMethod, - IddObjectType::OS_WindowMaterial_Screen, - IddObjectType::OS_WindowMaterial_Shade, - IddObjectType::OS_WindowMaterial_SimpleGlazingSystem, - IddObjectType::OS_WindowProperty_FrameAndDivider, - IddObjectType::OS_ShadingControl, - - IddObjectType::OS_Construction, - IddObjectType::OS_Construction_AirBoundary, - IddObjectType::OS_Construction_CfactorUndergroundWall, - IddObjectType::OS_Construction_FfactorGroundFloor, - IddObjectType::OS_Construction_InternalSource, - IddObjectType::OS_Construction_WindowDataFile, + IddObjectType::OS_MaterialProperty_GlazingSpectralData, IddObjectType::OS_Material, IddObjectType::OS_Material_AirGap, + IddObjectType::OS_Material_InfraredTransparent, IddObjectType::OS_Material_NoMass, IddObjectType::OS_Material_RoofVegetation, + + IddObjectType::OS_WindowMaterial_Blind, IddObjectType::OS_WindowMaterial_DaylightRedirectionDevice, IddObjectType::OS_WindowMaterial_Gas, + IddObjectType::OS_WindowMaterial_GasMixture, IddObjectType::OS_WindowMaterial_Glazing, + IddObjectType::OS_WindowMaterial_GlazingGroup_Thermochromic, IddObjectType::OS_WindowMaterial_Glazing_RefractionExtinctionMethod, + IddObjectType::OS_WindowMaterial_Screen, IddObjectType::OS_WindowMaterial_Shade, IddObjectType::OS_WindowMaterial_SimpleGlazingSystem, + IddObjectType::OS_WindowProperty_FrameAndDivider, IddObjectType::OS_ShadingControl, + + IddObjectType::OS_Construction, IddObjectType::OS_Construction_AirBoundary, IddObjectType::OS_Construction_CfactorUndergroundWall, + IddObjectType::OS_Construction_FfactorGroundFloor, IddObjectType::OS_Construction_InternalSource, IddObjectType::OS_Construction_WindowDataFile, IddObjectType::OS_StandardsInformation_Construction, // TODO: [ConstructionAssignmentSet purge] Probably not wanted, especially with purge = false in DefaultConstructionSet::collapseToSpaceAndBuilding - IddObjectType::OS_DefaultSubSurfaceConstructions, - IddObjectType::OS_DefaultSurfaceConstructions, - IddObjectType::OS_DefaultConstructionSet, + IddObjectType::OS_DefaultSubSurfaceConstructions, IddObjectType::OS_DefaultSurfaceConstructions, IddObjectType::OS_DefaultConstructionSet, IddObjectType::OS_DefaultScheduleSet, diff --git a/src/energyplus/ForwardTranslator/ForwardTranslateComfortViewFactorAngles.cpp b/src/energyplus/ForwardTranslator/ForwardTranslateComfortViewFactorAngles.cpp index a1b70a401d1..0d0e063fdc1 100644 --- a/src/energyplus/ForwardTranslator/ForwardTranslateComfortViewFactorAngles.cpp +++ b/src/energyplus/ForwardTranslator/ForwardTranslateComfortViewFactorAngles.cpp @@ -49,8 +49,7 @@ namespace energyplus { } const auto surfaceThermalZone = space ? space->thermalZone() : boost::none; if (!surfaceThermalZone || (thermalZone && (surfaceThermalZone->handle() != thermalZone->handle()))) { - LOG(Error, modelObject.briefDescription() - << " has surfaces that are not all assigned to the same ThermalZone and will not be translated."); + LOG(Error, modelObject.briefDescription() << " has surfaces that are not all assigned to the same ThermalZone and will not be translated."); return boost::none; } thermalZone = surfaceThermalZone; diff --git a/src/energyplus/ForwardTranslator/ForwardTranslatePeople.cpp b/src/energyplus/ForwardTranslator/ForwardTranslatePeople.cpp index ab79f0bde69..8fde5bab5cb 100644 --- a/src/energyplus/ForwardTranslator/ForwardTranslatePeople.cpp +++ b/src/energyplus/ForwardTranslator/ForwardTranslatePeople.cpp @@ -125,39 +125,40 @@ namespace energyplus { if (target->optionalCast() || target->optionalCast() || target->optionalCast()) { if (!istringEqual(mrtType, "SurfaceWeighted")) { LOG(Warn, modelObject.briefDescription() << " references " << target->briefDescription() - << ", but its PeopleDefinition has Mean Radiant Temperature Calculation Type '" << mrtType - << "'. Using 'SurfaceWeighted'."); + << ", but its PeopleDefinition has Mean Radiant Temperature Calculation Type '" << mrtType + << "'. Using 'SurfaceWeighted'."); } if (auto idfTarget = translateAndMapModelObject(*target)) { mrtType = "SurfaceWeighted"; idfObject.setString(PeopleFields::SurfaceName_AngleFactorListName, idfTarget->nameString()); } else { LOG(Warn, "Could not translate " << target->briefDescription() << " referenced by " << modelObject.briefDescription() - << "; using 'EnclosureAveraged' for Mean Radiant Temperature Calculation Type."); + << "; using 'EnclosureAveraged' for Mean Radiant Temperature Calculation Type."); mrtType = "EnclosureAveraged"; } } else if (target->optionalCast()) { if (!istringEqual(mrtType, "AngleFactor")) { LOG(Warn, modelObject.briefDescription() << " references " << target->briefDescription() - << ", but its PeopleDefinition has Mean Radiant Temperature Calculation Type '" << mrtType - << "'. Using 'AngleFactor'."); + << ", but its PeopleDefinition has Mean Radiant Temperature Calculation Type '" << mrtType + << "'. Using 'AngleFactor'."); } if (auto idfTarget = translateAndMapModelObject(*target)) { mrtType = "AngleFactor"; idfObject.setString(PeopleFields::SurfaceName_AngleFactorListName, idfTarget->nameString()); } else { LOG(Warn, "Could not translate " << target->briefDescription() << " referenced by " << modelObject.briefDescription() - << "; using 'EnclosureAveraged' for Mean Radiant Temperature Calculation Type."); + << "; using 'EnclosureAveraged' for Mean Radiant Temperature Calculation Type."); mrtType = "EnclosureAveraged"; } } else { LOG(Warn, modelObject.briefDescription() << " references unsupported Surface Name/Angle Factor List Name object " - << target->briefDescription() << "; using 'EnclosureAveraged' for Mean Radiant Temperature Calculation Type."); + << target->briefDescription() + << "; using 'EnclosureAveraged' for Mean Radiant Temperature Calculation Type."); mrtType = "EnclosureAveraged"; } } else if (!istringEqual(mrtType, "EnclosureAveraged")) { LOG(Warn, modelObject.briefDescription() << " has Mean Radiant Temperature Calculation Type '" << mrtType - << "' but no Surface Name/Angle Factor List Name; using 'EnclosureAveraged'."); + << "' but no Surface Name/Angle Factor List Name; using 'EnclosureAveraged'."); mrtType = "EnclosureAveraged"; } @@ -252,39 +253,40 @@ namespace energyplus { if (target->optionalCast()) { if (!istringEqual(mrtType, "SurfaceWeighted")) { LOG(Warn, modelObject.briefDescription() << " references " << target->briefDescription() - << ", but its PeopleDefinition has Mean Radiant Temperature Calculation Type '" << mrtType - << "'. Using 'SurfaceWeighted'."); + << ", but its PeopleDefinition has Mean Radiant Temperature Calculation Type '" << mrtType + << "'. Using 'SurfaceWeighted'."); } if (auto idfTarget = translateAndMapModelObject(*target)) { mrtType = "SurfaceWeighted"; idfObject.setString(People_InstanceFields::SurfaceName_AngleFactorListName, idfTarget->nameString()); } else { LOG(Warn, "Could not translate " << target->briefDescription() << " referenced by " << modelObject.briefDescription() - << "; using 'EnclosureAveraged' for Mean Radiant Temperature Calculation Type."); + << "; using 'EnclosureAveraged' for Mean Radiant Temperature Calculation Type."); mrtType = "EnclosureAveraged"; } } else if (target->optionalCast()) { if (!istringEqual(mrtType, "AngleFactor")) { LOG(Warn, modelObject.briefDescription() << " references " << target->briefDescription() - << ", but its PeopleDefinition has Mean Radiant Temperature Calculation Type '" << mrtType - << "'. Using 'AngleFactor'."); + << ", but its PeopleDefinition has Mean Radiant Temperature Calculation Type '" << mrtType + << "'. Using 'AngleFactor'."); } if (auto idfTarget = translateAndMapModelObject(*target)) { mrtType = "AngleFactor"; idfObject.setString(People_InstanceFields::SurfaceName_AngleFactorListName, idfTarget->nameString()); } else { LOG(Warn, "Could not translate " << target->briefDescription() << " referenced by " << modelObject.briefDescription() - << "; using 'EnclosureAveraged' for Mean Radiant Temperature Calculation Type."); + << "; using 'EnclosureAveraged' for Mean Radiant Temperature Calculation Type."); mrtType = "EnclosureAveraged"; } } else { LOG(Warn, modelObject.briefDescription() << " references unsupported Surface Name/Angle Factor List Name object " - << target->briefDescription() << "; using 'EnclosureAveraged' for Mean Radiant Temperature Calculation Type."); + << target->briefDescription() + << "; using 'EnclosureAveraged' for Mean Radiant Temperature Calculation Type."); mrtType = "EnclosureAveraged"; } } else if (!istringEqual(mrtType, "EnclosureAveraged")) { LOG(Warn, modelObject.briefDescription() << " has Mean Radiant Temperature Calculation Type '" << mrtType - << "' but no Surface Name/Angle Factor List Name; using 'EnclosureAveraged'."); + << "' but no Surface Name/Angle Factor List Name; using 'EnclosureAveraged'."); mrtType = "EnclosureAveraged"; } diff --git a/src/energyplus/ForwardTranslator/ForwardTranslateScheduleRuleset.cpp b/src/energyplus/ForwardTranslator/ForwardTranslateScheduleRuleset.cpp index 62c545def82..f0602aba2f7 100644 --- a/src/energyplus/ForwardTranslator/ForwardTranslateScheduleRuleset.cpp +++ b/src/energyplus/ForwardTranslator/ForwardTranslateScheduleRuleset.cpp @@ -136,7 +136,7 @@ namespace energyplus { group.setInt(Schedule_Week_RuleExtensibleFields::EndMonth, _endDate->monthOfYear().value()); group.setInt(Schedule_Week_RuleExtensibleFields::EndDay, _endDate->dayOfMonth()); } - } else { // SpecificDates + } else { // SpecificDates for (const openstudio::Date& specificDate : scheduleRule.specificDates()) { IdfExtensibleGroup group = scheduleWeekRule.pushExtensibleGroup(); group.setInt(Schedule_Week_RuleExtensibleFields::StartMonth, specificDate.monthOfYear().value()); @@ -146,7 +146,7 @@ namespace energyplus { } } - m_idfObjects.push_back(scheduleWeekRule); + m_idfObjects.push_back(scheduleWeekRule); } m_idfObjects.push_back(scheduleYearRules); diff --git a/src/energyplus/Test/DefaultSubSurfaceConstructions_GTest.cpp b/src/energyplus/Test/DefaultSubSurfaceConstructions_GTest.cpp index 6bb24399815..c3ea6d950ab 100644 --- a/src/energyplus/Test/DefaultSubSurfaceConstructions_GTest.cpp +++ b/src/energyplus/Test/DefaultSubSurfaceConstructions_GTest.cpp @@ -39,12 +39,10 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_DefaultSubSurfaceConstructions) { Building building = m.getUniqueModelObject(); EXPECT_TRUE(building.setDefaultConstructionSet(defaultConstructionSet)); - DefaultSubSurfaceConstructions defaultSubSurfaceConstructions(m); defaultSubSurfaceConstructions.setName("Exterior SubSurface Constructions"); EXPECT_TRUE(defaultConstructionSet.setDefaultExteriorSubSurfaceConstructions(defaultSubSurfaceConstructions)); - Construction fixedWindowConstruction(m); fixedWindowConstruction.setName("Fixed Window Construction"); EXPECT_TRUE(defaultSubSurfaceConstructions.setFixedWindowConstruction(fixedWindowConstruction)); @@ -84,11 +82,14 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_DefaultSubSurfaceConstructions) { const auto& idfObject = idfObjs.front(); EXPECT_EQ(defaultSubSurfaceConstructions.nameString(), idfObject.nameString()); EXPECT_EQ(fixedWindowConstruction.nameString(), idfObject.getString(SubSurfaceConstructionAssignmentsFields::FixedWindowConstructionName).get()); - EXPECT_EQ(operableWindowConstruction.nameString(), idfObject.getString(SubSurfaceConstructionAssignmentsFields::OperableWindowConstructionName).get()); + EXPECT_EQ(operableWindowConstruction.nameString(), + idfObject.getString(SubSurfaceConstructionAssignmentsFields::OperableWindowConstructionName).get()); EXPECT_EQ(doorConstruction.nameString(), idfObject.getString(SubSurfaceConstructionAssignmentsFields::DoorConstructionName).get()); EXPECT_EQ(glassDoorConstruction.nameString(), idfObject.getString(SubSurfaceConstructionAssignmentsFields::GlassDoorConstructionName).get()); EXPECT_EQ(overheadDoorConstruction.nameString(), idfObject.getString(SubSurfaceConstructionAssignmentsFields::OverheadDoorConstructionName).get()); EXPECT_EQ(skylightConstruction.nameString(), idfObject.getString(SubSurfaceConstructionAssignmentsFields::SkylightConstructionName).get()); - EXPECT_EQ(tubularDaylightDomeConstruction.nameString(), idfObject.getString(SubSurfaceConstructionAssignmentsFields::TubularDaylightDomeConstructionName).get()); - EXPECT_EQ(tubularDaylightDiffuserConstruction.nameString(), idfObject.getString(SubSurfaceConstructionAssignmentsFields::TubularDaylightDiffuserConstructionName).get()); + EXPECT_EQ(tubularDaylightDomeConstruction.nameString(), + idfObject.getString(SubSurfaceConstructionAssignmentsFields::TubularDaylightDomeConstructionName).get()); + EXPECT_EQ(tubularDaylightDiffuserConstruction.nameString(), + idfObject.getString(SubSurfaceConstructionAssignmentsFields::TubularDaylightDiffuserConstructionName).get()); } diff --git a/src/energyplus/Test/PythonPluginInstance_GTest.cpp b/src/energyplus/Test/PythonPluginInstance_GTest.cpp index 560899ffec0..833bbc77c36 100644 --- a/src/energyplus/Test/PythonPluginInstance_GTest.cpp +++ b/src/energyplus/Test/PythonPluginInstance_GTest.cpp @@ -37,6 +37,9 @@ using namespace openstudio; TEST_F(EnergyPlusFixture, ForwardTranslator_PythonPluginInstance) { Model model; + // Use a directory unique to this test: it deletes the destination dir below, which would otherwise be /files, + // shared with other tests that copy external files there (PythonPluginSearchPaths, ScheduleFileRelativePath) and may run in parallel + model.workflowJSON().setOswDir(openstudio::tempDir() / toPath("ForwardTranslator_PythonPluginInstance")); openstudio::path p = resourcesPath() / toPath("model/PythonPluginThermochromicWindow.py"); ASSERT_TRUE(exists(p)); diff --git a/src/energyplus/Test/ScheduleRuleset_GTest.cpp b/src/energyplus/Test/ScheduleRuleset_GTest.cpp index a8af340d6c5..f4865327c1e 100644 --- a/src/energyplus/Test/ScheduleRuleset_GTest.cpp +++ b/src/energyplus/Test/ScheduleRuleset_GTest.cpp @@ -480,7 +480,7 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_ScheduleRuleset_SpecialDays) { for (const WorkspaceObject& scheduleWeekRule : scheduleWeekRules) { const int rulePriorityOrder = scheduleWeekRule.getInt(Schedule_Week_RuleFields::RulePriorityOrder).get(); - if (rulePriorityOrder == 0) { // Weekends + if (rulePriorityOrder == 0) { // Weekends EXPECT_EQ("Yes", scheduleWeekRule.getString(Schedule_Week_RuleFields::ApplySunday).get()); EXPECT_EQ("No", scheduleWeekRule.getString(Schedule_Week_RuleFields::ApplyMonday).get()); EXPECT_EQ("No", scheduleWeekRule.getString(Schedule_Week_RuleFields::ApplyTuesday).get()); @@ -489,7 +489,7 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_ScheduleRuleset_SpecialDays) { EXPECT_EQ("No", scheduleWeekRule.getString(Schedule_Week_RuleFields::ApplyFriday).get()); EXPECT_EQ("Yes", scheduleWeekRule.getString(Schedule_Week_RuleFields::ApplySaturday).get()); EXPECT_EQ(weekendSchedule.nameString(), scheduleWeekRule.getString(Schedule_Week_RuleFields::DayScheduleName).get()); - } else if (rulePriorityOrder == 1) { // Weekdays + } else if (rulePriorityOrder == 1) { // Weekdays EXPECT_EQ("No", scheduleWeekRule.getString(Schedule_Week_RuleFields::ApplySunday).get()); EXPECT_EQ("Yes", scheduleWeekRule.getString(Schedule_Week_RuleFields::ApplyMonday).get()); EXPECT_EQ("Yes", scheduleWeekRule.getString(Schedule_Week_RuleFields::ApplyTuesday).get()); diff --git a/src/energyplus/Test/Surface_GTest.cpp b/src/energyplus/Test/Surface_GTest.cpp index 4a9f54595dd..e41e54004ab 100644 --- a/src/energyplus/Test/Surface_GTest.cpp +++ b/src/energyplus/Test/Surface_GTest.cpp @@ -541,11 +541,11 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_Surface_ExcludeSpaceTranslation_Sear }; EXPECT_EQ(spaceTypeRoofConstruction.nameString(), surfaceConstructionName(roof1)); // SpaceType wins over the Story - EXPECT_EQ(storyWallConstruction.nameString(), surfaceConstructionName(wall)); // Falls through to the Story - EXPECT_EQ("", surfaceConstructionName(floor)); // Building SpaceType: left to E+ - EXPECT_EQ(windowConstruction.nameString(), subSurfaceConstructionName(window)); // SubSurfaces are hard-assigned too - EXPECT_EQ("", subSurfaceConstructionName(door)); // Building: left to E+ - EXPECT_EQ(storyRoofConstruction.nameString(), surfaceConstructionName(roof2)); // Defaulted SpaceType skipped + EXPECT_EQ(storyWallConstruction.nameString(), surfaceConstructionName(wall)); // Falls through to the Story + EXPECT_EQ("", surfaceConstructionName(floor)); // Building SpaceType: left to E+ + EXPECT_EQ(windowConstruction.nameString(), subSurfaceConstructionName(window)); // SubSurfaces are hard-assigned too + EXPECT_EQ("", subSurfaceConstructionName(door)); // Building: left to E+ + EXPECT_EQ(storyRoofConstruction.nameString(), surfaceConstructionName(roof2)); // Defaulted SpaceType skipped // The input model isn't touched for (const auto& surface : {roof1, wall, floor, roof2}) { diff --git a/src/gbxml/Test/ForwardTranslator_GTest.cpp b/src/gbxml/Test/ForwardTranslator_GTest.cpp index 4da7ef89b53..152e6134778 100644 --- a/src/gbxml/Test/ForwardTranslator_GTest.cpp +++ b/src/gbxml/Test/ForwardTranslator_GTest.cpp @@ -81,7 +81,7 @@ TEST_F(gbXMLFixture, ForwardTranslator_exampleModel) { path p1 = resourcesPath() / openstudio::toPath("gbxml/exampleModel.osm"); model.save(p1, true); - path p2 = resourcesPath() / openstudio::toPath("gbxml/exampleModel2.osm"); + path p2 = resourcesPath() / openstudio::toPath("gbxml/exampleModel_reverseTranslated.osm"); model2->save(p2, true); } @@ -298,7 +298,7 @@ TEST_F(gbXMLFixture, ForwardTranslator_surfaceType_4001) { Model model = exampleModel(); // Write out the XML - path p = resourcesPath() / openstudio::toPath("gbxml/exampleModel.xml"); + path p = resourcesPath() / openstudio::toPath("gbxml/surfaceType_4001.xml"); ForwardTranslator forwardTranslator; bool test = forwardTranslator.modelToGbXML(model, p); @@ -891,7 +891,7 @@ TEST_F(gbXMLFixture, ForwardTranslator_IDs_Names) { TEST_F(gbXMLFixture, ForwardTranslator_exampleModelValid) { Model model = exampleModel(); - path p = resourcesPath() / openstudio::toPath("gbxml/exampleModel.xml"); + path p = resourcesPath() / openstudio::toPath("gbxml/exampleModelValid.xml"); ForwardTranslator forwardTranslator; bool test = forwardTranslator.modelToGbXML(model, p); @@ -913,7 +913,7 @@ TEST_F(gbXMLFixture, ForwardTranslator_exposedToSun) { Model model = exampleModel(); // Write out the XML - path p = resourcesPath() / openstudio::toPath("gbxml/exampleModel.xml"); + path p = resourcesPath() / openstudio::toPath("gbxml/exposedToSun.xml"); ForwardTranslator forwardTranslator; bool test = forwardTranslator.modelToGbXML(model, p); @@ -963,7 +963,7 @@ TEST_F(gbXMLFixture, ForwardTranslator_spaceVolume) { EXPECT_EQ(300.0, ospace1->volume()); // Write out the XML - path p = resourcesPath() / openstudio::toPath("gbxml/exampleModel.xml"); + path p = resourcesPath() / openstudio::toPath("gbxml/spaceVolume.xml"); ForwardTranslator forwardTranslator; bool test = forwardTranslator.modelToGbXML(model, p); @@ -1013,7 +1013,7 @@ TEST_F(gbXMLFixture, ForwardTranslator_spaceVolume) { EXPECT_EQ(305.0, ospace1->volume()); // Write out the XML - path p = resourcesPath() / openstudio::toPath("gbxml/exampleModel.xml"); + path p = resourcesPath() / openstudio::toPath("gbxml/spaceVolume.xml"); ForwardTranslator forwardTranslator; bool test = forwardTranslator.modelToGbXML(model, p); diff --git a/src/measure/test/MeasureFixture.cpp b/src/measure/test/MeasureFixture.cpp index 69faa007d69..581d2ff2092 100644 --- a/src/measure/test/MeasureFixture.cpp +++ b/src/measure/test/MeasureFixture.cpp @@ -87,9 +87,8 @@ void MeasureFixture::SetUpTestSuite() { logFile->setLogLevel(Info); openstudio::Logger::instance().standardOutLogger().disable(); - // clear scratch + // Don't clear it: CTest runs each test in its own process, so this runs for every test, and would delete the files of tests running in parallel scratchDir = openstudio::getApplicationBuildDirectory() / openstudio::toPath("Testing/Temporary/measure"); - openstudio::filesystem::remove_all(scratchDir); openstudio::filesystem::create_directories(scratchDir); } diff --git a/src/model/ComfortViewFactorAngles.cpp b/src/model/ComfortViewFactorAngles.cpp index 36e17d99207..1e94e283eae 100644 --- a/src/model/ComfortViewFactorAngles.cpp +++ b/src/model/ComfortViewFactorAngles.cpp @@ -77,7 +77,7 @@ namespace model { } ComfortViewFactorAngles_Impl::ComfortViewFactorAngles_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, - bool keepHandle) + bool keepHandle) : ModelObject_Impl(other, model, keepHandle) {} ComfortViewFactorAngles_Impl::ComfortViewFactorAngles_Impl(const ComfortViewFactorAngles_Impl& other, Model_Impl* model, bool keepHandle) @@ -120,7 +120,7 @@ namespace model { boost::optional ComfortViewFactorAngles_Impl::getAngleFactor(unsigned groupIndex) const { if (groupIndex >= numberofAngleFactors()) { LOG(Error, "Asked to get Angle Factor with index " << groupIndex << ", but " << briefDescription() << " has just " << numberofAngleFactors() - << " angle factors."); + << " angle factors."); return boost::none; } @@ -156,8 +156,7 @@ namespace model { boost::optional thermalZone = space->thermalZone(); if (!thermalZone) { - LOG(Error, "Cannot add " << surface.briefDescription() << " to " << briefDescription() - << " because it is not assigned to any ThermalZone."); + LOG(Error, "Cannot add " << surface.briefDescription() << " to " << briefDescription() << " because it is not assigned to any ThermalZone."); return result; } @@ -166,9 +165,8 @@ namespace model { const auto existingThermalZone = existingSpace ? existingSpace->thermalZone() : boost::none; if (!existingThermalZone || (existingThermalZone->handle() != thermalZone->handle())) { LOG(Error, "Cannot add " << surface.briefDescription() << " to " << briefDescription() << " because it is assigned to ThermalZone '" - << thermalZone->nameString() - << "' instead of '" - << (existingThermalZone ? existingThermalZone->nameString() : "an unassigned ThermalZone") << "'."); + << thermalZone->nameString() << "' instead of '" + << (existingThermalZone ? existingThermalZone->nameString() : "an unassigned ThermalZone") << "'."); return result; } } @@ -178,7 +176,7 @@ namespace model { boost::optional existingAngleFactor = getAngleFactor(existingIndex.get()); OS_ASSERT(existingAngleFactor); LOG(Warn, "For " << briefDescription() << ", AngleFactor already exists, will be modified in place from " << existingAngleFactor.get() - << " to " << angleFactor << "."); + << " to " << angleFactor << "."); } double sum = angleFactor.angleFactor(); @@ -194,7 +192,7 @@ namespace model { constexpr double tolerance = 0.000001; if (sum > 1.0 + tolerance) { LOG(Error, "Cannot add an AngleFactor to " << briefDescription() << " because the Angle Factors would sum to " << sum - << ", which is greater than 1."); + << ", which is greater than 1."); return result; } diff --git a/src/model/ComfortViewFactorAngles_Impl.hpp b/src/model/ComfortViewFactorAngles_Impl.hpp index d17d9ff93f0..1db5d0d4375 100644 --- a/src/model/ComfortViewFactorAngles_Impl.hpp +++ b/src/model/ComfortViewFactorAngles_Impl.hpp @@ -41,9 +41,8 @@ namespace model { private: REGISTER_LOGGER("openstudio.model.ComfortViewFactorAngles"); - }; - } + } // namespace detail } // namespace model } // namespace openstudio diff --git a/src/model/test/ChillerElectricASHRAE205_GTest.cpp b/src/model/test/ChillerElectricASHRAE205_GTest.cpp index c4b9eb44000..b8a8e9f6860 100644 --- a/src/model/test/ChillerElectricASHRAE205_GTest.cpp +++ b/src/model/test/ChillerElectricASHRAE205_GTest.cpp @@ -620,6 +620,7 @@ TEST_F(ModelFixture, ChillerElectricASHRAE205_Loops) { TEST_F(ModelFixture, ChillerElectricASHRAE205_NotCBORFile) { Model model; + setUniqueOswDir(model); openstudio::path p = resourcesPath() / toPath("model/7-7_Windows_Complete.osm"); EXPECT_TRUE(exists(p)); @@ -632,18 +633,11 @@ TEST_F(ModelFixture, ChillerElectricASHRAE205_NotCBORFile) { TEST_F(ModelFixture, ChillerElectricASHRAE205_Clone) { Model m; + setUniqueOswDir(m); openstudio::path p = resourcesPath() / toPath("model/A205ExampleChiller.RS0001.a205.cbor"); EXPECT_TRUE(exists(p)); - // Work in a temp dir so we don't mess everything up when running tests in parallel - // Work in a temp dir so we don't mess everything up when running tests in parallel - openstudio::path expectedDestDir = openstudio::tempDir() / openstudio::toPath("ChillerElectricASHRAE205_Clone"); - if (exists(expectedDestDir)) { - removeDirectory(expectedDestDir); - } - EXPECT_TRUE(m.workflowJSON().addFilePath(expectedDestDir)); - boost::optional representationFile = ExternalFile::getExternalFile(m, openstudio::toString(p)); ASSERT_TRUE(representationFile); @@ -657,6 +651,7 @@ TEST_F(ModelFixture, ChillerElectricASHRAE205_Clone) { { // Another model first, so we don't mess the original one Model m2; + setUniqueOswDir(m2, "_m2"); auto ch2 = ch.clone(m2).cast(); ASSERT_EQ(1, m2.getConcreteModelObjects().size()); diff --git a/src/model/test/ModelFixture.cpp b/src/model/test/ModelFixture.cpp index 9a226b61cc5..fe6f7c55320 100644 --- a/src/model/test/ModelFixture.cpp +++ b/src/model/test/ModelFixture.cpp @@ -7,6 +7,7 @@ #include "../../utilities/idd/IddKey.hpp" #include "../../utilities/core/Finder.hpp" +#include "../../utilities/filetypes/WorkflowJSON.hpp" #include @@ -32,6 +33,13 @@ void ModelFixture::TearDownTestSuite() { logFile->disable(); } +openstudio::path ModelFixture::setUniqueOswDir(openstudio::model::Model& model, const std::string& suffix) { + const auto* testInfo = ::testing::UnitTest::GetInstance()->current_test_info(); + openstudio::path dir = openstudio::tempDir() / toPath(std::string(testInfo->name()) + suffix); + model.workflowJSON().setOswDir(dir); + return dir; +} + void ModelFixture::testBooleanIddField(const openstudio::IddField& iddField, const boost::optional& defaultValue) { EXPECT_TRUE(iddField.properties().type == openstudio::IddFieldType::ChoiceType); openstudio::IddKeyVector keys = iddField.keys(); diff --git a/src/model/test/ModelFixture.hpp b/src/model/test/ModelFixture.hpp index 28fd47c1a36..133100b9b58 100644 --- a/src/model/test/ModelFixture.hpp +++ b/src/model/test/ModelFixture.hpp @@ -38,6 +38,10 @@ class ModelFixture : public ::testing::Test bool testFuelTypeEquality(const std::vector& expectedFuelTypes, const std::vector& actualFuelTypes); + // Points the model's workflow to /, so that the files that ExternalFile copies + // (to /files) don't clash with other tests running in parallel: they'd all use /files otherwise + static openstudio::path setUniqueOswDir(openstudio::model::Model& model, const std::string& suffix = ""); + bool testAppGFuelTypeEquality(const std::vector& expectedAppGFuelTypes, const std::vector& actualAppGFuelTypes); diff --git a/src/model/test/PythonPluginInstance_GTest.cpp b/src/model/test/PythonPluginInstance_GTest.cpp index 46b627b8dcb..5026abded28 100644 --- a/src/model/test/PythonPluginInstance_GTest.cpp +++ b/src/model/test/PythonPluginInstance_GTest.cpp @@ -18,6 +18,7 @@ using namespace openstudio; TEST_F(ModelFixture, PythonPluginInstance) { Model model; + setUniqueOswDir(model); EXPECT_EQ(0u, model.getConcreteModelObjects().size()); EXPECT_EQ(0u, model.getConcreteModelObjects().size()); @@ -86,6 +87,7 @@ TEST_F(ModelFixture, PythonPluginInstance) { TEST_F(ModelFixture, PythonPluginInstance_NotPYFile) { Model model; + setUniqueOswDir(model); path p = resourcesPath() / toPath("model/7-7_Windows_Complete.osm"); EXPECT_TRUE(exists(p)); @@ -98,6 +100,7 @@ TEST_F(ModelFixture, PythonPluginInstance_NotPYFile) { TEST_F(ModelFixture, PythonPluginInstance_ClassNameValidation) { Model model; + setUniqueOswDir(model); path p = resourcesPath() / toPath("model/PythonPluginThermochromicWindow.py"); EXPECT_TRUE(exists(p)); diff --git a/src/model/test/ScheduleInterval_GTest.cpp b/src/model/test/ScheduleInterval_GTest.cpp index 85514edd01e..0ef07f12656 100644 --- a/src/model/test/ScheduleInterval_GTest.cpp +++ b/src/model/test/ScheduleInterval_GTest.cpp @@ -217,6 +217,7 @@ TEST_F(ModelFixture, Schedule_VariableInterval3) { TEST_F(ModelFixture, ScheduleFile) { Model model; + setUniqueOswDir(model); EXPECT_EQ(0u, model.getConcreteModelObjects().size()); EXPECT_EQ(0u, model.getConcreteModelObjects().size()); @@ -372,6 +373,7 @@ TEST_F(ModelFixture, ScheduleFile) { TEST_F(ModelFixture, ScheduleFileAltCtor) { Model model; + setUniqueOswDir(model); EXPECT_EQ(0u, model.getConcreteModelObjects().size()); EXPECT_EQ(0u, model.getConcreteModelObjects().size()); diff --git a/src/utilities/CMakeLists.txt b/src/utilities/CMakeLists.txt index 7a96c66cea8..4c1bf276aa0 100644 --- a/src/utilities/CMakeLists.txt +++ b/src/utilities/CMakeLists.txt @@ -11,6 +11,7 @@ include(xml/CMakeLists.txt) CONFIGURE_FILE_WITH_CHECKSUM("core/ApplicationPathHelpers.cxx.in" "${CMAKE_CURRENT_BINARY_DIR}/core/ApplicationPathHelpers.cxx") set(core_src + ${PROJECT_BINARY_DIR}/src/OpenStudio.cxx core/ApplicationPathHelpers.hpp ${CMAKE_CURRENT_BINARY_DIR}/core/ApplicationPathHelpers.cxx core/Assert.hpp diff --git a/src/utilities/filetypes/EpwFile.cpp b/src/utilities/filetypes/EpwFile.cpp index 8fbdb3ef3c7..566af9c659e 100644 --- a/src/utilities/filetypes/EpwFile.cpp +++ b/src/utilities/filetypes/EpwFile.cpp @@ -5447,8 +5447,8 @@ bool EpwFile::parseDesignConditions(const std::string& line) { int nDesignConditions = std::stoi(split[1]); if (nDesignConditions < 0) { - LOG(Warn, "Negative number of design conditions (" << nDesignConditions << ") in EPW file '" << m_path - << "'. Design conditions will not be parsed."); + LOG(Warn, + "Negative number of design conditions (" << nDesignConditions << ") in EPW file '" << m_path << "'. Design conditions will not be parsed."); return true; } const auto nDC = static_cast(nDesignConditions); diff --git a/src/utilities/filetypes/test/EpwFile_GTest.cpp b/src/utilities/filetypes/test/EpwFile_GTest.cpp index 79eabed2b62..65e1102564a 100644 --- a/src/utilities/filetypes/test/EpwFile_GTest.cpp +++ b/src/utilities/filetypes/test/EpwFile_GTest.cpp @@ -1635,8 +1635,10 @@ TEST(Filetypes, EpwDesignCondition_WrongNumberOfSubFields_UnbalancedFields2) { TEST(Filetypes, EpwDesignCondition_HoF_2025) { const std::string line = "2025 ASHRAE Handbook -- Fundamentals - Chapter 14 Climatic Design Information," "Heating,1,-15.9,-13.5,-20.3,0.6,-15.4,-18.1,0.8,-12.7,14.1,-1.0,12.8,-0.4,4.4,260,0.573," - "Cooling,7,8.8,30.3,21.7,29.0,21.2,27.8,20.6,23.7,27.7,22.9,27.0,22.1,26.0,5.2,240,22.4,17.5,26.0,21.5,16.6,25.3,20.7,15.7,24.7,71.8,27.5,68.9,27.1,65.7,25.8,25.9," - "Extremes,11.7,10.3,9.1,-18.5,32.7,2.8,1.4,-20.6,33.7,-22.2,34.5,-23.8,35.2,-25.9,36.2,-19.0,24.7,2.7,0.9,-20.9,25.3,-22.5,25.9,-24.0,26.4,-26.0,27.1"; + "Cooling,7,8.8,30.3,21.7,29.0,21.2,27.8,20.6,23.7,27.7,22.9,27.0,22.1,26.0,5.2,240,22.4,17.5,26.0,21.5,16.6,25.3,20.7,15." + "7,24.7,71.8,27.5,68.9,27.1,65.7,25.8,25.9," + "Extremes,11.7,10.3,9.1,-18.5,32.7,2.8,1.4,-20.6,33.7,-22.2,34.5,-23.8,35.2,-25.9,36.2,-19.0,24.7,2.7,0.9,-20.9,25.3,-22." + "5,25.9,-24.0,26.4,-26.0,27.1"; auto dc_ = EpwDesignCondition::fromDesignConditionsString(line); ASSERT_TRUE(dc_); const auto& dc = *dc_; @@ -1731,14 +1733,16 @@ TEST(Filetypes, EpwDesignCondition_HoF_2025) { EXPECT_EQ(27.1, dc.extremeN50YearsMaxWetBulb().get()); const std::string epw = "LOCATION,Buffalo,NY,USA,TMYx,725280,42.9406,-78.7322,-5.0,215.4\n" - "DESIGN CONDITIONS,1," + line + "\n" - "TYPICAL/EXTREME PERIODS,0\n" - "GROUND TEMPERATURES,0\n" - "HOLIDAYS/DAYLIGHT SAVINGS,No,0,0,0\n" - "COMMENTS 1,\n" - "COMMENTS 2,\n" - "DATA PERIODS,1,1,Data,Wednesday,1/1,1/1\n" - "2025,1,1,1,60\n"; + "DESIGN CONDITIONS,1," + + line + + "\n" + "TYPICAL/EXTREME PERIODS,0\n" + "GROUND TEMPERATURES,0\n" + "HOLIDAYS/DAYLIGHT SAVINGS,No,0,0,0\n" + "COMMENTS 1,\n" + "COMMENTS 2,\n" + "DATA PERIODS,1,1,Data,Wednesday,1/1,1/1\n" + "2025,1,1,1,60\n"; auto epwFile = EpwFile::loadFromString(epw, false); ASSERT_TRUE(epwFile); ASSERT_EQ(1, epwFile->designConditions().size()); @@ -1748,8 +1752,10 @@ TEST(Filetypes, EpwDesignCondition_HoF_2025) { TEST(Filetypes, EpwDesignCondition_HoF_2025_Heuristics) { const std::string line = "This title does not include a year," "Heating,1,-15.9,-13.5,-20.3,0.6,-15.4,-18.1,0.8,-12.7,14.1,-1.0,12.8,-0.4,4.4,260,0.573," - "Cooling,7,8.8,30.3,21.7,29.0,21.2,27.8,20.6,23.7,27.7,22.9,27.0,22.1,26.0,5.2,240,22.4,17.5,26.0,21.5,16.6,25.3,20.7,15.7,24.7,71.8,27.5,68.9,27.1,65.7,25.8,25.9," - "Extremes,11.7,10.3,9.1,-18.5,32.7,2.8,1.4,-20.6,33.7,-22.2,34.5,-23.8,35.2,-25.9,36.2,-19.0,24.7,2.7,0.9,-20.9,25.3,-22.5,25.9,-24.0,26.4,-26.0,27.1"; + "Cooling,7,8.8,30.3,21.7,29.0,21.2,27.8,20.6,23.7,27.7,22.9,27.0,22.1,26.0,5.2,240,22.4,17.5,26.0,21.5,16.6,25.3,20.7,15." + "7,24.7,71.8,27.5,68.9,27.1,65.7,25.8,25.9," + "Extremes,11.7,10.3,9.1,-18.5,32.7,2.8,1.4,-20.6,33.7,-22.2,34.5,-23.8,35.2,-25.9,36.2,-19.0,24.7,2.7,0.9,-20.9,25.3,-22." + "5,25.9,-24.0,26.4,-26.0,27.1"; auto dc_ = EpwDesignCondition::fromDesignConditionsString(line); ASSERT_TRUE(dc_); const auto& dc = *dc_; @@ -1845,8 +1851,10 @@ TEST(Filetypes, EpwDesignCondition_HoF_2025_Heuristics) { TEST(Filetypes, EpwDesignCondition_HoF_2025_Heuristics_OverrideVersion) { const std::string line = "This title includes the 2009 version when it is not actually it," "Heating,1,-15.9,-13.5,-20.3,0.6,-15.4,-18.1,0.8,-12.7,14.1,-1.0,12.8,-0.4,4.4,260,0.573," - "Cooling,7,8.8,30.3,21.7,29.0,21.2,27.8,20.6,23.7,27.7,22.9,27.0,22.1,26.0,5.2,240,22.4,17.5,26.0,21.5,16.6,25.3,20.7,15.7,24.7,71.8,27.5,68.9,27.1,65.7,25.8,25.9," - "Extremes,11.7,10.3,9.1,-18.5,32.7,2.8,1.4,-20.6,33.7,-22.2,34.5,-23.8,35.2,-25.9,36.2,-19.0,24.7,2.7,0.9,-20.9,25.3,-22.5,25.9,-24.0,26.4,-26.0,27.1"; + "Cooling,7,8.8,30.3,21.7,29.0,21.2,27.8,20.6,23.7,27.7,22.9,27.0,22.1,26.0,5.2,240,22.4,17.5,26.0,21.5,16.6,25.3,20.7,15." + "7,24.7,71.8,27.5,68.9,27.1,65.7,25.8,25.9," + "Extremes,11.7,10.3,9.1,-18.5,32.7,2.8,1.4,-20.6,33.7,-22.2,34.5,-23.8,35.2,-25.9,36.2,-19.0,24.7,2.7,0.9,-20.9,25.3,-22." + "5,25.9,-24.0,26.4,-26.0,27.1"; auto dc_ = EpwDesignCondition::fromDesignConditionsString(line); ASSERT_TRUE(dc_); const auto& dc = *dc_;