Skip to content

Commit 91be3fe

Browse files
authored
Refactor Kodi addon checker workflow
1 parent 5ac2661 commit 91be3fe

1 file changed

Lines changed: 99 additions & 19 deletions

File tree

.github/workflows/addon-check.yml

Lines changed: 99 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,109 @@
1-
name: Kodi Addon Checker
1+
name: Validate Kodi Add-on
22

33
on:
44
push:
55
branches: [ main, master ]
66
pull_request:
77
branches: [ main, master ]
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: addon-check-${{ github.ref }}
12+
cancel-in-progress: true
813

914
jobs:
10-
kodi-addon-checker:
15+
kodi-addon-check:
16+
name: addon-check (${{ matrix.kodi_branch }})
1117
runs-on: ubuntu-latest
12-
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
kodi_branch: [nexus, omega, piers]
22+
1323
steps:
14-
- uses: actions/checkout@v3
15-
16-
- name: Set up Python
17-
uses: actions/setup-python@v4
18-
with:
19-
python-version: '3.11'
20-
21-
- name: Install dependencies
22-
run: |
23-
python -m pip install --upgrade pip
24-
pip install setuptools wheel
25-
pip install kodi-addon-checker
26-
27-
- name: Run addon checker
28-
run: |
29-
kodi-addon-checker --branch omega service.libreelec.backupper
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
27+
- name: Set up Python
28+
uses: actions/setup-python@v5
29+
with:
30+
python-version: "3.11"
31+
32+
- name: Install addon-check
33+
run: |
34+
python -m pip install --upgrade pip
35+
python -m pip install kodi-addon-checker
36+
37+
- name: Read addon id from addon.xml
38+
id: addon_meta
39+
run: |
40+
set -euo pipefail
41+
ADDON_ID="$(python - <<'PY'
42+
from xml.etree import ElementTree as ET
43+
root = ET.parse('addon.xml').getroot()
44+
print(root.attrib['id'])
45+
PY
46+
)"
47+
echo "addon_id=${ADDON_ID}" >> "${GITHUB_OUTPUT}"
48+
49+
- name: Prepare addon-check source directory
50+
id: source_dir
51+
run: |
52+
set -euo pipefail
53+
WORKDIR="${RUNNER_TEMP}/addon-check-src"
54+
TARGET_DIR="${WORKDIR}/${{ steps.addon_meta.outputs.addon_id }}"
55+
rm -rf "${WORKDIR}"
56+
mkdir -p "${TARGET_DIR}"
57+
rsync -a ./ "${TARGET_DIR}/" \
58+
--exclude '.git/' \
59+
--exclude '.github/' \
60+
--exclude '.venv/' \
61+
--exclude 'venv/' \
62+
--exclude '.env/' \
63+
--exclude '.vscode/' \
64+
--exclude '.idea/' \
65+
--exclude '.cache/' \
66+
--exclude 'cache/' \
67+
--exclude '__pycache__/' \
68+
--exclude '.pytest_cache/' \
69+
--exclude '.mypy_cache/' \
70+
--exclude '.ruff_cache/' \
71+
--exclude '.tox/' \
72+
--exclude '.nox/' \
73+
--exclude '.addon-check-run.log' \
74+
--exclude '*.pyc' \
75+
--exclude '*.pyo' \
76+
--exclude '.DS_Store' \
77+
--exclude 'tests/' \
78+
--exclude 'scripts/' \
79+
--exclude 'package_build/' \
80+
--exclude 'package_clean/' \
81+
--exclude '*.zip' \
82+
--exclude '.gitignore'
83+
echo "addon_path=${TARGET_DIR}" >> "${GITHUB_OUTPUT}"
84+
85+
- name: Run addon-check
86+
run: |
87+
set -euo pipefail
88+
EXTRA_ARGS=""
89+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
90+
EXTRA_ARGS="--PR"
91+
fi
92+
kodi-addon-checker "${{ steps.source_dir.outputs.addon_path }}" --branch "${{ matrix.kodi_branch }}" ${EXTRA_ARGS}
93+
94+
python-syntax:
95+
name: Python Syntax Check
96+
runs-on: ubuntu-latest
97+
98+
steps:
99+
- name: Checkout repository
100+
uses: actions/checkout@v4
101+
102+
- name: Set up Python
103+
uses: actions/setup-python@v5
104+
with:
105+
python-version: "3.11"
106+
107+
- name: Compile Python files
108+
run: |
109+
python -m compileall default.py resources

0 commit comments

Comments
 (0)