-
Notifications
You must be signed in to change notification settings - Fork 38
388 lines (386 loc) · 17.2 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
name: build
on:
push:
paths-ignore:
- 'README.md'
pull_request:
paths-ignore:
- 'README.md'
schedule:
- cron: '0 6 * * *'
jobs:
check_source:
if: github.event_name != 'schedule'
runs-on: ubuntu-latest
outputs:
python-changed: ${{ steps.changed.outputs.python }}
gui-changed: ${{ steps.changed.outputs.gui }}
language-changed: ${{ steps.changed.outputs.language }}
translation-changed: ${{ steps.po.outputs.po_changed }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Check code changes
uses: dorny/paths-filter@v3
id: changed
with:
filters: |
python:
- '*.py'
- 'src/*.py'
- 'test/*.py'
gui:
- 'src/compat.py'
- 'src/YouTubeUi.py'
- 'src/YouTubeDownload.py'
- 'src/YouTubeSearch.py'
- 'src/YouTubeApi.py'
- 'src/YouTubeVideoUrl.py'
- 'src/OAuth.py'
language:
- 'po/*.po'
translation:
- 'src/plugin.py'
- 'src/YouTubeUi.py'
- 'src/YouTubeDownload.py'
- 'src/YouTubeSearch.py'
- name: Install dependencies
if: steps.changed.outputs.translation == 'true'
run: |
sudo apt install gettext
- name: Check translation phrase changes
if: steps.changed.outputs.translation == 'true'
id: po
run: |
xgettext --no-wrap --no-location --omit-header -L Python --from-code=UTF-8 -kpgettext:1c,2 --add-comments="TRANSLATORS:" -d YouTube -s -o ./po/YouTube.pot `find ./src -type f -name '*.py'`
if git status -s | grep 'M'; then
echo "po_changed=true" >> $GITHUB_OUTPUT
fi
test-python:
needs: check_source
if: needs.check_source.outputs.python-changed == 'true' || contains(github.event.head_commit.message,'force-test')
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['2.7', '3.12']
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3
if: matrix.python-version != '2.7'
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Upgrade Python 3 pip
if: matrix.python-version != '2.7'
run: |
python -m pip install --upgrade pip
- name: Set up Python 2
if: matrix.python-version == '2.7'
run: |
sudo apt install -y python2
sudo ln -sf /usr/bin/python2 /usr/bin/python
curl -L -O "https://bootstrap.pypa.io/pip/2.7/get-pip.py"
python get-pip.py
- name: Install dependencies
run: |
pip install flake8 pytest pytest-cov
- name: Compile sources
run: |
python -O -m compileall ./src/
- name: Check code with flake8
run: |
flake8 --ignore=W191,W504,E126,E127,E128,E501 --show-source --exclude=./src/compat.py,./src/jsinterp.py,./test/enigmahelper.py,./test/try_plugin.py,./src/__init__.py
flake8 --ignore=W191,E501 --show-source --filename=./src/jsinterp.py,./test/enigmahelper.py,./test/try_plugin.py,./src/__init__.py
flake8 --ignore=W191,F401,F821 --show-source --filename=./src/compat.py
- name: Remove enigma2 imports and variables for test
run: |
echo "" > src/__init__.py
sed -i 's/from Components/# from Components/g' src/YouTubeVideoUrl.py
sed -i 's/config.plugins.YouTube.maxResolution.value/"22"/g' src/YouTubeVideoUrl.py
sed -i 's/config.plugins.YouTube.useDashMP4.value/video_id != "bWgPKTOMoSY"/g' src/YouTubeVideoUrl.py
sed -i 's/config.plugins.YouTube.searchLanguage.value/"en"/g' src/YouTubeVideoUrl.py
sed -i 's/ != video_id/ != video_id or video_id in ("bWgPKTOMoSY", "9UMxZofMNbA")/g' src/YouTubeVideoUrl.py
- name: Test code with pytest
run: |
YOUTUBE_PLUGIN_TOKEN=${{ secrets.YOUTUBE_PLUGIN_TOKEN }} pytest -rx -v --cov=src --cov-report=xml --cov-report=html
mv .coverage .coverage_${{ matrix.python-version }}
- name: Upload code coverage results
uses: actions/upload-artifact@v4
with:
name: coverage_${{ matrix.python-version }}
include-hidden-files: true
path: .coverage_${{ matrix.python-version }}
test-gui:
needs: test-python
if: always() && (github.event_name == 'schedule' && github.ref == 'refs/heads/master') || ((needs.check_source.outputs.gui-changed == 'true' || contains(github.event.head_commit.message,'force-test')) && (needs.test-python.result == 'success' || needs.test-python.result == 'skipped'))
runs-on: ubuntu-latest
strategy:
matrix:
enigma2-version: ['OpenPLi develop 3.10', 'OpenPLi release-9.0 3.10', 'OpenPLi release-8.3 2.7', 'OpenPLi release-6.2 2.7', 'openatv master 3.12', 'openatv 6.4 2.7', 'OpenViX Developer 3.12', 'Taapat bh 2.7']
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set enigma2 repository
uses: jungwinter/split@v2
id: split
with:
msg: ${{ matrix.enigma2-version }}
- name: Checkout ${{ steps.split.outputs._0 }} ${{ steps.split.outputs._1 }} repository
uses: actions/checkout@v4
with:
repository: '${{ steps.split.outputs._0 }}/enigma2'
ref: ${{ steps.split.outputs._1 }}
path: './enigma2'
fetch-depth: 0
- name: Set up Python 3
if: steps.split.outputs._2 != '2.7'
uses: actions/setup-python@v5
with:
python-version: ${{ steps.split.outputs._2 }}
- name: Upgrade Python 3 pip
if: steps.split.outputs._2 != '2.7'
run: |
python -m pip install --upgrade pip
- name: Set up Python 2
if: steps.split.outputs._2 == '2.7'
run: |
sudo apt install -y python2
sudo ln -sf /usr/bin/python2 /usr/bin/python
curl -L -O "https://bootstrap.pypa.io/pip/2.7/get-pip.py"
python get-pip.py
- name: Install dependencies
run: |
[ '${{ steps.split.outputs._2 }}' == '3.12' ] && tw_ver="" || tw_ver="==20.3.0"
pip install twisted${tw_ver} pyopenssl service_identity
- name: Install additional dependencies
if: matrix.enigma2-version == 'openatv master 3.12' || matrix.enigma2-version == 'OpenViX Developer 3.12'
run: |
pip install requests chardet six
- name: Link plugin files for test
working-directory: './enigma2/lib/python/Plugins/Extensions'
run: |
ln -s ../../../../../src YouTube
- name: Patch enigma step 1
if: matrix.enigma2-version != 'OpenPLi release-6.2 2.7' && matrix.enigma2-version != 'openatv 6.4 2.7' && matrix.enigma2-version != 'Taapat bh 2.7'
run: |
sed -i 's/, domStyle, /, domStyle.getroot(), /g' enigma2/lib/python/skin.py
- name: Patch enigma step 2
if: steps.split.outputs._0 == 'openatv' || steps.split.outputs._0 == 'OpenViX'
run: |
cp test/RcModel.py enigma2/lib/python/Components
cp test/skin_display.xml ./
sed -i 's/\/home/./g' enigma2/lib/python/Components/UsageConfig.py
sed -i 's/config.crash.pystackonspinner.addNotifier/# config.crash.pystackonspinner.addNotifier/g' enigma2/lib/python/Components/UsageConfig.py
echo "model=duo4k" > enigma2/enigma.info
echo "architecture=arm" >> enigma2/enigma.info
echo "socfamily=brcmstb" >> enigma2/enigma.info
echo "brand=vu" >> enigma2/enigma.info
echo "displaytype=lcd" >> enigma2/enigma.info
echo "mtdrootfs=hdd" >> enigma2/enigma.info
echo "displaymodel=vu" >> enigma2/enigma.info
echo "machinebuild=vu" >> enigma2/enigma.info
echo "imagetype=developer" >> enigma2/enigma.info
echo "hdmifhdin=no" >> enigma2/enigma.info
echo "avjack=no" >> enigma2/enigma.info
echo "rca=no" >> enigma2/enigma.info
echo "scart=no" >> enigma2/enigma.info
echo "scartyuv=no" >> enigma2/enigma.info
echo "yuv=no" >> enigma2/enigma.info
- name: Patch enigma step 3
if: steps.split.outputs._0 == 'OpenViX'
run: |
cp test/skin_display.xml enigma2/data/skin_user.xml
sed -i 's/\/root/./g' enigma2/lib/python/Components/UsageConfig.py
sed -i 's/\/usr/./g' enigma2/lib/python/Components/UsageConfig.py
sed -i 's/addNotifier(iAVSwitch/addNotifier(iAVSwitch.setPolicy169) #/g' enigma2/lib/python/Components/AVSwitch.py
sed -i 's/instance, eListbox/instance, type(eListbox)/g' enigma2/lib/python/Components/GUIComponent.py
- name: Patch enigma step 4
if: matrix.enigma2-version == 'OpenPLi develop 3.10' || matrix.enigma2-version == 'OpenPLi release-9.0 3.10' || matrix.enigma2-version == 'OpenViX Developer 3.12'
working-directory: './enigma2/data'
run: |
python convert-iso-639-3.py
- name: ========== Test plugin screens load ==========
if: github.event_name == 'schedule'
run: |
YOUTUBE_PLUGIN_TOKEN=${{ secrets.YOUTUBE_PLUGIN_TOKEN }} E2_VERSION=${{ steps.split.outputs._0 }} PYTHONPATH=./test:./enigma2:./enigma2/lib/python python ./test/try_plugin.py
- name: Install coverage dependencies
if: github.event_name != 'schedule'
run: |
pip install pytest pytest-cov
- name: ========== Coverage code ==========
if: github.event_name != 'schedule'
run: |
YOUTUBE_PLUGIN_TOKEN=${{ secrets.YOUTUBE_PLUGIN_TOKEN }} E2_VERSION=${{ steps.split.outputs._0 }} PYTHONPATH=./test:./enigma2:./enigma2/lib/python python -m pytest -rx -v --cov=src --cov-report=xml --cov-report=html test/try_plugin.py -s
mv .coverage .coverage_${{ steps.split.outputs._0 }}_${{ steps.split.outputs._1 }}
- name: Upload code coverage results
if: github.event_name != 'schedule'
uses: actions/upload-artifact@v4
with:
name: coverage_${{ steps.split.outputs._0 }}_${{ steps.split.outputs._1 }}
include-hidden-files: true
path: .coverage_${{ steps.split.outputs._0 }}_${{ steps.split.outputs._1 }}
sonarcloud:
needs: [test-python, test-gui]
if: always() && needs.test-python.result == 'success' && needs.test-gui.result == 'success'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install coverage dependencies
run: |
pip install coverage
- name: Download code coverage results
uses: actions/download-artifact@v4
with:
pattern: coverage_*
merge-multiple: true
- name: Combine coverage results
run: |
coverage combine .coverage_*
coverage xml
- name: Override coverage source path for Sonarcloud
run: |
sed -i "s/<source>\/home\/runner\/work\/enigma2-plugin-youtube\/enigma2-plugin-youtube<\/source>/<source>\/github\/workspace<\/source>/g" coverage.xml
- name: Sonarcloud scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
test-language:
needs: check_source
if: needs.check_source.outputs.language-changed == 'true' || contains(github.event.head_commit.message,'force-test')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install dependencies
run: |
sudo apt install gettext
- name: Compile language files
run: |
for i in $(ls -1 ./po/*.po); do $(msgfmt "$i" -o "$i".mo); done
update-translation:
needs: check_source
if: needs.check_source.outputs.translation-changed == 'true' || contains(github.event.head_commit.message,'force-test')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
- name: Install dependencies
run: |
sudo apt install gettext
- name: Update translation files
run: |
xgettext --no-wrap --no-location -L Python --from-code=UTF-8 -kpgettext:1c,2 --add-comments="TRANSLATORS:" -d ./po/YouTube -s -o ./po/YouTube.pot `find ./src -type f -name '*.py'`
find ./po -type f -name '*.po' -print -exec msgmerge --backup=none --no-wrap -s -U {} ./po/YouTube.pot \;
find ./po -type f -name '*.po' -print -exec msgattrib --no-obsolete --no-wrap -o {} {} \;
xgettext --no-wrap --no-location --omit-header -L Python --from-code=UTF-8 -kpgettext:1c,2 --add-comments="TRANSLATORS:" -d YouTube -s -o ./po/YouTube.pot `find ./src -type f -name '*.py'`
- name: Compile language files
run: |
for i in $(ls -1 ./po/*.po); do $(msgfmt "$i" -o "$i".mo); done
rm ./po/*.mo
- name: Commit and push translation updates
uses: Taapat/push@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
message: 'Update language files'
branch: 'master'
deploy:
needs: [test-python, test-gui, test-language]
if: always() && !contains(github.event.head_commit.message,'skip-release') && github.event_name == 'push' && (needs.test-python.result == 'success' || needs.test-python.result == 'skipped') && (needs.test-gui.result == 'success' || needs.test-gui.result == 'skipped') && (needs.test-language.result == 'success' || needs.test-language.result == 'skipped') && github.repository == 'Taapat/enigma2-plugin-youtube' && github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Set up Python 2
run: |
sudo apt install -y python2
- name: Install dependencies
run: |
sudo apt install gettext
- name: Build sources
run: |
python setup.py build --build-lib=build/lib
- name: Set git variables
run: |
echo "SRCPV=git$(git rev-list --count HEAD)" >> $GITHUB_ENV
echo "PKGV=-git$(git rev-list --count HEAD)-${GITHUB_SHA::7}-r0.0" >> $GITHUB_ENV
echo "COMMIT_SUBJECT=$(git log -1 --pretty=format:%s)" >> $GITHUB_ENV
- name: Create plugin package files
run: |
mkdir -p deploy/data/usr/lib/enigma2/python/Plugins
cp -r build/lib/* deploy/data/usr/lib/enigma2/python/Plugins
mkdir -p deploy/data/etc/enigma2
sed -i 's/Version:/Version: py3${{ env.PKGV }}/' deploy/control/control
mkdir ipk
- name: Compile Python 3 sources
run: |
python3 -m compileall -b deploy/data/usr/lib/enigma2/python/Plugins/Extensions/YouTube/
- name: Build Python 3 data package
working-directory: './deploy/data'
run: |
tar --numeric-owner --group=0 --owner=0 -czf ../data.tar.gz ./*
- name: Build Python 3 control package
working-directory: './deploy/control'
run: |
tar --numeric-owner --group=0 --owner=0 -czf ../control.tar.gz ./*
- name: Build Python 3 ipk package
working-directory: './deploy'
run: |
echo 2.0 > debian-binary
ar rv ../ipk/enigma2-plugin-extensions-youtube_py3${{ env.PKGV }}.ipk debian-binary data.tar.gz control.tar.gz
- name: Delete compiled Python 3 files
run: |
rm deploy/data/usr/lib/enigma2/python/Plugins/Extensions/YouTube/*.pyc
- name: Compile Python 2 sources
run: |
python2 -O -m compileall deploy/data/usr/lib/enigma2/python/Plugins/Extensions/YouTube/
- name: Build Python 2 data package
working-directory: './deploy/data'
run: |
tar --numeric-owner --group=0 --owner=0 -czf ../data.tar.gz ./*
- name: Build Python 2 control package
working-directory: './deploy/control'
run: |
sed -i 's/Version: py3+/Version: h1+/' control
sed -i 's/python3-/python-/g' control
tar --numeric-owner --group=0 --owner=0 -czf ../control.tar.gz ./*
- name: Build Python 2 ipk package
working-directory: './deploy'
run: |
ar rv ../ipk/enigma2-plugin-extensions-youtube_h1${{ env.PKGV }}.ipk debian-binary data.tar.gz control.tar.gz
- name: Create release
uses: Taapat/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ env.SRCPV }}
name: ${{ env.COMMIT_SUBJECT }}
gzip: false
files: >
ipk/enigma2-plugin-extensions-youtube_h1${{ env.PKGV }}.ipk
ipk/enigma2-plugin-extensions-youtube_py3${{ env.PKGV }}.ipk
- name: Upload ipk via ftp
uses: sebastianpopp/ftp-action@releases/v2
with:
host: ${{ secrets.FTP_SERVER }}
user: ${{ secrets.FTP_USERNAME }}
password: ${{ secrets.FTP_PASSWORD }}
localDir: 'ipk'
remoteDir: ${{ secrets.FTP_DIR }}