-
Notifications
You must be signed in to change notification settings - Fork 280
376 lines (339 loc) · 16.1 KB
/
docs23.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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
# manuals -> master latest e LTS
# dev/<branch>/arch
#
# link a pdf e constraint coi test ok
# Tree Structure
# --------------
#
# .oq-engine-new
# <x.y>|master
# PDF
# <pdf_docs>
# reference
# manual
# advanced
# latest -> <latest x.y>
# LTS -> <LTS x.y>
# reference
# latest -> ../latest/reference
# LTS -> ../LTS/reference
# master -> ../master/reference
# manual
# latest -> ../latest/manual
# LTS -> ../LTS/manual
# master -> ../master/manual
# advanced
# latest -> ../latest/advanced
# LTS -> ../LTS/advanced
# master -> ../master/advanced
# manuals
# OpenQuake Manual <x.y>.pdf -> ../oq-engine-new/<x.y>/PDF/OpenQuake Manual <x.y>.pdf
# OpenQuake Manual latest.pdf -> OpenQuake Manual <latest_(x.y)>.pdf
# OpenQuake Manual LTS.pdf -> OpenQuake Manual <LTS_(x.y)>.pdf
#
# .dev
# oq-engine-new
# <branch>
# PDF
# <pdf_docs>
# reference
# manual
# advanced
# manuals
# OpenQuake Manual <branch>.pdf -> ../oq-engine-new/<branch>/PDF/OpenQuake Manual <branch>.pdf
#
---
name: Docs23
on:
workflow_dispatch:
inputs:
oq-release:
description: 'OQ Release'
required: true
default: 'dev'
type: choice
options:
- dev
- master
# - release
# - LTS
push:
branches: [master, 'engine-*', moster, 'ongine-*']
pull_request:
jobs:
docs:
runs-on: ubuntu-latest
env:
EV_NAME: ${{ github.event_name }}
# during devel was DOCS_BASE: ".oq-engine-docs-refact/"
DOCS_BASE: ""
GITHUB_REF: ${{ github.ref }}
GITHUB_HD_REF: ${{ github.head_ref }}
GITHUB_BS_REF: ${{ github.base_ref }}
steps:
- name: run if workflow_dispatch
if: github.event_name == 'workflow_dispatch'
shell: bash
run: echo "Action triggered by 'workflow_dispatch' ($EV_NAME)"
- name: run if push
if: github.event_name == 'push'
shell: bash
run: echo "Action triggered by 'push' ($EV_NAME)"
- name: identify github reference
run: |
echo "DOCS_BASE: [$DOCS_BASE]"
echo "REF: $GITHUB_REF"
echo "REF_NAME: $GITHUB_REF_NAME"
echo "HD_REF: $GITHUB_HD_REF"
echo "BS_REF: $GITHUB_BS_REF"
- name: Check out the codebase
uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Upgrade pip and install requirements
run: |
pip install -U pip
pip install -r ./requirements-py38-linux64.txt
pip install -r ./doc23/requirements.txt
# - name: Install oq engine
# run: |
# pip install -e .[dev]
# python3 -c "import openquake.baselib as m; print(m.__version__.rpartition('.')[0])"
- name: Make docs and rsync to docs.openquake.org
shell: bash
env:
# Used
BUILD: ${{ github.event.inputs.oq-release }}
DOCS_SSH: ${{ secrets.DOCS_ARTIFACTS }}
# GITHUB_PULL_REQUEST: ${{ github.event.number }}
GITHUB_DEF_BR: ${{ github.event.repository.default_branch }}
GITHUB_REF: ${{ github.ref }}
GITHUB_HD_REF: ${{ github.head_ref }}
GITHUB_BS_REF: ${{ github.base_ref }}
UPLOAD: ${{ github.event.inputs.git-ref }}
# JUST TO TEST MULTI_DOCS
MULTI_DOCS_FOR_DEVEL: "true"
run: |
bash --version
# LTS_VER=$(grep '^Current LTS' README.md | sed 's/.*OpenQuake Engine //g;s/\*\*.*//g')
LTS_VER="TODO"
# ENG_VER=$(python3 -c "import openquake.baselib as m; print(m.__version__.rpartition('.')[0])")
ENG_VER="TODO"
if [ -z "$BUILD" ]; then
if [[ "$GITHUB_REF_NAME" == "master" || "$GITHUB_REF_NAME" == "moster" ]]; then
BUILD=master
elif [[ "$GITHUB_REF_NAME" =~ ^engine- || "$GITHUB_REF_NAME" =~ ^ongine- ]]; then
BRANCH_VER="${GITHUB_REF_NAME#engine-}"
if [ "$BRANCH_VER" == "$GITHUB_REF_NAME" ]; then
BRANCH_VER="${GITHUB_REF_NAME#ongine-}"
fi
# TEST: ENABLE IF NEEDED
# ENG_VER=$BRANCH_VER
if [ "$BRANCH_VER" != "$ENG_VER" ]; then
echo "Versions don't match (BRANCH_VER: [$BRANCH_VER] ENG_VER: [$ENG_VER])"
exit 2
fi
if [[ "$BRANCH_VER" == "$LTS_VER" ]]; then
BUILD=LTS
else
BUILD=release
fi
else
BUILD=dev
fi
fi
# REL_VERS="$(git ls-remote --heads | grep -v '^From' | grep '/engine-' | sed 's/^.*ngine-//g' | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n)"
REL_VERS="TODO"
LATEST_VER="$(echo "$REL_VERS" | tail -n 1)"
# ALL_VERS="$((git ls-remote --heads | grep -v '^From' | grep '/engine-' | sed 's/^.*ngine-//g' ; echo "$ENG_VER") | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n | uniq)"
ALL_VERS="TODO"
PDFDOCS="manuals/"
TARGET_LINK=""
PDF_VER_LINK=""
if [ "$BUILD" == "release" -o "$BUILD" == "LTS" ]; then
TARGET="oq-engine-new/$ENG_VER/"
# TARGET_LINK="${DOCS_BASE}oq-engine-new/$BUILD"
PDF_VER="${ENG_VER}"
if [ "$BUILD" == "release" ]; then
if [ "$ENG_VER" == "$LATEST_VER" ]; then
PDF_VER_LINK="latest"
fi
elif [ "$BUILD" == "LTS" ]; then
PDF_VER_LINK="LTS"
fi
elif [ "$BUILD" == "master" ]; then
TARGET="oq-engine-new/master/"
PDF_VER="(master)"
elif [ "$BUILD" == "dev" ]; then
DOCS_BASE="${DOCS_BASE}.dev/"
if echo "$GITHUB_REF_NAME" | grep -q '[0-9]\+/merge'; then
TARGET="oq-engine-new/$GITHUB_HD_REF/"
PDF_VER="($GITHUB_HD_REF)"
else
TARGET="oq-engine-new/$GITHUB_REF_NAME/"
PDF_VER="($GITHUB_REF_NAME)"
fi
PDFDOCS="manuals/"
else
echo "BUILD [$BUILD] not recognized"
exit 3
fi
PDFDEST=${PDFDOCS}
# TEST PER PDF_VER_LINK
# PDF_VER_LINK=test_ver_link
echo "LATEST_VER: [$LATEST_VER]"
echo "BUILD: [$BUILD]"
echo "LTS_VER: [$LTS_VER]"
echo "ENG_VER: [$ENG_VER]"
echo "TARGET: [$TARGET]"
echo "TARGET_LINK: [$TARGET_LINK]"
echo "PDF_VER: [$PDF_VER]"
echo "PDF_VER_LINK: [$PDF_VER_LINK]"
echo "PDFDOCS [$PDFDOCS]"
echo "PDFDEST [$PDFDEST]"
echo "----"
echo "GITHUB_PULL_REQUEST: [$GITHUB_PULL_REQUEST]"
echo "GITHUB_DEF_BR: [$GITHUB_DEF_BR]"
echo "GITHUB_REF: [$GITHUB_REF]"
echo "GITHUB_HD_REF: [$GITHUB_HD_REF]"
echo "GITHUB_BS_REF: [$GITHUB_BS_REF]"
echo "UPLOAD: [$UPLOAD]"
# multi-version doc switcher could be runned just from main because
# is the only one known the master version (from sources)
# set -x
# if [ "$MULTI_DOCS_FOR_DEVEL" == "true" -o "$BUILD" == "master" ]; then
# ddown_adv="["
# ddown_man="["
# for v in $ALL_VERS; do
# ver_maj="$(echo "$v" | sed 's/\([0-9]\+\)\..*/\1/g')"
# ver_min="$(echo "$v" | sed 's/[0-9]\+\.\(.*\)$/\1/g')"
# pfx=""
# sfx=""
# if [ "$v" = "$ENG_VER" ]; then
# pfx="development"
# main_rename="true"
# else
# main_rename="false"
# fi
# # if [ "$v" = "$LATEST_VER" ]; then
# # if [ "$sfx" ]; then
# # sfx="${sfx}, latest"
# # else
# # sfx="latest"
# # fi
# # fi
# if [ "$v" = "$LTS_VER" ]; then
# if [ "$sfx" ]; then
# sfx="${sfx}, LTS"
# else
# sfx="LTS"
# fi
# fi
# if [ "$sfx" ]; then
# sfx=" (${sfx})"
# fi
# # policies for the user manual version switcher menu
# if ( (( "$ver_maj" == 3 )) && (( "$ver_min" >= 16 )) ) || (( "$ver_maj" > 3 )); then
# if [ "$main_rename" == "true" ]; then
# ver_name="${pfx}"
# ver_val="master"
# else
# ver_name="${ver_maj}.${ver_min}${sfx}"
# ver_val="${ver_maj}.${ver_min}"
# fi
# ver_url="https://docs.openquake.org/${DOCS_BASE}oq-engine-new/${ver_val}/manual/"
# if [ "$ddown_man" != "[" ]; then
# ddown_man="${ddown_man}, "
# fi
# ddown_man="${ddown_man}{ \"name\": \"${ver_name}\", \"version\": \"$ver_val\", \"url\": \"${ver_url}\" }"
# fi
# # policies for the advanced manual version switcher menu
# if ( (( "$ver_maj" == 3 )) && (( "$ver_min" >= 16 )) ) || (( "$ver_maj" > 3 )); then
# if [ "$main_rename" == "true" ]; then
# ver_name="${pfx}"
# ver_val="master"
# else
# ver_name="${ver_maj}.${ver_min}${sfx}"
# ver_val="${ver_maj}.${ver_min}"
# fi
# ver_url="https://docs.openquake.org/${DOCS_BASE}oq-engine-new/${ver_val}/advanced/"
# if [ "$ddown_adv" != "[" ]; then
# ddown_adv="${ddown_adv}, "
# fi
# ddown_adv="${ddown_adv}{ \"name\": \"${ver_name}\", \"version\": \"$ver_val\", \"url\": \"${ver_url}\" }"
# fi
# done
# ddown_man="${ddown_man}]"
# echo "$ddown_man" > dot_ddown_man.json
# ddown_adv="${ddown_adv}]"
# echo "$ddown_adv" > dot_ddown_adv.json
# fi
set -x
if [ "$DOCS_SSH" ]; then
gpg --version
gpg --quiet --batch --yes --decrypt --passphrase="$DOCS_SSH" --output ./.deploy_rsa ./.deploy_docs.enc
chmod 600 ./.deploy_rsa
eval $(ssh-agent -s) && ssh-add ./.deploy_rsa
else
echo "DOCS_SSH env variable not found, skip deploy"
fi
# if [ -f "dot_ddown_man.json" ]; then
# rsync -s -e 'ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' --rsync-path="mkdir -p \"${DOCS_BASE}oq-engine-new\" && rsync" dot_ddown_man.json "[email protected]:${DOCS_BASE}oq-engine-new/.ddown_man.json"
# fi
# if [ -f "dot_ddown_adv.json" ]; then
# rsync -s -e 'ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' --rsync-path="mkdir -p \"${DOCS_BASE}oq-engine-new\" && rsync" dot_ddown_adv.json "[email protected]:${DOCS_BASE}oq-engine-new/.ddown_adv.json"
# fi
# sudo apt update; sudo apt-get install -y texlive-fonts-recommended texlive-latex-extra latexmk gpg
echo "Make OpenQuake Manual (HTML and PDF)"
# PAY ATTENTION: engine folder is 'doc', not 'docs'
# cd doc23/manual && make html && make latexpdf
cd doc23 && make html 2>&1 | tee full.log
grep WARNING < full.log > warnings.log
echo
echo "=== WARNINGS ==="
echo
cat warnings.log
echo
echo
echo "=== WARNINGS SUMMARY ==="
cat warnings.log | sed 's/.*WARNING/WARNING/g' | sed "s/WARNING: 'myst' cross-reference target not found.*/WARNING: 'myst' cross-reference target not found/g" | sed 's/WARNING: undefined label.*/WARNING: undefined label/g' | sed 's/WARNING: duplicate label.*/WARNING: duplicate label/g' | sed 's/WARNING: Duplicate explicit target name.*/WARNING: Duplicate explicit target name/g' | sort | uniq -c
# echo "Uploading OpenQuake Manual (PDF)"
# rsync -s -e 'ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' -ax --rsync-path="mkdir -p \"${DOCS_BASE}${TARGET}PDF\" && rsync" build/latex/OpenQuakeEngineManual.pdf "[email protected]:${DOCS_BASE}${TARGET}PDF/OpenQuake Manual ${PDF_VER}.pdf"
# ssh -v -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null [email protected] "bash -cx 'cd \"${DOCS_BASE}${PDFDOCS}\"; ln -sf \"../${TARGET}PDF/OpenQuake Manual ${PDF_VER}.pdf\" .'"
# if [ "$PDF_VER_LINK" ]; then
# echo "Found PDF_VER_LINK set [$PDF_VER_LINK]"
# ssh -v -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null [email protected] "bash -cx 'cd \"${DOCS_BASE}manuals/\"; ln -sf \"OpenQuake Manual ${PDF_VER}.pdf\" \"OpenQuake Manual (${PDF_VER_LINK}).pdf\"'"
# fi
if [ "$DOCS_SSH" ]; then
echo "Uploading New OpenQuake Documentation (HTML)"
rsync -s -e 'ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' -ax --rsync-path="mkdir -p \"${DOCS_BASE}${TARGET}manual/\" && rsync" -s -e 'ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' -ax --delete _build/html/ "[email protected]:/var/www/docs.openquake.org/${DOCS_BASE}${TARGET}manual/"
echo "------"
else
echo "SKIP Uploading New OpenQuake Documentation (HTML)"
fi
# echo "Make Reference Manual (HTML)"
# cd ../sphinx && make html
# echo "Upload Reference Manual (HTML)"
# rsync -s -e 'ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' -ax --delete build/html/ "[email protected]:${DOCS_BASE}${TARGET}reference/"
# echo "------"
# echo "Make Advanced Manual (PDF)"
# cd ../adv-manual
# sed -i "s@#PDF_VER#@${PDF_VER}@g;s@#TARGET#@${DOCS_BASE}${TARGET}@g" index.rst
# make clean && make latexpdf
# echo "Upload OpenQuakeforAdvancedUsers (PDF)"
# rsync -e 'ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' -ax --delete build/latex/OpenQuakeforAdvancedUsers.pdf "[email protected]:${DOCS_BASE}${TARGET}PDF/"
# ssh -v -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null [email protected] "bash -cx 'cd \"${DOCS_BASE}${PDFDOCS}\"; ln -sf \"../${TARGET}PDF/OpenQuakeforAdvancedUsers.pdf\" \"OpenQuake for Advanced Users ${PDF_VER}.pdf\"'"
# echo "Make Advanced Manual (HTML)"
# cd ../adv-manual && make clean && make html
# echo "Upload OpenQuakeforAdvancedUsers (HTML)"
# rsync -e 'ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' -ax --delete build/html/ "[email protected]:${DOCS_BASE}${TARGET}advanced/"
# if [ "$BUILD" == "LTS" ]; then
# ssh -v -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null [email protected] "bash -cx 'cd \"${DOCS_BASE}oq-engine-new/\"; ln -snf \"$ENG_VER\" LTS'"
# fi
# if [ "$BUILD" == "release" -o "$BUILD" == "LTS" ]; then
# if [ "$LATEST_VER" == "$ENG_VER" ]; then
# ssh -v -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null [email protected] "bash -cx 'cd \"${DOCS_BASE}oq-engine-new/\"; ln -snf \"$ENG_VER\" latest'"
# fi
# fi