Skip to content

[video_transcoder] v0.1.6 #125

[video_transcoder] v0.1.6

[video_transcoder] v0.1.6 #125

name: Unmanic Plugin Test and Generate Repo
on:
push:
branches:
- '**'
- 'pr-**'
- '!template'
pull_request:
branches:
- 'official'
- 'master'
jobs:
# Ensure that all plugins contain the required files and that
# certain files or directories are not present.
plugins-contain-required-files:
runs-on: ubuntu-latest
name: Plugins contain all required files
steps:
# Checkout
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# _____ ____ _
# | ____|_ __ ___ _ _ _ __ ___ | _ \ _ __ ___ ___ ___ _ __ | |_
# | _| | '_ \/ __| | | | '__/ _ \ | |_) | '__/ _ \/ __|/ _ \ '_ \| __|
# | |___| | | \__ \ |_| | | | __/ | __/| | | __/\__ \ __/ | | | |_
# |_____|_| |_|___/\__,_|_| \___| |_| |_| \___||___/\___|_| |_|\__|
#
- name: Check all plugins exist in source directory
if: success() || failure()
run: |
success=0
for root_dir in ./*; do
if [ -d "${root_dir:?}" ]; then
# Ignore docs directory
[ "$(basename ${root_dir:?})" == "docs" ] && continue
# The only other directory should be "source"
if [ "$(basename ${root_dir:?})" != "source" ]; then
echo "FAIL - Found an unexpected directory in '${root_dir:?}'. All plugins should be added to './source/'."
success=1
fi
fi
done
if [ ${success} -gt 0 ]; then
exit 1
else
echo "PASS - Found a correct directory structure in the project root."
fi
- name: Check .gitignore in all plugin folders
if: success() || failure()
run: |
success=0
for plugin_dir in source/*; do
if [ -d "${plugin_dir}" ]; then
# Ensure this directory contains a .gitignore file
if [ -e "${plugin_dir}/.gitignore" ]; then
echo "PASS - Found .gitignore in plugin '${plugin_dir}'"
else
echo "FAIL - Missing .gitignore in plugin '${plugin_dir}'"
success=1
fi
fi
done
if [ ${success} -gt 0 ]; then
exit 1
fi
- name: Check info.json in all plugin folders
if: success() || failure()
run: |
success=0
for plugin_dir in source/*; do
if [ -d "${plugin_dir}" ]; then
# Ensure this directory contains a info.json file
if [ -e "${plugin_dir}/info.json" ]; then
echo "PASS - Found info.json in plugin '${plugin_dir}'"
else
echo "FAIL - Missing info.json in plugin '${plugin_dir}'"
success=1
fi
fi
done
if [ ${success} -gt 0 ]; then
exit 1
fi
- name: Check LICENSE file in all plugin folders
if: success() || failure()
run: |
success=0
for plugin_dir in source/*; do
if [ -d "${plugin_dir}" ]; then
# Ensure this directory contains a LICENSE file
if [ -e "${plugin_dir}/LICENSE" ]; then
echo "PASS - Found LICENSE in plugin '${plugin_dir}'"
else
echo "FAIL - Missing LICENSE in plugin '${plugin_dir}'"
success=1
fi
fi
done
if [ ${success} -gt 0 ]; then
exit 1
fi
- name: Check plugin.py in all plugin folders
if: success() || failure()
run: |
success=0
for plugin_dir in source/*; do
if [ -d "${plugin_dir}" ]; then
# Ensure this directory contains a plugin.py file
if [ -e "${plugin_dir}/plugin.py" ]; then
echo "PASS - Found plugin.py in plugin '${plugin_dir}'"
else
echo "FAIL - Missing plugin.py in plugin '${plugin_dir}'"
success=1
fi
fi
done
if [ ${success} -gt 0 ]; then
exit 1
fi
- name: Check python source files contain the required SPDX identifier in header
if: success() || failure()
run: |
success=0
for plugin_dir in source/*; do
if [ -d "${plugin_dir}" ]; then
correct_header=0
# Ensure this directory contains a settings.json file
for python_file in $(find ${plugin_dir} -name '*.py' -not -path "${plugin_dir}/site-packages/*" -not -path "${plugin_dir}/dep/*"); do
if ! grep -q "Copyright:" "${python_file}"; then
echo "FAIL - Python file '${python_file}' Missing required SPDX identifier in header"
echo " See 'Standard License Header' here: https://spdx.org/licenses/GPL-3.0-only.html#licenseHeader"
correct_header=1
success=1
continue
fi
if ! grep -q "Copyright (C)" "${python_file}"; then
echo "FAIL - Python file '${python_file}' Missing required SPDX identifier in header"
echo " See 'Standard License Header' here: https://spdx.org/licenses/GPL-3.0-only.html#licenseHeader"
correct_header=1
success=1
continue
fi
if ! grep -q "This program is free software" "${python_file}"; then
echo "FAIL - Python file '${python_file}' Missing required SPDX identifier in header"
echo " See 'Standard License Header' here: https://spdx.org/licenses/GPL-3.0-only.html#licenseHeader"
correct_header=1
success=1
continue
fi
if ! grep -q "This program is distributed in the hop" "${python_file}"; then
echo "FAIL - Python file '${python_file}' Missing required SPDX identifier in header"
echo " See 'Standard License Header' here: https://spdx.org/licenses/GPL-3.0-only.html#licenseHeader"
correct_header=1
success=1
continue
fi
if ! grep -q "You should have received a copy of the GNU General Public License along with this program" "${python_file}"; then
echo "FAIL - Python file '${python_file}' Missing required SPDX identifier in header"
echo " See 'Standard License Header' here: https://spdx.org/licenses/GPL-3.0-only.html#licenseHeader"
correct_header=1
success=1
continue
fi
done
if [ ${correct_header} == 0 ]; then
echo "PASS - All python files in plugin '${plugin_dir}' contain the correct SPDX identifier in header"
fi
fi
done
if [ ${success} -gt 0 ]; then
exit 1
fi
# _____ __ __ _ _
# | ____|_ __ ___ _ _ _ __ ___ | \/ (_)___ ___(_)_ __ __ _
# | _| | '_ \/ __| | | | '__/ _ \ | |\/| | / __/ __| | '_ \ / _` |
# | |___| | | \__ \ |_| | | | __/ | | | | \__ \__ \ | | | | (_| |
# |_____|_| |_|___/\__,_|_| \___| |_| |_|_|___/___/_|_| |_|\__, |
# |___/
- name: Check site-packages in all plugin folders
if: success() || failure()
run: |
success=0
for plugin_dir in source/*; do
if [ -d "${plugin_dir}" ]; then
# Ensure this directory contains a site-packages file
if [ -e "${plugin_dir}/site-packages" ]; then
echo "FAIL - Directory 'site-packages' found in plugin '${plugin_dir}'"
success=1
else
echo "PASS - No 'site-packages' directory found in plugin '${plugin_dir}'"
fi
fi
done
if [ ${success} -gt 0 ]; then
exit 1
fi
- name: Check settings.json in all plugin folders
if: success() || failure()
run: |
success=0
for plugin_dir in source/*; do
if [ -d "${plugin_dir}" ]; then
# Ensure this directory contains a settings.json file
if [ -e "${plugin_dir}/settings.json" ]; then
echo "FAIL - Directory 'settings.json' found in plugin '${plugin_dir}'"
success=1
else
echo "PASS - No 'settings.json' directory found in plugin '${plugin_dir}'"
fi
fi
done
if [ ${success} -gt 0 ]; then
exit 1
fi
# Store success message in success file artifact
- name: Set success file on completion of tests
if: success()
run: echo 'true' > success_file.txt
- name: Upload success file
if: success()
uses: actions/upload-artifact@v4
with:
name: success_file
path: success_file.txt
# Build the plugin repository
deploy-plugin-repo:
needs: [plugins-contain-required-files]
runs-on: ubuntu-latest
name: Build the plugin repository
steps:
# Fetch and read success file
- name: Download success file from previous job
uses: actions/download-artifact@v4
with:
path: ./artifacts/
- name: Read success file
id: previous_jobs_success
run: |
IS_SUCCESS=$(cat ./artifacts/success_file/success_file.txt)
echo "IS_SUCCESS=${IS_SUCCESS:?}" >> $GITHUB_OUTPUT
rm -rfv ./artifacts
# Checkout
- name: Checkout
if: steps.previous_jobs_success.outputs.IS_SUCCESS == 'true'
uses: actions/checkout@v4
with:
submodules: recursive
# Execute plugin repo gen action
- name: Generate and Deploy Unmanic Plugin Repository
uses: Unmanic/action.generate-unmanic-plugin-repo@master
with:
deploy_repo: 'true'
github_token: ${{ secrets.GH_TOKEN }}