-
Notifications
You must be signed in to change notification settings - Fork 11
131 lines (127 loc) · 4.62 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: CI
on:
push:
# re-enable all branches until we start simulating again.
# branches:
# - 'develop'
# - 'main'
defaults:
run:
shell: bash
# Cancel existing run if a new one is started
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.10", "3.11"]
test_env: [python, docs, mypy]
mbl_branch: [maint_9.1.x]
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 }}
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
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 and configure Poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: 1.5.1
- name: Install dependencies with Poetry
run: |
poetry --version
poetry install
poetry update
- 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 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
env:
MATRIX_OS: ${{ matrix.os }}
MBL_BRANCH: ${{ matrix.mbl_branch }}
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 ${MBL_BRANCH} 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
# Perhaps we want to eneable this again to build the gmt running container?
# -
# name: Build Spawn Modelica Docker Container
# run: |
# cd geojson_modelica_translator/modelica/lib/runner
# docker build -t nrel/gmt-om-runner:latest .
- name: Run pytest (simulation only on linux)
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: |
if [ '${{ matrix.test_env }}' == 'python' ]; then
if [ '${{ matrix.os }}' == 'windows-latest' ]; then
poetry run pytest --doctest-modules -v -m 'not simulation and not compilation' ./tests
else
poetry run pytest --doctest-modules -v --cov-report term-missing --cov . ./tests
fi
fi
- name: Run pre-commit
uses: pre-commit/[email protected]
with:
extra_args: --all-files
- name: Run mypy
run: |
if [ '${{ matrix.test_env }}' == 'mypy' ]; then
poetry run mypy --install-types --non-interactive --show-error-codes .
fi
- name: Build docs
run: |
if [ '${{ matrix.test_env }}' == 'docs' ]; then
cd docs
poetry run make html
fi
- name: Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ matrix.os == 'ubuntu-latest' && matrix.test_env == 'python' && matrix.mbl_branch == 'maint_9.1.x' }}
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