Skip to content

Templates and tests for horizontal piping modeling (#627) #2577

Templates and tests for horizontal piping modeling (#627)

Templates and tests for horizontal piping modeling (#627) #2577

Workflow file for this run

name: CI
on:
push:
# re-enable all branches until we start simulating again.
# branches:
# - 'develop'
# - 'main'
defaults:
run:
shell: bash
jobs:
test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.10", "3.12.1"]
test_env: [python, docs, mypy]
mbl_tag: [v10.0.0]
exclude:
# only test mypy on linux for all versions of python
- os: windows-latest
test_env: mypy
# only test docs on linux for all versions of python
- os: windows-latest
test_env: docs
runs-on: ${{ matrix.os }}
permissions: write-all
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Display system info
run: |
python -c "import sys; print(sys.version)"
docker --version
docker-compose --version
- name: Install Poetry
uses: Gr1N/setup-poetry@v8 # optionally set specific poetry version. Defaults to latest
- name: Install dependencies with Poetry
# poetry setuptools workaround sourced from https://github.com/python-poetry/poetry/issues/7611#issuecomment-1711443539
run: |
poetry --version
poetry self add setuptools
poetry install
- name: Install modelicafmt
run: |
RUNNER_SYSTEM=$(python -c 'import platform; print(platform.system())')
curl -SLO "https://github.com/urbanopt/modelica-fmt/releases/download/v0.2-pr.2/modelica-fmt_0.2-pr.2_${RUNNER_SYSTEM}_x86_64.tar.gz"
tar --exclude='README.md' --exclude='CHANGELOG.md' -xzf modelica-fmt_0.2-pr.2_${RUNNER_SYSTEM}_x86_64.tar.gz
chmod +x modelicafmt
if [[ $RUNNER_SYSTEM == 'Linux' ]]; then
sudo mv modelicafmt /usr/local/bin/
else
mv modelicafmt '/c/Program Files/'
fi
- name: Install MBL
run: |
if [[ '${{ matrix.os }}' == 'ubuntu-latest' ]]; then
MODELICAPATH='/home/runner/work/modelica-buildings'
else
echo $GITHUB_WORKSPACE
MODELICAPATH='/c/Program Files/modelica-buildings'
fi
git clone --single-branch --branch ${{ matrix.mbl_tag }} https://github.com/lbl-srg/modelica-buildings.git "${MODELICAPATH}"
cd "${MODELICAPATH}"
echo "Git branch is $(git branch)"
# export MODELICAPATH for subsequent steps
echo "MODELICAPATH=${MODELICAPATH}" >> $GITHUB_ENV
- name: Run pytest (including simulations)
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
if: matrix.test_env == 'python' && matrix.os == 'ubuntu-latest'
run: poetry run pytest tests --doctest-modules -v -m 'not dymola' --cov-report term-missing --cov .
- name: Run Pytest (no compilation or simulation)
if: matrix.test_env == 'python' && matrix.os == 'windows-latest'
run: poetry run pytest tests --doctest-modules -v -m 'not simulation and not compilation and not dymola'
- name: Run pre-commit
run: poetry run pre-commit run --show-diff-on-failure --color=always --all-files
- name: Run mypy
if: matrix.test_env =='mypy'
run: poetry run mypy --install-types --non-interactive --show-error-codes .
- name: Build docs
if: matrix.test_env == 'docs'
run: |
cd docs
poetry run make html
- name: Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ matrix.os == 'ubuntu-latest' && matrix.test_env == 'python' }}
run: |
poetry run coveralls
- name: Job Failed
if: ${{ failure() }}
run: |
echo "Maybe these logs will help?"
ls -alt $GITHUB_WORKSPACE
find $GITHUB_WORKSPACE -type f -name 'stdout.log' -print | while read filename; do
echo "============================================ stdout.log ========================================="
echo "$filename"
cat "$filename"
done