Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 120 additions & 0 deletions .github/actions/configure-and-build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: "CMake Configure and Build"
description: "Run CMake Configure and Build the targets"

inputs:
build-directory:
description: "the E+ working directory, top level of the repo"
nproc:
required: true
minimal-targets:
description: "If true will build only energyplus and a couple of fortran ones, just enough to run reg tests"
type: boolean
default: false
python-version:
required: true
python-root-dir:
required: true
enable-pch:
description: "Turn on ENABLE_PCH to have pre-compiled headers. Pass ON or OFF"
default: "OFF"

runs:
using: "composite"
steps:

- name: Configure CMake And Build on Windows
if: runner.os == 'Windows'
working-directory: ${{ inputs.build-directory }}
shell: pwsh
run: |
$ErrorActionPreference = 'stop'
$PSNativeCommandUseErrorActionPreference = $true

function Begin-Group {
param([string]$Title)
Write-Output "::group::`e[93m$Title`e[0m"
}

switch ($env:PROCESSOR_ARCHITECTURE) {
"AMD64" { $target_arch = "x64" }
"ARM64" { $target_arch = "arm64" }
default { throw "Unknown architecture: $env:PROCESSOR_ARCHITECTURE" }
}

Begin-Group "Entering a VS Dev Shell"
Import-Module "$env:MSVC_DIR\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
Enter-VsDevShell -VsInstallPath "$env:MSVC_DIR" -SkipAutomaticLocation -devCmdArguments "-arch=$target_arch"
Write-Output "::endgroup::"

