-
Notifications
You must be signed in to change notification settings - Fork 280
186 lines (179 loc) · 7.21 KB
/
macos_m1_install.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
name: MacOS M1
'on':
workflow_dispatch:
inputs:
git-ref:
description: Git Ref
default: master
required: true
schedule:
- cron: "15 23 * * *"
push:
branches: [macos_test]
jobs:
install_and_test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [m1]
python-version: ["3.11.8"]
steps:
- name: Clone Repository (Master)
uses: actions/checkout@v4
if: github.event.inputs.git-ref == ''
- name: Clone Repository (Custom Ref)
uses: actions/checkout@v4
if: github.event.inputs.git-ref != ''
with:
ref: ${{ github.event.inputs.git-ref }}
- name: Set up Python3 with installer from python.org
run: |
macpython_py_prefix=/Library/Frameworks/Python.framework/Versions
macpython_url=https://www.python.org/ftp/python
downloads_dir=/tmp
py_version=${{ matrix.python-version }}
py_inst=$py_version.pkg
inst_path=$downloads_dir/$py_inst
retval=""
# exit early on curl errors, but don't let it exit the shell
# https://www.python.org/ftp/python/3.9.13/python-3.9.13-macos11.pkg
macpy_download=$macpython_url/$py_version/python-$py_version-macos11.pkg
curl -f $macpy_download > $inst_path || retval=$?
if [ ${retval:-0} -ne 0 ]; then
echo "Python download failed! "
exit $retval
fi
#
sudo installer -pkg $inst_path -target /
py_mm=${py_version%.*}
python=$macpython_py_prefix/$py_mm/bin/python$py_mm
# Install certificates for Python
inst_cmd="/Applications/Python ${py_mm}/Install Certificates.command"
if [ -e "$inst_cmd" ]; then
sh "$inst_cmd"
fi
- name: Install oq-engine in devel mode
env:
BRANCH: ${{ github.event.inputs.git-ref }}
run: |
set -x
export PIP_DEFAULT_TIMEOUT=100
macpython_py_prefix=/Library/Frameworks/Python.framework/Versions
py_version=${{ matrix.python-version }}
py_mm=${py_version%.*}
python=$macpython_py_prefix/$py_mm/bin/python$py_mm
$python -V
$python -m pip install -U pip wheel
#
echo "branch to test: ${BRANCH}"
if [[ "$BRANCH" != "" ]]
then
$python install.py devel --version ${BRANCH}
else
$python install.py devel
fi
source ~/openquake/bin/activate
pip3 install pytest pyshp flake8
oq dbserver upgrade
sleep 5
- name: Run tests for calculators to test installation
if: always()
run: |
source ~/openquake/bin/activate
cd /Users/runner/runner-isolation/actions-runner/_work/oq-engine/oq-engine/
pytest --doctest-modules --disable-warnings --color=yes --durations=10 openquake/calculators
- name: Run tests for hazardlib, sep, commands, engine, hmtk, risklib, commonlib and baselib to test installation
if: always()
run: |
source ~/openquake/bin/activate
cd /Users/runner/runner-isolation/actions-runner/_work/oq-engine/oq-engine/openquake/
pytest --doctest-modules --disable-warnings --color=yes --durations=10 hazardlib sep commands engine hmtk risklib commonlib baselib
- name: Run tests for the engine server in public mode to test installation
if: always()
run: |
source ~/openquake/bin/activate
cd /Users/runner/runner-isolation/actions-runner/_work/oq-engine/oq-engine/
# -v 2 also logs the test names
OQ_APPLICATION_MODE=public ./openquake/server/manage.py test -v 2 tests.test_public_mode
- name: Test WebUI and run https calculation
run: |
set -x
source ~/openquake/bin/activate
mkdir /var/log/oq-engine/
oq dbserver upgrade &
oq --version
#
echo "Add settings for login and logging on webui before to start"
cd /Users/runner/runner-isolation/actions-runner/_work/oq-engine/oq-engine/
cd openquake/server
cat > local_settings.py << EOF
LOCKDOWN = True
#
WEBUI_ACCESS_LOG_DIR = '/var/log/oq-engine'
EOF
echo "DISPLAY content of local_settings"
cat local_settings.py
# START WEBUI
oq webui start 127.0.0.1:8800 -s &
echo "Waiting WEBUI up on port 8800...."
while ! nc -z localhost 8800; do
sleep 5 # wait for 1/10 of the second before check again
done
echo "Test WebUI with curl before to test django"
sleep 1
# Perform migration after setup local_settings
cd /Users/runner/runner-isolation/actions-runner/_work/oq-engine/oq-engine/
oq webui migrate
sleep 1
curl --fail -L -I -X GET http://127.0.0.1:8800/accounts/login/
echo -n "Test Standalone Tools pages"
curl --fail -I -L -X GET http://127.0.0.1:8800/
curl --fail -I -L -X GET http://127.0.0.1:8800/taxtweb
curl --fail -I -L -X GET http://127.0.0.1:8800/taxonomy
curl --fail -I -L -X GET http://127.0.0.1:8800/ipt
echo -n "TEST DJANGO LOGIN "
LOGIN_URL=http://127.0.0.1:8800/accounts/login/
YOUR_USER='username'
YOUR_PASS='password'
COOKIES=cookies.txt
CURL_BIN="curl -s -c $COOKIES -b $COOKIES -e $LOGIN_URL"
echo -n "Django Auth: get csrftoken ..."
$CURL_BIN $LOGIN_URL > /dev/null
DJANGO_TOKEN="csrfmiddlewaretoken=$(grep csrftoken $COOKIES | sed 's/^.*csrftoken\s*//')"
echo " perform login ..."
$CURL_BIN \
-d "$DJANGO_TOKEN&username=$YOUR_USER&password=$YOUR_PASS" \
-X POST $LOGIN_URL > /dev/null
echo "--------------------"
echo "display log of webui"
echo "--------------------"
cat /var/log/oq-engine/webui-access.log
if [ -s /var/log/oq-engine/webui-access.log ]; then
# The file is not-empty.
cat /var/log/oq-engine/webui-access.log
else
## The file is empty.
echo "Something not work as expected"
exit 1
fi
# NB: the demos are tested on linux; there is no reason a demo should
# not run on macos, so we can avoid running them
# - name: Run demos to test installation
# run: |
# set -x
# source ~/openquake/bin/activate
# oq info venv
# oq info cfg
# cd /Users/runner/runner-isolation/actions-runner/_work/oq-engine/oq-engine/demos
# ls -lrt
# # run demos with job_hazard.ini and job_risk.ini
# for demo_dir in $(find . -type d | sort); do
# if [ -f $demo_dir/job_hazard.ini ]; then
# oq engine --run $demo_dir/job_hazard.ini --exports csv,hdf5
# oq engine --run $demo_dir/job_risk.ini --exports csv,hdf5 --hc -1
# fi
# done
# # run the other demos
# for ini in $(find . -name job.ini | sort); do
# oq engine --run $ini --exports csv,hdf5
# done