-
Notifications
You must be signed in to change notification settings - Fork 18
452 lines (412 loc) · 15.6 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
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
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
name: CI
on:
release:
types:
- published
push:
pull_request:
repository_dispatch:
jobs:
some-context-vars:
runs-on: ubuntu-latest
steps:
- name: Get branch or version name from repo (howto)
id: get-bv_name
run: |
if [[ "$GITHUB_REF" == *"refs/tags"* ]]; then
# v4.0.6 -> 4.0.6
echo ::set-output name=branch_or_version::$(echo ${GITHUB_REF#refs/tags/} | sed 's/v//g')
else
# feature/something -> feature-something
echo ::set-output name=branch_or_version::$(echo ${GITHUB_REF#refs/heads/} | sed 's/\//-/g')
fi
- name: Some vars
run: |
echo Echoing:
echo 'github.event.action :' ${{ github.event.action }}
echo 'github.event_name :' ${{ github.event_name }}
echo 'github.repository :' ${{ github.repository }}
echo 'github.sha :' ${{ github.sha }}
echo 'branch or version from GITHUB_REF:' ${{ steps.get-bv_name.outputs.branch_or_version }}
echo 'GITHUB_REF :' ${GITHUB_REF}
echo 'GITHUB_REF#refs/heads/:' ${GITHUB_REF#refs/heads/}
echo 'GITHUB_REF#refs/tags/ :' ${GITHUB_REF#refs/tags/}
on-pull_request-job:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- run: echo 'github.event_name is:' ${{ github.event_name }}
on-push-job:
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- run: echo 'github.event_name is:' ${{ github.event_name }}
on-release-job:
if: github.event_name == 'release' && github.event.action == 'published'
runs-on: ubuntu-latest
steps:
- run: |
echo 'github.event_name is:' ${{ github.event_name }}
echo 'github.event.action is:' ${{ github.event.action }}
on-repository_dispatch-job:
if: github.event_name == 'repository_dispatch'
runs-on: ubuntu-latest
steps:
- run: |
echo 'github.event_name is:' ${{ github.event_name }}
echo 'github.event.action is:' ${{ github.event.action }}
yarn-frontend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Get Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: "12.x"
- run: yarn install
- run: yarn frontend
- run: git status
- name: Assert clean working tree
run: git status | grep -q "nothing to commit, working tree clean"
lint:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.x]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- run: python --version
- run: pip install --upgrade pip
- run: pip install --upgrade flake8
- run: make lint-minimal
build:
runs-on: ubuntu-latest
needs: [yarn-frontend, lint]
steps:
- name: Checkout non-shallow
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Fetch all tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: "3.x"
- run: python --version
- run: pip install --upgrade pip
- run: pip install --upgrade setuptools_scm wheel pytest
- run: echo TODO pytest
- run: python -m setuptools_scm
- name: Maybe set tag 99.88.77
run: |
scm_version=$(python -c "import setuptools_scm as st;print('.'.join(st.get_version().split('.')[:3]))")
validstr=$(echo "$scm_version" | sed -e 's/\(0\|\([1-9][0-9]*\)\)\.\(0\|\([1-9][0-9]*\)\)\.\(0\|\([1-9][0-9]*\)\)/valid/')
echo Found scm_version:${scm_version}: && echo validates to validstr:${validstr}:
if [ ! "$validstr" = "valid" ]; then
newtag=v99.88.77
echo Create tag "$newtag"
git tag | xargs git tag -d
git tag "$newtag"
git tag
else
echo Given version is "$scm_version" and looks ok.
fi
- run: python -m setuptools_scm
- run: python setup.py sdist bdist_wheel
- name: Remove sdist package
run: find dist -name "*.tar.gz" -delete
- name: Archive wheel
uses: actions/upload-artifact@v1
with:
name: bdist-wheel-package
path: dist
make-docs:
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Download wheel
uses: actions/download-artifact@v1
with:
name: bdist-wheel-package
path: packages
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.x
- run: python --version
- run: pip install --upgrade pip
- run: pip install --upgrade sphinx==4.5.0
- name: Install from wheel
run: pip install $(find packages -name "*.whl")
- name: Assert importable, show version
run: |
our_version=$(python -c "import sphinx_typo3_theme; print(sphinx_typo3_theme.__version__)")
echo our version: ${our_version}
- name: Render repo docs
run: |
non_interactive=1 make docs
touch docs/_build/html/.nojekyll
- name: Upload rendered docs
uses: actions/upload-artifact@v1
with:
name: docs-rendered-for-gh-pages
path: docs/_build/html
sphinx-quickstart:
needs: [build]
runs-on: ubuntu-latest
strategy:
matrix:
mode: [
['online', '-A docstypo3org=yes -A version=faked/online '],
['offline', '-A version=faked/offline']]
python-version: [3.x]
steps:
- name: Download wheel
uses: actions/download-artifact@v1
with:
name: bdist-wheel-package
path: packages
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- run: python --version
- run: pip install --upgrade pip
- run: pip install --upgrade sphinx==4.5.0
- name: Install from wheel
run: pip install $(find packages -name "*.whl")
- name: Assert importable, show version
run: |
our_version=$(python -c "import sphinx_typo3_theme; print(sphinx_typo3_theme.__version__)")
echo our version: ${our_version}
- run: pip list
- name: Sphinx quickstart
run: |
html_theme=sphinx_typo3_theme
sphinx-quickstart --project PROJECT --author AUTHOR --sep \
--extensions ${html_theme} --no-use-make-mode --quiet
echo >> source/conf.py
echo 'extensions.append("'${html_theme}'")' >> source/conf.py
echo 'html_theme = "'${html_theme}'"' >> source/conf.py
echo 'source/conf.py'
cat source/conf.py
- name: Sphinx build
run: |
sphinx-build -b html ${{ matrix.mode[1] }} source build
- name: Upload
uses: actions/upload-artifact@v1
with:
name: sphinx-quickstart-${{ matrix.python-version }}-mode-${{ matrix.mode[0] }}
path: build
make-test:
needs: [build]
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.x]
steps:
- uses: actions/checkout@v2
- name: Download wheel
uses: actions/download-artifact@v1
with:
name: bdist-wheel-package
path: packages
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- run: python --version
- run: pip install --upgrade pip
- run: pip install --upgrade pytest twine
- name: Install from wheel
run: pip install $(find packages -name "*.whl")
- name: Assert is importable, show version
run: python -c "import sphinx_typo3_theme; print(sphinx_typo3_theme.__version__)"
- name: Assert is importable and show version_info
run: python -c "import sphinx_typo3_theme; print(sphinx_typo3_theme.version_info)"
- run: python tests/test_python_sphinx_typo3_theme.py
- name: make test TODO Make this work
if: 0
run: make test
- run: twine check packages/*
passed-all-tests:
needs: [make-docs, make-test, sphinx-quickstart]
runs-on: ubuntu-latest
steps:
- run: true
publish-gh-pages:
needs: [passed-all-tests]
if: (github.event_name == 'push' && github.event.ref == 'refs/heads/master')
|| (github.event_name == 'push' && github.repository == 'marble/dummyrepo')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Download rendered docs
uses: actions/download-artifact@v1
with:
name: docs-rendered-for-gh-pages
path: site
- name: Publish
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
GITHUB_TOKEN: ${{ secrets.REPO_ACCESS_GITHUB }}
BRANCH: gh-pages
FOLDER: site
assert-good-release-version:
needs: [passed-all-tests]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- name: Download wheel
uses: actions/download-artifact@v1
with:
name: bdist-wheel-package
path: packages
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: "3.x"
- run: ls -la packages
- run: python --version
- run: pip install --upgrade pip
- name: Install from wheel
run: pip install $(find packages -name "*.whl")
- name: Assert release number is exactly like 1.2.3 or 1.2.dev3
run: |
our_version=$(python -c "import sphinx_typo3_theme; print(sphinx_typo3_theme.__version__)")
validstr=$(echo "$our_version" | sed -e 's/\(0\|\([1-9][0-9]*\)\)\.\(0\|\([1-9][0-9]*\)\)\.\(0\|\([1-9][0-9]*\)\)/valid/')
echo our version:${our_version}: && echo validates to validstr:${validstr}:
if [ "$validstr" != "valid" ]; then
echo Invalid version number. Expecting a legal version like
echo '<major>.<minor>.<patch> or <major>.<minor>.dev<patch> with major >= 1 and no leading zeros'
exit 1
fi
- name: Assert real release number
run: |
if [ "$our_version" = "99.88.77" ]; then
exit 1
fi
upload-to-pypi:
needs: [assert-good-release-version]
if: github.event_name == 'release' && github.event.action == 'published'
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: "3.x"
- run: python --version
- run: pip install --upgrade pip twine
- name: Download wheel
uses: actions/download-artifact@v1
with:
name: bdist-wheel-package
path: packages
- run: find packages
- run: twine check packages/*
- name: Publish on PyPi
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: twine upload packages/*
upload-to-cdn:
needs: [upload-to-pypi]
runs-on: ubuntu-latest
steps:
- name: Download wheel
uses: actions/download-artifact@v1
with:
name: bdist-wheel-package
path: packages
- name: Unpack and find version
id: get-version
run: |
the_wheel=$(find packages -name "*.whl")
echo "the wheel package is: '"${the_wheel}"'"
unzip ${the_wheel}
find .
echo ::set-output name=version1::$(echo ${the_wheel} | sed -e 's/^.*sphinx_typo3_theme-\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\).*/\1/')
echo ::set-output name=version2::$(echo ${the_wheel} | sed -e 's/^.*sphinx_typo3_theme-\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\).*/\1.\2/')
echo ::set-output name=version3::$(echo ${the_wheel} | sed -e 's/^.*sphinx_typo3_theme-\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\).*/\1.\2.\3/')
- name: Show version1, version2, version3
run: |
echo "version1: ${{ steps.get-version.outputs.version1 }}"
echo "version2: ${{ steps.get-version.outputs.version2 }}"
echo "version3: ${{ steps.get-version.outputs.version3 }}"
- name: Remove some files
run: |
find sphinx_typo3_theme/static -name __init__.py -delete
find sphinx_typo3_theme/static -name *_t -delete
- name: Prepare upload folder
run: mkdir -p cdn/theme/sphinx_typo3_theme/
# example: https://typo3.azureedge.net/typo3documentation/theme/sphinx_typo3_theme/4.3.2/css/theme.css
- name: Provide as x.x.x
run: cp -r sphinx_typo3_theme/static cdn/theme/sphinx_typo3_theme/${{ steps.get-version.outputs.version3 }}
# example: https://typo3.azureedge.net/typo3documentation/theme/sphinx_typo3_theme/master/css/theme.css
- name: Provide as <branch>
run: cp -r sphinx_typo3_theme/static cdn/theme/sphinx_typo3_theme/master
- run: find .
- name: Upload to Azure
env:
AZURE_STORAGE_ACCOUNT: ${{ secrets.AZURE_ACCOUNT }}
AZURE_STORAGE_KEY: ${{ secrets.AZURE_KEY }}
run: |
az storage blob upload-batch --source cdn --destination ${{ secrets.AZURE_CONTAINER }}
use-docker-container:
needs: [passed-all-tests]
runs-on: ubuntu-latest
if: 1
strategy:
matrix:
# online, offline
mode: ['online']
manual: [
# ['Writing Documentation', 'TYPO3-Documentation/TYPO3CMS-Guide-HowToDocument'],
['Stress Test Demo', 'typo3-documentation/sphinx_typo3_theme_rendering_test']]
steps:
- uses: actions/checkout@v2
with:
repository: ${{ matrix.manual[1] }}
- name: Download wheel
uses: actions/download-artifact@v1
with:
name: bdist-wheel-package
path: WHEELS
- run: |
mkdir -p Documentation-GENERATED-temp
if [[ "${{ matrix.mode }}" = "offline" ]]; then
echo '{"Overrides_cfg":{"html_theme_options":{"docstypo3org":""}}}' > Documentation-GENERATED-temp/jobfile.json
fi
if [[ "${{ matrix.mode }}" = "online" ]]; then
echo '{"Overrides_cfg":{"html_theme_options":{"docstypo3org":"nonempty"}}}' > Documentation-GENERATED-temp/jobfile.json
fi
- name: list WHEELS
run: |
echo github.workspace is ${{ github.workspace }}
echo GITHUB_WORKSPACE in env is ${GITHUB_WORKSPACE}
echo files in ${{ github.workspace }}/WHEELS
ls -la ${{ github.workspace }}/WHEELS
- name: docker run
run: |
docker run --rm --user=$(id -u):$(id -g) \
-v $(pwd):/PROJECT:ro \
-v $(pwd)/Documentation-GENERATED-temp:/RESULT \
-v ${{ github.workspace }}/WHEELS:/WHEELS \
ghcr.io/t3docs/render-documentation:latest makehtml \
-c make_singlehtml 1 \
-c jobfile /RESULT/jobfile.json
- name: Verify rendering result
run: stat Documentation-GENERATED-temp/Result/project/0.0.0/index.html || stat Documentation-GENERATED-temp/Result/project/0.0.0/Index.html
- name: Upload
uses: actions/upload-artifact@v1
with:
name: ${{ matrix.manual[0] }} (TYPO3 rendering example, mode ${{ matrix.mode }})
path: ./Documentation-GENERATED-temp/Result/project/0.0.0