Begin-Group "CMake configure"
cmake `
-G Ninja `
-DENABLE_PCH:BOOL=${{ inputs.enable-pch }} `
-DCMAKE_BUILD_TYPE:STRING=Release `
-DLINK_WITH_PYTHON:BOOL=ON `
-DPYTHON_CLI:BOOL=ON `
-DPython_REQUIRED_VERSION:STRING=${{ inputs.python-version }} `
-DPython_ROOT_DIR:PATH=${{ inputs.python-root-dir }} `
-DBUILD_TESTING:BOOL=ON `
-DBUILD_FORTRAN:BOOL=ON `
-DBUILD_PACKAGE:BOOL=OFF `
-DDOCUMENTATION_BUILD:STRING=DoNotBuild `
-DENABLE_OPENMP:BOOL=OFF `
../
Write-Output "::endgroup::"

if ("${{ inputs.minimal-targets }}" -eq "true") {
Begin-Group "Building only energyplus and fortran targets"
ninja energyplus ExpandObjects_build ReadVars_build Slab_build Basement_build AppGPostProcess_build ParametricPreprocessor_build
Write-Output "::endgroup::"
}
else {
Begin-Group "Building full energyplus"
ninja
Write-Output "::endgroup::"
}

Begin-Group "Showing CCache Stats"
try { ccache --show-stats -vv } catch { ccache --show-stats }
ccache --zero-stats
ccache -p
Write-Output "::endgroup::"

- name: Configure CMake And Build on Unix
if: runner.os != 'Windows'
working-directory: ${{ inputs.build-directory }}
shell: bash
run: |
begin_group() { echo -e "::group::\033[93m$1\033[0m"; }

begin_group "CMake configure"
cmake \
-G Ninja \
-DENABLE_PCH:BOOL=${{ inputs.enable-pch }} \
-DCMAKE_BUILD_TYPE:STRING=Release \
-DLINK_WITH_PYTHON:BOOL=ON \
-DPYTHON_CLI:BOOL=ON \
-DPython_REQUIRED_VERSION:STRING=${{ inputs.python-version }} \
-DPython_ROOT_DIR:PATH=${{ inputs.python-root-dir }} \
-DBUILD_TESTING:BOOL=ON \
-DBUILD_FORTRAN:BOOL=ON \
-DBUILD_PACKAGE:BOOL=OFF \
-DDOCUMENTATION_BUILD:STRING=DoNotBuild \
-DENABLE_OPENMP:BOOL=OFF \
../

if [ "${{ inputs.minimal-targets }}" == "true" ]; then
begin_group "Builing only energyplus and fortran targets"
ninja energyplus ExpandObjects ReadVarsESO Slab Basement AppGPostProcess ParametricPreprocessor
echo "::endgroup::"
else
begin_group "Builing full energyplus"
ninja
echo "::endgroup::"
fi;

begin_group "Showing CCache Stats"
ccache --show-stats -vv || ccache --show-stats || true
ccache --zero-stats
ccache -p
echo "::endgroup::"
114 changes: 114 additions & 0 deletions .github/actions/setup-runner/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: "Setup Runner"
description: "Setup Python, System Dependencies and configure CCache"

inputs:
python-version:
required: true
python-arch:
required: true

outputs:
nproc:
description: "The number of processors"
value: ${{ steps.install-deps.outputs.nproc }}
python-root-dir:
description: "The Python_ROOT_DIR"
value: ${{ steps.install-deps.outputs.python-root-dir }}
ccache-dir:
description: "The ccache directory"
value: ${{ steps.install-deps.outputs.ccache-dir }}
compiler-id:
description: "The computer compiler id to use as a caching key"
value: ${{ steps.install-deps.outputs.compiler-id }}

runs:
using: "composite"
steps:

- name: Set up Python ${{ inputs.python-version }}
id: setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
architecture: ${{ inputs.python-arch }}

- name: Install Dependencies
id: install-deps
shell: bash
run: |
echo "Configuring"
begin_group() { echo -e "::group::\033[93m$1\033[0m"; }

begin_group "Figure out NPROC"
NPROC=$(nproc 2>/dev/null || sysctl -n hw.logicalcpu)
echo "There are $NPROC threads available"
echo "NPROC=$NPROC" >> $GITHUB_ENV
echo "nproc=$NPROC" >> $GITHUB_OUTPUT
echo "::endgroup::"

if [ "$RUNNER_OS" == "Windows" ]; then
DIR_SEP="\\"
else
DIR_SEP="/"
fi
echo "DIR_SEP=$DIR_SEP" >> $GITHUB_ENV

begin_group "Install system dependencies such as ninja and ccache"
CCACHE_DIR="${{ github.workspace }}${DIR_SEP}.ccache"
echo "CCACHE_DIR=$CCACHE_DIR"
echo "CCACHE_DIR=$CCACHE_DIR" >> $GITHUB_ENV
echo "ccache-dir=$CCACHE_DIR" >> $GITHUB_OUTPUT

if [ "$RUNNER_OS" == "Linux" ]; then
echo "FC=gfortran-13" >> $GITHUB_ENV
sudo apt-get -qq update
sudo apt-get -qq install -y libxkbcommon-x11-0 xorg-dev libgl1-mesa-dev ccache

COMPILER="gcc-$(gcc -dumpversion)"
elif [ "$RUNNER_OS" == "Windows" ]; then
choco install ninja ccache

# C:\Program Files\Microsoft Visual Studio\2022\Enterprise
MSVC_DIR=$(vswhere -products '*' -requires Microsoft.Component.MSBuild -latest -property installationPath)
echo "Latest MSVC_DIR is: $MSVC_DIR"
echo "MSVC_DIR=$MSVC_DIR" >> $GITHUB_ENV
# add folder containing vcvarsall.bat
echo "$MSVC_DIR\VC\Auxiliary\Build" >> $GITHUB_PATH
# msvc-17.14
# COMPILER="msvc-$(vswhere -products '*' -requires Microsoft.Component.MSBuild -latest -property installationVersion | cut -d'.' -f 1,2)"
# msvc-2022
COMPILER="msvc-$(vswhere -products '*' -requires Microsoft.Component.MSBuild -latest -property catalog_productLineVersion)"
elif [ "$RUNNER_OS" == "macOS" ]; then
brew update
brew install tcl-tk
brew reinstall gcc@13
echo "FC=$(brew --prefix gcc@13)/bin/gfortran-13" >> $GITHUB_ENV
echo "MACOSX_DEPLOYMENT_TARGET=${{ matrix.macos_dev_target }}" >> $GITHUB_ENV

brew install ccache
ccache --set-config=compiler_check=content # darwin only
# clang-19
COMPILER="clang-$(clang -dumpversion | cut -d'.' -f 1)"
fi;

echo "COMPILER=$COMPILER" >> $GITHUB_ENV
echo "compiler-id=$COMPILER" >> $GITHUB_OUTPUT

# Setup ccache, common
ccache --set-config=cache_dir=$CCACHE_DIR
ccache --set-config=max_size=500M
ccache --set-config=compression=true
ccache --set-config=sloppiness=pch_defines,time_macros
ccache --set-config=base_dir="${{ github.workspace }}"

echo "::endgroup::"

begin_group "App Python_ROOT_DIR env variable"
Python_ROOT_DIR="$RUNNER_TOOL_CACHE/Python/${{ steps.setup-python.outputs.python-version }}/${{ inputs.python-arch }}"
echo "Python_ROOT_DIR=$Python_ROOT_DIR" >> $GITHUB_ENV
echo "python-root-dir=$Python_ROOT_DIR" >> $GITHUB_OUTPUT
echo "::endgroup::"

begin_group "Install python dependencies"
pip install pytest lxml tzdata
echo "::endgroup::"
29 changes: 29 additions & 0 deletions .github/workflows/clean_cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Cleanup github runner caches on closed pull requests
on:
pull_request:
types:
- closed

jobs:
cleanup:
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- name: Cleanup
run: |
echo "Fetching list of cache keys"
cacheKeysForPR=$(gh cache list --ref $BRANCH --limit 100 --json id --jq '.[].id')

## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh cache delete $cacheKey
done
echo "Done"
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge
130 changes: 130 additions & 0 deletions .github/workflows/run_and_cache_regressions_develop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
name: Build, Run and Cache Develop Regressions

on:
push:
branches: [ develop ]

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FC: gfortran-13

jobs:
build_and_test:
name: Testing on ${{ matrix.pretty }}
runs-on: ${{ matrix.os }}
permissions:
pull-requests: write
strategy:
fail-fast: false
matrix:
include:
- os: macos-14
macos_dev_target: 13.0
arch: arm64
python-arch: arm64
pretty: "Mac arm64"
python-version: 3.12.3 # 3.12.2 not available on Ubuntu 24 GHA
- os: ubuntu-24.04
arch: x86_64
python-arch: x64
pretty: "Ubuntu 24.04"
python-version: 3.12.3 # 3.12.2 not available on Ubuntu 24 GHA
- os: windows-2022
arch: x86_64
python-arch: x64
pretty: "Windows x64"
python-version: 3.12.3 # 3.12.2 not available on Ubuntu 24 GHA
- os: ubuntu-24.04-arm
arch: arm64
python-arch: arm64
pretty: "Ubuntu 24.04 arm64"
python-version: 3.12.3 # 3.12.2 not available on Ubuntu 24 GHA
- os: windows-11-arm
arch: arm64
python-arch: arm64
pretty: "Windows arm64"
python-version: 3.12.10

steps:

- uses: actions/checkout@v5

- name: Setup System
id: setup-runner
uses: ./.github/actions/setup-runner
with:
python-version: ${{ matrix.python-version }}
python-arch: ${{ matrix.python-arch }}

- name: Get Current SHA
shell: bash
run: |
echo "Figuring out the develop GIT SHA"
CURRENT_SHA=$(git rev-parse --short=10 HEAD)
echo "Develop GIT SHA is '${CURRENT_SHA}'"
echo "CURRENT_SHA=$CURRENT_SHA" >> $GITHUB_ENV

- name: Cache CCACHE
uses: actions/cache@v4
id: cacheccache
with:
path: |
${{ steps.setup-runner.outputs.ccache-dir }}
key: ccache-${{ matrix.os }}-${{ steps.setup-runner.outputs.compiler-id }}-${{ env.CURRENT_SHA }}
restore-keys: |
ccache-${{ matrix.os }}-${{ steps.setup-runner.outputs.compiler-id }}-
ccache-${{ matrix.os }}-

- name: Did restoring the CCache-cache work? Yes
# If the SDK wasn't found in the cache
if: steps.cacheccache.outputs.cache-hit == 'true'
shell: bash
run: |
ccache --show-stats -vv || ccache --show-stats
ccache --zero-stats
ccache -p

- name: Create Build Directory
shell: bash
run: |
cmake -E make_directory ./build/
if [ "$RUNNER_OS" == "macOS" ]; then
# The MACOSX_DEPLOYMENT_TARGET environment variable sets the default value for the CMAKE_OSX_DEPLOYMENT_TARGET variable.
echo MACOSX_DEPLOYMENT_TARGET=${{ matrix.macos_dev_target }} >> $GITHUB_ENV
fi;

- name: Install problem matcher
shell: bash
run: echo "::add-matcher::./.github/workflows/cpp-problem-matcher.json"

- name: Configure and Build
uses: ./.github/actions/configure-and-build
with:
enable-pch: OFF
minimal-targets: false
build-directory: ./build
nproc: ${{ steps.setup-runner.outputs.nproc }}
python-version: ${{ matrix.python-version }}
python-root-dir: ${{ steps.setup-runner.outputs.python-root-dir }}

- name: Remove problem matcher
shell: bash
run: echo "::remove-matcher owner=gcc-problem-matcher::"

- name: Run Tests
working-directory: ./build
shell: bash
run: |
if ctest -j ${{ env.NPROC }}; then
echo "All tests passed"
else
echo "Re-running failed tests..."
ctest --rerun-failed --output-on-failure
fi;
mv testfiles testfiles-develop

- uses: actions/cache/save@v4
with:
path: |
./build/testfiles-develop
key: baselineregression-${{ matrix.os }}-${{ env.CURRENT_SHA }}
Loading
Loading