forked from Kubeinit/kubeinit
-
Notifications
You must be signed in to change notification settings - Fork 0
292 lines (248 loc) · 14.8 KB
/
docs_build.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
---
name: docs_build
on:
push:
branches:
- main
pull_request:
branches:
- main
# This will help to identify faster if
# there is a CI failure related to a
# change in any dependency.
schedule:
- cron: '0 */8 * * *'
jobs:
build:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.9]
steps:
- name: Use checkout v2 with all git log available
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install required packages
run: |
sudo apt-get update -y
sudo apt-get install -y \
librsvg2-bin \
ghostscript \
libfreetype6-dev \
gsfonts \
libmagickwand-dev \
imagemagick \
graphviz \
plantuml \
openjdk-11-jdk
sudo apt-get remove ansible -y
sudo python3 -m pip uninstall ansible ansible-base ansible-core -y
sudo python3 -m pip install -r test-requirements.txt
sudo python3 -m pip install --upgrade pip
sudo python3 -m pip install --upgrade virtualenv
sudo python3 -m pip install --upgrade setuptools
sudo python3 -m pip install --upgrade ansible-inventory-grapher
sudo python3 -m pip install 'ansible-playbook-grapher==1.1.2'
sudo python3 -m pip install --upgrade shyaml
sudo python3 -m pip install --upgrade diagrams
sudo python3 -m pip install --upgrade ruamel.yaml
sudo python3 -m pip install --upgrade sphinx
sudo python3 -m pip install --upgrade sphinx-rtd-theme
sudo python3 -m pip install --upgrade yq
- name: Install kubeinit's collection
run: |
cd kubeinit
rm -rf ~/.ansible/collections/ansible_collections/kubeinit/kubeinit
ansible-galaxy collection build -v --force --output-path releases/
ansible-galaxy collection install --force --force-with-deps releases/kubeinit-kubeinit-`cat galaxy.yml | shyaml get-value version`.tar.gz
cd ..
- name: Render the plantuml, mingrammer and SVG diagrams
run: |
echo "Rendering the planUML diagrams"
plantuml -tpng -output render ./docs/src/images/plantuml/*.plantuml
echo " "
echo "Creating the planUML static folder"
mkdir -p ./docs/src/static/plantuml
echo " "
echo "Moving the planUML diagrams to the docs folder"
mv ./docs/src/images/plantuml/render/* ./docs/src/static/plantuml/
echo " "
echo "Rendering the mingrammer diagrams"
cd ./docs/src/images/mingrammer/
for diagram in *.py; do python3 "$diagram"; done
cd ../../../../
echo " "
echo "Creating the mingrammer static folder"
mkdir -p ./docs/src/static/mingrammer
echo " "
echo "Moving the mingrammer diagrams to the docs folder"
mv ./docs/src/images/mingrammer/*.png ./docs/src/static/mingrammer/
echo " "
echo "Rendering the SVG diagrams"
cd ./docs/src/images/svg/
# mogrify -format png *.svg
for diagram in *.svg; do
echo "Rendering $diagram"
dest=`echo "$diagram" | cut -d'.' -f1`
# convert "$diagram" "$dest.png"
rsvg-convert "$diagram" > "$dest.png"
done
cd ../../../../
echo " "
echo "Creating the SVG static folder"
mkdir -p ./docs/src/static/svg
echo " "
echo "Moving the SVG diagrams to the docs folder"
mv ./docs/src/images/svg/*.png ./docs/src/static/svg/
- name: Render the projects roles and inventory diagrams
run: |
set -x
tasktag=task_gather_facts
taskname=$(echo ${tasktag} | tr '_' '-')
ansible-playbook-grapher -t ${tasktag} --skip-tags omit_from_grapher -e kubeinit_cluster_distro=okd -e kubeinit_cluster_distro_role=kubeinit_openshift kubeinit/playbook.yml --include-role-tasks -o docs/src/static/playbook_${tasktag} --save-dot-file
sed -e ':again;$!N;$!b again; s/subgraph "Play #[23]:[^"]*"{[^}]*}//g' -e 's/"Play #1: [^"]*"/"'${taskname}'"/g' -e 's/shape=box/shape=octagon/g' -e 's/#[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]/#000000/g' -e 's/ style=filled / /' docs/src/static/playbook_${tasktag}.dot | dot -Tsvg > docs/src/static/playbook_${tasktag}.svg
cat << EOF >> docs/src/playbook_diagrams.rst
playbook task ${taskname}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. image:: static/playbook_${tasktag}.svg
:width: 400
:alt: Alternative text
EOF
tasktag=task_prepare_hypervisors
taskname=$(echo ${tasktag} | tr '_' '-')
ansible-playbook-grapher -t ${tasktag} --skip-tags omit_from_grapher -e kubeinit_cluster_distro=okd -e kubeinit_cluster_distro_role=kubeinit_openshift kubeinit/playbook.yml --include-role-tasks -o docs/src/static/playbook_${tasktag} --save-dot-file
sed -e ':again;$!N;$!b again; s/subgraph "Play #[13]:[^"]*"{[^}]*}//g' -e 's/"Play #2: [^"]*"/"'${taskname}'"/g' -e 's/shape=box/shape=octagon/g' -e 's/#[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]/#000000/g' -e 's/ style=filled / /' docs/src/static/playbook_${tasktag}.dot | dot -Tsvg > docs/src/static/playbook_${tasktag}.svg
cat << EOF >> docs/src/playbook_diagrams.rst
playbook task ${taskname}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. image:: static/playbook_${tasktag}.svg
:width: 400
:alt: Alternative text
EOF
for tasktag in task_prepare_environment task_cleanup_hypervisors task_run_validations task_create_network task_create_services; do
taskname=$(echo ${tasktag} | tr '_' '-')
ansible-playbook-grapher -t ${tasktag} --skip-tags omit_from_grapher -e kubeinit_cluster_distro=okd -e kubeinit_cluster_distro_role=kubeinit_openshift kubeinit/playbook.yml --include-role-tasks -o docs/src/static/playbook_${tasktag} --save-dot-file
sed -e ':again;$!N;$!b again; s/subgraph "Play #[12]:[^"]*"{[^}]*}//g' -e 's/"Play #3: [^"]*"/"'${taskname}'"/g' -e 's/shape=box/shape=octagon/g' -e 's/#[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]/#000000/g' -e 's/ style=filled / /' docs/src/static/playbook_${tasktag}.dot | dot -Tsvg > docs/src/static/playbook_${tasktag}.svg
cat << EOF >> docs/src/playbook_diagrams.rst
playbook task ${taskname}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. image:: static/playbook_${tasktag}.svg
:width: 400
:alt: Alternative text
EOF
done
tasktag=task_prepare_cluster
taskname=$(echo ${tasktag} | tr '_' '-')
for distro in k8s; do
ansible-playbook-grapher -t ${tasktag} --skip-tags omit_from_grapher -e kubeinit_cluster_distro=${distro} -e kubeinit_cluster_distro_role=kubeinit_${distro} kubeinit/playbook.yml --include-role-tasks -o docs/src/static/playbook_${distro}_${tasktag} --save-dot-file
sed -e ':again;$!N;$!b again; s/subgraph "Play #[12]:[^"]*"{[^}]*}//g' -e 's/"Play #3: [^"]*"/"'${taskname}'"/g' -e 's/shape=box/shape=octagon/g' -e 's/#[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]/#000000/g' -e 's/ style=filled / /' docs/src/static/playbook_${distro}_${tasktag}.dot | dot -Tsvg > docs/src/static/playbook_${distro}_${tasktag}.svg
cat << EOF >> docs/src/playbook_diagrams.rst
playbook task ${taskname} [${distro}]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. image:: static/playbook_${distro}_${tasktag}.svg
:width: 400
:alt: Alternative text
EOF
done
distro=okd
ansible-playbook-grapher -t ${tasktag} --skip-tags omit_from_grapher -e kubeinit_cluster_distro=${distro} -e kubeinit_cluster_distro_role=kubeinit_openshift kubeinit/playbook.yml --include-role-tasks -o docs/src/static/playbook_${distro}_${tasktag} --save-dot-file
sed -e ':again;$!N;$!b again; s/subgraph "Play #[12]:[^"]*"{[^}]*}//g' -e 's/"Play #3: [^"]*"/"'${taskname}'"/g' -e 's/shape=box/shape=octagon/g' -e 's/#[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]/#000000/g' -e 's/ style=filled / /' docs/src/static/playbook_${distro}_${tasktag}.dot | dot -Tsvg > docs/src/static/playbook_${distro}_${tasktag}.svg
cat << EOF >> docs/src/playbook_diagrams.rst
playbook task ${taskname} [${distro}]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. image:: static/playbook_${distro}_${tasktag}.svg
:width: 400
:alt: Alternative text
EOF
tasktag=task_download_images
taskname=$(echo ${tasktag} | tr '_' '-')
ansible-playbook-grapher -t ${tasktag} --skip-tags omit_from_grapher -e kubeinit_cluster_distro=okd -e kubeinit_cluster_distro_role=kubeinit_openshift kubeinit/playbook.yml --include-role-tasks -o docs/src/static/playbook_${tasktag} --save-dot-file
sed -e ':again;$!N;$!b again; s/subgraph "Play #[12]:[^"]*"{[^}]*}//g' -e 's/"Play #3: [^"]*"/"'${taskname}'"/g' -e 's/shape=box/shape=octagon/g' -e 's/#[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]/#000000/g' -e 's/ style=filled / /' docs/src/static/playbook_${tasktag}.dot | dot -Tsvg > docs/src/static/playbook_${tasktag}.svg
cat << EOF >> docs/src/playbook_diagrams.rst
playbook task ${taskname}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. image:: static/playbook_${tasktag}.svg
:width: 400
:alt: Alternative text
EOF
tasktag=task_deploy_cluster
taskname=$(echo ${tasktag} | tr '_' '-')
for distro in k8s; do
ansible-playbook-grapher -t ${tasktag} --skip-tags omit_from_grapher -e kubeinit_cluster_distro=${distro} -e kubeinit_cluster_distro_role=kubeinit_${distro} kubeinit/playbook.yml --include-role-tasks -o docs/src/static/playbook_${distro}_${tasktag} --save-dot-file
sed -e ':again;$!N;$!b again; s/subgraph "Play #[12]:[^"]*"{[^}]*}//g' -e 's/"Play #3: [^"]*"/"'${taskname}'"/g' -e 's/shape=box/shape=octagon/g' -e 's/#[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]/#000000/g' -e 's/ style=filled / /' docs/src/static/playbook_${distro}_${tasktag}.dot | dot -Tsvg > docs/src/static/playbook_${distro}_${tasktag}.svg
cat << EOF >> docs/src/playbook_diagrams.rst
playbook task ${taskname} [${distro}]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. image:: static/playbook_${distro}_${tasktag}.svg
:width: 400
:alt: Alternative text
EOF
done
distro=okd
ansible-playbook-grapher -t ${tasktag} --skip-tags omit_from_grapher -e kubeinit_cluster_distro=${distro} -e kubeinit_cluster_distro_role=kubeinit_openshift kubeinit/playbook.yml --include-role-tasks -o docs/src/static/playbook_${distro}_${tasktag} --save-dot-file
sed -e ':again;$!N;$!b again; s/subgraph "Play #[12]:[^"]*"{[^}]*}//g' -e 's/"Play #3: [^"]*"/"'${taskname}'"/g' -e 's/shape=box/shape=octagon/g' -e 's/#[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]/#000000/g' -e 's/ style=filled / /' docs/src/static/playbook_${distro}_${tasktag}.dot | dot -Tsvg > docs/src/static/playbook_${distro}_${tasktag}.svg
cat << EOF >> docs/src/playbook_diagrams.rst
playbook task ${taskname} [${distro}]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. image:: static/playbook_${distro}_${tasktag}.svg
:width: 400
:alt: Alternative text
EOF
tasktag=task_post_deployment
taskname=$(echo ${tasktag} | tr '_' '-')
ansible-playbook-grapher -t ${tasktag} --skip-tags omit_from_grapher -e kubeinit_cluster_distro=okd -e kubeinit_cluster_distro_role=kubeinit_openshift kubeinit/playbook.yml --include-role-tasks -o docs/src/static/playbook_${tasktag} --save-dot-file
sed -e ':again;$!N;$!b again; s/subgraph "Play #[12]:[^"]*"{[^}]*}//g' -e 's/"Play #3: [^"]*"/"'${taskname}'"/g' -e 's/shape=box/shape=octagon/g' -e 's/#[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]/#000000/g' -e 's/ style=filled / /' docs/src/static/playbook_${tasktag}.dot | dot -Tsvg > docs/src/static/playbook_${tasktag}.svg
cat << EOF >> docs/src/playbook_diagrams.rst
playbook task ${taskname}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. image:: static/playbook_${tasktag}.svg
:width: 400
:alt: Alternative text
EOF
sed -e '/^hypervisor-04/d' \
-e '/^\[controller_nodes\]$/ acontroller-01 target=hypervisor-01\ncontroller-02 target=hypervisor-02\ncontroller-03 target=hypervisor-03' \
-e '/^\[compute_nodes\]$/ acompute-01 target=hypervisor-01\ncompute-02 target=hypervisor-02' \
-e '/^service /s/ / target=hypervisor-01 /' \
-e '/^bootstrap /s/$/ target=hypervisor-03/' kubeinit/inventory.yml > docs/src/static/inventory
ansible-inventory-grapher -i docs/src/static/inventory all -a 'rankdir=LR;' --visible-vars=ansible_host --visible-vars=target -t docs/src/static/inventory.j2 | dot -Tpng > docs/src/static/inventory.png
cat << EOF >> docs/src/inventory_diagrams.rst
inventory example for okd-libvirt-3-2-3
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. image:: static/inventory.png
:width: 400
:alt: Alternative text
EOF
cat ./docs/src/playbook_diagrams.rst
cat ./docs/src/inventory_diagrams.rst
- name: Render the changelog file
run: |
GITCHANGELOG_CONFIG_FILENAME=./ci/gitchangelog.rc ./ci/gitchangelog.py > ./docs/src/changelog.rst
cat ./docs/src/changelog.rst
- name: Render the docs
run: |
cd ./docs/src
make html
- uses: actions/upload-artifact@v1
with:
name: DocumentationHTML
path: docs/src/_build/html/
if-no-files-found: error
- name: Commit documentation changes
run: |
git clone https://github.com/kubeinit/kubeinit.git --branch gh-pages --single-branch gh-pages
cp -r docs/src/_build/html/* gh-pages/
cd gh-pages
git config --local user.email "[email protected]"
git config --local user.name "KubeInit's bot"
git add .
git commit -m "Update documentation" -a || true
- name: Push changes
if: github.event_name == 'push'
uses: kubeinit/github-push-action@master
with:
force: true
branch: gh-pages
directory: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}