Skip to content

Test OS SDK CLI from OpenStudio Application #22

Test OS SDK CLI from OpenStudio Application

Test OS SDK CLI from OpenStudio Application #22

Workflow file for this run

name: Test OS SDK CLI from OpenStudio Application
on:
workflow_dispatch:
inputs:
run_id:
description: 'The github actions run_id where to find the artifacts'
required: true
jobs:
test:
runs-on: ${{ matrix.os }}
continue-on-error: true
strategy:
# fail-fast: Default is true, switch to false to allow one platform to fail and still run others
fail-fast: false
matrix:
os: [ubuntu-20.04, ubuntu-22.04, windows-2022, macos-13, macos-arm64]
include:
- os: ubuntu-20.04
SELF_HOSTED: false
PLATFORM_NAME: Linux
BINARY_EXT: deb
COMPRESSED_EXT: tar.gz
- os: ubuntu-22.04
SELF_HOSTED: false
PLATFORM_NAME: Linux
BINARY_EXT: deb
COMPRESSED_EXT: tar.gz
- os: windows-2022
SELF_HOSTED: false
PLATFORM_NAME: Windows
BINARY_EXT: exe
COMPRESSED_EXT: zip
- os: macos-13
SELF_HOSTED: false
PLATFORM_NAME: Darwin
BINARY_EXT: dmg
COMPRESSED_EXT: tar.gz
MACOSX_DEPLOYMENT_TARGET: 10.15
- os: macos-arm64
SELF_HOSTED: true
PLATFORM_NAME: Darwin
BINARY_EXT: dmg
COMPRESSED_EXT: tar.gz
MACOSX_DEPLOYMENT_TARGET: 12.1
steps:
- name: Download binary installer
uses: actions/download-artifact@v4
id: downloader
with:
pattern: OpenStudioApplication-*-${{ matrix.os }}.${{ matrix.COMPRESSED_EXT }}
run-id: ${{ github.event.inputs.run_id}}
github-token: ${{ secrets.GITHUB_TOKEN }}
path: cli_tester
merge-multiple: true
- name: Install OSApp
working-directory: cli_tester
shell: bash
run: |
set -x
echo "steps.downloader.outputs.download-path=${{ steps.downloader.outputs.download-path }}"
ls -R
archive=$(ls *.${{ matrix.COMPRESSED_EXT }})
OSAPP_DIR_NAME=$(basename $archive .${{ matrix.COMPRESSED_EXT }})
echo "OSAPP_DIR_NAME=$OSAPP_DIR_NAME" >> $GITHUB_ENV
if [ "${{ matrix.COMPRESSED_EXT }}" == "tar.gz" ]; then
#OSAPP_DIR_NAME=$(tar tzf $archive | head -1 | cut -f1 -d"/")
tar xfz $archive
else
7z X $archive
fi
examples_dir=$(find $(pwd)/$OSAPP_DIR_NAME -name "Examples" -type d)
OSAPP_ROOT_DIR=$(dirname $examples_dir)
echo "OSAPP_ROOT_DIR=$OSAPP_ROOT_DIR" >> $GITHUB_ENV
echo "puts ARGV" > test.rb
echo "import sys" > test.py
echo "print(sys.argv)" >> test.py
ls
cp -R $examples_dir/compact_osw/* .
if [ ! -d "$OSAPP_ROOT_DIR" ]; then
echo "Directly does not exist! $OSAPP_ROOT_DIR"
exit 1
fi
if [ "$RUNNER_OS" == "Linux" ]; then
export PATH="$OSAPP_ROOT_DIR/bin:$PATH"
echo "$OSAPP_ROOT_DIR/bin" >> $GITHUB_PATH
elif [ "$RUNNER_OS" == "Windows" ]; then
export PATH="$OSAPP_ROOT_DIR/bin:$PATH"
echo "$OSAPP_ROOT_DIR/bin" >> $GITHUB_PATH
elif [ "$RUNNER_OS" == "macOS" ]; then
export PATH="$OSAPP_ROOT_DIR/OpenStudioApp.app/Contents/MacOS:$PATH"
echo "$OSAPP_ROOT_DIR/OpenStudioApp.app/Contents/MacOS" >> $GITHUB_PATH
fi
which openstudio
openstudio openstudio_version
if openstudio labs; then
echo "The Ruby CLI is the default"
echo CLASSIC_SUBCOMMAND= >> $GITHUB_ENV
echo LABS_SUBCOMMAND=labs >> $GITHUB_ENV
else
echo "The C++ CLI is the default"
echo CLASSIC_SUBCOMMAND=classic >> $GITHUB_ENV
echo LABS_SUBCOMMAND= >> $GITHUB_ENV
fi
- name: EnergyPlus itself works
working-directory: cli_tester
shell: bash
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
$OSAPP_ROOT_DIR/EnergyPlus/energyplus --help || ( echo "EnergyPlus missing dependencies!" && sudo apt install -y libgomp1 libx11-6 && $OSAPP_ROOT_DIR/EnergyPlus/energyplus --help )
else
$OSAPP_ROOT_DIR/EnergyPlus/energyplus --help
fi
- name: Classic Ruby CLI test
working-directory: cli_tester
shell: bash
run: |
set -x
openstudio $CLASSIC_SUBCOMMAND --help
openstudio $CLASSIC_SUBCOMMAND openstudio_version
openstudio $CLASSIC_SUBCOMMAND energyplus_version
openstudio $CLASSIC_SUBCOMMAND ruby_version
openstudio $CLASSIC_SUBCOMMAND -e "puts OpenStudio::Model::Model.new()"
openstudio $CLASSIC_SUBCOMMAND -e "require 'oga'; puts Oga::VERSION"
openstudio $CLASSIC_SUBCOMMAND execute_ruby_script test.rb -x arg2
openstudio $CLASSIC_SUBCOMMAND run -w compact_ruby_only.osw
- name: Labs C++ CLI Test
working-directory: cli_tester
shell: bash
run: |
set -x
openstudio $LABS_SUBCOMMAND --help
openstudio $LABS_SUBCOMMAND openstudio_version
openstudio $LABS_SUBCOMMAND energyplus_version
openstudio $LABS_SUBCOMMAND ruby_version
openstudio $LABS_SUBCOMMAND python_version
openstudio $LABS_SUBCOMMAND -e "puts OpenStudio::Model::Model.new()"
openstudio $LABS_SUBCOMMAND -e "require 'oga'; puts Oga::VERSION"
openstudio $LABS_SUBCOMMAND execute_ruby_script test.rb -x arg2
openstudio $LABS_SUBCOMMAND execute_python_script test.py -x arg2
openstudio $LABS_SUBCOMMAND run -w compact_ruby_only.osw
openstudio $LABS_SUBCOMMAND run -w compact_python_only_twomeasures.osw
openstudio $LABS_SUBCOMMAND run -w compact_ruby_then_python.osw
openstudio $LABS_SUBCOMMAND run -w compact_python_then_ruby.osw
- name: Display structure
if: ${{ always() && runner.os == 'Windows' }}
working-directory: cli_tester/${{ env.OSAPP_DIR_NAME }}
run: |
tree /f /a
- name: Display structure
if: ${{ always() && runner.os != 'Windows' }}
working-directory: ${{ env.OSAPP_ROOT_DIR }}
run: |
separator() {
echo -e "\n\033[0;31m===========================================================\033[0m"
};
if [ "$RUNNER_OS" == "macOS" ]; then
brew install tree
inspect_lib() {
separator
echo -e "\033[0;33m$1\033[0m"
otool -L $1
otool -l $1 | grep -A2 LC_RPATH || true
}
BUNDLE_EXT=bundle
SONAME=dylib
CLI_PREFIX=OpenStudioApp.app/Contents/MacOS
else
inspect_lib() {
separator
echo -e "\033[0;33m$1\033[0m"
ldd $1
objdump -x $1 | grep RUNPATH || true
}
BUNDLE_EXT=so
SONAME=so
CLI_PREFIX=bin
fi
tree -I 'Radiance|python_standard_lib|include'
inspect_lib $CLI_PREFIX/openstudio
inspect_lib lib/libopenstudiolib.$SONAME
inspect_lib lib/libpythonengine.so
inspect_lib lib/librubyengine.so
inspect_lib Python/_openstudiomodel.so
inspect_lib Ruby/openstudio.$BUNDLE_EXT
inspect_lib EnergyPlus/energyplus
inspect_lib EnergyPlus/libenergyplusapi.$SONAME
inspect_lib EnergyPlus/ExpandObjects || true
- name: cleanup
if: ${{ always() }}
shell: bash
run: |
rm -Rf ./cli_tester/ || true
rm -Rf ./OpenStudioApplication-*-${{ matrix.os }}.${{ matrix.BINARY_EXT }} || true
rm -Rf ./OpenStudioApplication-*-${{ matrix.os }}.${{ matrix.COMPRESSED_EXT }} || true