-
Notifications
You must be signed in to change notification settings - Fork 17
188 lines (174 loc) · 9.36 KB
/
buildtest.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
name: Build Test
# Builds and tests stormpy with different versions of Storm
# also deploys images to Dockerhub
on:
push:
branches:
- master
schedule:
# run weekly
- cron: '0 10 * * 3'
# needed to trigger the workflow manually
workflow_dispatch:
pull_request:
env:
GIT_URL: "${{ github.server_url }}/${{ github.repository }}.git"
BRANCH: "${{ github.ref }}"
# GitHub runners currently have two cores
NR_JOBS: "2"
jobs:
indepthTests:
name: Indepth Tests (${{ matrix.debugOrRelease}}, ${{ matrix.setupArgs.name }})
runs-on: ubuntu-latest
env:
RELEASE_IMG: "storm:ci-release"
DEBUG_IMG: "storm:ci-debug"
strategy:
matrix:
debugOrRelease: ["debug", "release"]
setupArgs:
- {name: "all libraries", disableFlags: "", optionalLibs: "[numpy,plot]"}
- {name: "no libraries", disableFlags: "--disable-dft --disable-gspn --disable-pars --disable-pomdp", optionalLibs: ""}
steps:
- name: Setup environment variables
# this is strangely the best way to implement environment variables based on the value of another
# GITHUB_ENV is a magic variable pointing to a file; if a line with format {NAME}={VALUE}
# then the env variable with name NAME will be created/updated with VALUE
run: |
([[ ${{ matrix.debugOrRelease }} == "debug" ]] && echo "BUILD_TYPE=Debug" || echo "BUILD_TYPE=Release") >> $GITHUB_ENV
([[ ${{ matrix.debugOrRelease }} == "debug" ]] && echo "IMG=${DEBUG_IMG}" || echo "IMG=${RELEASE_IMG}") >> $GITHUB_ENV
([[ ${{ matrix.debugOrRelease }} == "debug" ]] && echo "DEBUG_SWITCH=--debug" || true) >> $GITHUB_ENV
# Restrict tests to directory 'tests' (excluding examples and documentation) if not all libraries are present
([[ "${{ matrix.setupArgs.disableFlags }}" != "" ]] && echo "TEST_OPT=--addopts tests" || true) >> $GITHUB_ENV
- name: Git clone
uses: actions/checkout@v3
- name: Build stormpy from Dockerfile
run: docker build -t movesrwth/stormpy:ci-${{ matrix.debugOrRelease }} . --build-arg STORM_BASE=movesrwth/${IMG} --build-arg build_type=${BUILD_TYPE} --build-arg setup_args="${DEBUG_SWITCH} ${{ matrix.setupArgs.disableFlags }}" --build-arg setup_args_pycarl=${DEBUG_SWITCH} --build-arg no_threads=${NR_JOBS}
- name: Run Docker
run: docker run -d -it --name ci movesrwth/stormpy:ci-${{ matrix.debugOrRelease }}
- name: Build optional stormpy libraries
run: docker exec ci bash -c "cd /opt/stormpy; pip3 install -e '.${{ matrix.setupArgs.optionalLibs }}'"
- name: Run tests
run: docker exec ci bash -c "cd /opt/stormpy; python setup.py test $TEST_OPT"
stableTest:
name: Test on stable
runs-on: ubuntu-latest
env:
RELEASE_IMG: "storm:stable"
DEBUG_IMG: "storm:stable-debug"
strategy:
matrix:
debugOrRelease: ["debug", "release"]
# Allow failures of stable versions as new features might have been added
steps:
- name: Setup environment variables
# this is strangely the best way to implement environment variables based on the value of another
# GITHUB_ENV is a magic variable pointing to a file; if a line with format {NAME}={VALUE}
# then the env variable with name NAME will be created/updated with VALUE
run: |
([[ ${{ matrix.debugOrRelease }} == "debug" ]] && echo "BUILD_TYPE=Debug" || echo "BUILD_TYPE=Release") >> $GITHUB_ENV
([[ ${{ matrix.debugOrRelease }} == "debug" ]] && echo "IMG=${DEBUG_IMG}" || echo "IMG=${RELEASE_IMG}") >> $GITHUB_ENV
([[ ${{ matrix.debugOrRelease }} == "debug" ]] && echo "DEBUG_SWITCH=--debug" || true) >> $GITHUB_ENV
- name: Git clone
uses: actions/checkout@v3
- name: Replace Dockerfile
run: cp .github/workflows/Dockerfile.stable Dockerfile
- name: Build dependencies
run: docker build -t movesrwth/stormpy:ci-${{ matrix.debugOrRelease }} . --build-arg STORM_BASE=movesrwth/${IMG} --build-arg build_type=${BUILD_TYPE} --build-arg setup_args_pycarl=${DEBUG_SWITCH} --build-arg no_threads=${NR_JOBS}
- name: Run Docker
run: docker run -d -it --name ci movesrwth/stormpy:ci-${{ matrix.debugOrRelease }}
- name: Build stormpy
# Build stormpy explicitly to catch exit code
id: build_stormpy
shell: bash {0} // Deactivate fast-fail to handle exit code for incompatibility
run: |
docker exec ci bash -c "cd /opt/stormpy; python setup.py build_ext ${DEBUG_SWITCH} -j ${NR_JOBS} develop"
status=$?
if [ $status -eq 42 ]; then
# Warn about incompatibility but do not handle as failure
echo "::warning file=setup.py,line=82::Stormpy is incompatible with stable version of Storm"
# Deactivate tests
echo "run_tests=false" >> $GITHUB_OUTPUT
else
echo "run_tests=true" >> $GITHUB_OUTPUT
exit $status
fi
- name: Run tests
if: steps.build_stormpy.outputs.run_tests == 'true'
run: docker exec ci bash -c "cd /opt/stormpy; python setup.py test"
deploy:
name: Test and Deploy on latest
runs-on: ubuntu-latest
env:
RELEASE_IMG: "storm:ci-release"
DEBUG_IMG: "storm:ci-debug"
strategy:
matrix:
debugOrRelease: ["debug", "release"]
steps:
- name: Setup environment variables
# this is strangely the best way to implement environment variables based on the value of another
# GITHUB_ENV is a magic variable pointing to a file; if a line with format {NAME}={VALUE}
# then the env variable with name NAME will be created/updated with VALUE
run: |
([[ ${{ matrix.debugOrRelease }} == "debug" ]] && echo "CMAKE_ARGS=${CMAKE_DEBUG}" || echo "CMAKE_ARGS=${CMAKE_RELEASE}") >> $GITHUB_ENV
([[ ${{ matrix.debugOrRelease }} == "debug" ]] && echo "IMG=${DEBUG_IMG}" || echo "IMG=${RELEASE_IMG}") >> $GITHUB_ENV
([[ ${{ matrix.debugOrRelease }} == "debug" ]] && echo "DEBUG_SWITCH=--debug" || true) >> $GITHUB_ENV
- name: Git clone
uses: actions/checkout@v3
- name: Build stormpy from Dockerfile
run: docker build -t movesrwth/stormpy:ci-${{ matrix.debugOrRelease }} . --build-arg STORM_BASE=movesrwth/${IMG} --build-arg build_type=${BUILD_TYPE} --build-arg setup_args=${DEBUG_SWITCH} --build-arg setup_args_pycarl=${DEBUG_SWITCH} --build-arg no_threads=${NR_JOBS}
- name: Run Docker
run: docker run -d -it --name ci movesrwth/stormpy:ci-${{ matrix.debugOrRelease }}
- name: Run tests
run: docker exec ci bash -c "cd /opt/stormpy; python setup.py test"
- name: Login into docker
# Only login if using master on original repo (and not for pull requests or forks)
if: github.repository_owner == 'moves-rwth' && github.ref == 'refs/heads/master'
run: echo "${{ secrets.STORM_CI_DOCKER_PASSWORD }}" | docker login -u "${{ secrets.STORM_CI_DOCKER_USERNAME }}" --password-stdin
- name: Deploy stormpy
# Only deploy if using master on original repo (and not for pull requests or forks)
if: github.repository_owner == 'moves-rwth' && github.ref == 'refs/heads/master'
run: |
docker commit ci movesrwth/stormpy:ci-${{ matrix.debugOrRelease }}
docker push movesrwth/stormpy:ci-${{ matrix.debugOrRelease }}
- name: Install documentation dependencies
if: matrix.debugOrRelease == 'release'
run: |
docker exec ci apt-get install -qq -y pandoc
docker exec ci bash -c "cd /opt/stormpy; pip install -e '.[doc,numpy]'"
- name: Build documentation
if: matrix.debugOrRelease == 'release'
run: |
docker exec ci bash -c "cd /opt/stormpy/doc; make html"
docker exec ci rm -r /opt/stormpy/doc/build/html/_sources
docker cp ci:/opt/stormpy/doc/build/html .
- name: Deploy documentation
# Only deploy for release version and using master on original repo (and not for pull requests or forks)
if: matrix.debugOrRelease == 'release' && github.repository_owner == 'moves-rwth' && github.ref == 'refs/heads/master'
uses: peaceiris/actions-gh-pages@v3
with:
personal_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./html
notify:
name: Email notification
runs-on: ubuntu-latest
needs: [indepthTests,stableTest, deploy]
# Only run in main repo and even if previous step failed
if: github.repository_owner == 'moves-rwth' && always()
steps:
- uses: technote-space/workflow-conclusion-action@v2
- uses: dawidd6/action-send-mail@v2
with:
server_address: ${{ secrets.STORM_CI_MAIL_SERVER }}
server_port: 587
username: ${{ secrets.STORM_CI_MAIL_USERNAME }}
password: ${{ secrets.STORM_CI_MAIL_PASSWORD }}
subject: "[You broke it] CI run failed for ${{ github.repository }}"
body:
"CI job of ${{ github.repository }} has failed for commit ${{ github.sha }}.\n\
The error type is: ${{ env.WORKFLOW_CONCLUSION }}.\n\n\
For more information, see https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
to: ${{ secrets.STORM_CI_MAIL_RECIPIENTS }}
from: Github Actions <[email protected]>
if: env.WORKFLOW_CONCLUSION != 'success' # notify only if failure