build #1758
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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@v3 | |
with: | |
fetch-depth: 2 | |
- name: Check code changes | |
uses: dorny/paths-filter@v2 | |
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-get 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.11'] | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: MatteoH2O1999/setup-python@v1 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Upgrade pip | |
if: matrix.python-version != '2.7' | |
run: | | |
python -m pip install --upgrade pip | |
- 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,F821 --show-source --filename=./test/try_plugin.py | |
flake8 --ignore=W191,F401,E128,E402,E501 --show-source --filename=./src/jsinterp.py,./test/enigmahelper.py,./src/__init__.py | |
flake8 --ignore=W191,F821,F401 --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/True/g' src/YouTubeVideoUrl.py | |
- name: Test code with pytest | |
run: | | |
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@v3 | |
with: | |
name: coverage | |
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', 'OpenPLi release-8.3', 'OpenPLi release-6.2', 'openatv master', 'openatv 6.4', 'OpenViX Developer', 'Taapat bh'] | |
python-version: [2.7] | |
include: | |
- enigma2-version: 'OpenPLi develop' | |
python-version: '3.10' | |
- enigma2-version: 'openatv master' | |
python-version: '3.10' | |
- enigma2-version: 'OpenViX Developer' | |
python-version: '3.10' | |
exclude: | |
- enigma2-version: 'OpenPLi develop' | |
python-version: 2.7 | |
- enigma2-version: 'openatv master' | |
python-version: 2.7 | |
- enigma2-version: 'OpenViX Developer' | |
python-version: 2.7 | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set enigma2 repository | |
uses: jungwinter/split@v2 | |
id: split | |
with: | |
msg: ${{ matrix.enigma2-version }} | |
- name: Checkout ${{ matrix.enigma2-version }} repository | |
uses: actions/checkout@v3 | |
with: | |
repository: '${{ steps.split.outputs._0 }}/enigma2' | |
ref: ${{ steps.split.outputs._1 }} | |
path: './enigma2' | |
fetch-depth: 0 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: MatteoH2O1999/setup-python@v1 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
pip install twisted==20.3.0 pyopenssl service_identity | |
- name: Install additional dependencies | |
if: matrix.enigma2-version == 'openatv master' || matrix.enigma2-version == 'OpenViX Developer' | |
run: | | |
pip install requests chardet | |
- 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' && matrix.enigma2-version != 'openatv 6.4' && matrix.enigma2-version != 'Taapat bh' | |
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 | |
- 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 | |
- name: Patch enigma step 4 | |
if: matrix.enigma2-version == 'OpenPLi develop' | |
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@v3 | |
with: | |
name: coverage | |
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@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
- name: Install coverage dependencies | |
run: | | |
pip install coverage | |
- name: Download code coverage results | |
uses: actions/download-artifact@v3 | |
with: | |
name: coverage | |
- 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@v3 | |
with: | |
fetch-depth: 0 | |
- name: Install dependencies | |
run: | | |
sudo apt-get 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@v3 | |
with: | |
persist-credentials: false | |
fetch-depth: 0 | |
- name: Install dependencies | |
run: | | |
sudo apt-get 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: actions-js/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@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python 2.7 | |
uses: MatteoH2O1999/setup-python@v1 | |
with: | |
python-version: '2.7' | |
- name: Install dependencies | |
run: | | |
sudo apt-get 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: Build python3 data package | |
working-directory: './deploy/data' | |
run: | | |
tar --numeric-owner --group=0 --owner=0 -czf ../data.tar.gz ./* | |
- name: Build python3 control package | |
working-directory: './deploy/control' | |
run: | | |
tar --numeric-owner --group=0 --owner=0 -czf ../control.tar.gz ./* | |
- name: Build python3 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: Compile python2 sources | |
run: | | |
python -O -m compileall deploy/data/usr/lib/enigma2/python/Plugins/Extensions/YouTube/ | |
- name: Build python2 data package | |
working-directory: './deploy/data' | |
run: | | |
tar --numeric-owner --group=0 --owner=0 -czf ../data.tar.gz ./* | |
- name: Build python2 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 python2 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: meeDamian/[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 }} |