Skip to content

Commit b19e32d

Browse files
committed
fix(ci): handle qmlformat binary name across Ubuntu versions
1 parent ea63647 commit b19e32d

2 files changed

Lines changed: 25 additions & 3 deletions

File tree

.github/workflows/quality.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ jobs:
2323
- name: Install Qt tools
2424
run: |
2525
sudo apt-get update
26-
sudo apt-get install -y qt6-declarative-dev-tools
26+
# qt6-declarative-dev-tools provides qmlformat on Ubuntu 22.04;
27+
# qml6format is the package name on Ubuntu 24.04+.
28+
# Try both; at least one must succeed.
29+
sudo apt-get install -y qt6-declarative-dev-tools || \
30+
sudo apt-get install -y qml6format
2731
2832
- name: Lint Markdown
2933
run: bash scripts/lint-markdown.sh

scripts/validate-qml.sh

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4+
# Detect qmlformat binary — name varies by Qt version and distro:
5+
# qmlformat (Qt5 / Qt6 on Ubuntu 22.04)
6+
# qml6format (Qt6 on Ubuntu 24.04+)
7+
# qmlformat6 (some Fedora/Arch packaging)
8+
QML_FMT=""
9+
for candidate in qmlformat qml6format qmlformat6; do
10+
if command -v "$candidate" &>/dev/null; then
11+
QML_FMT="$candidate"
12+
break
13+
fi
14+
done
15+
16+
if [[ -z "$QML_FMT" ]]; then
17+
echo "Error: no QML formatter found (tried: qmlformat, qml6format, qmlformat6)." >&2
18+
echo "Install qt6-declarative-dev-tools (Ubuntu 22.04) or qml6format (Ubuntu 24.04+)." >&2
19+
exit 1
20+
fi
21+
422
mapfile -t qml_files < <(find . -type f -name "*.qml" | sort)
523

624
if [[ ${#qml_files[@]} -eq 0 ]]; then
@@ -9,7 +27,7 @@ if [[ ${#qml_files[@]} -eq 0 ]]; then
927
fi
1028

1129
for file in "${qml_files[@]}"; do
12-
qmlformat "$file" >/dev/null
30+
"$QML_FMT" "$file" >/dev/null
1331
done
1432

15-
echo "QML syntax validation passed for ${#qml_files[@]} file(s)."
33+
echo "QML syntax validation passed for ${#qml_files[@]} file(s) (via $QML_FMT)."

0 commit comments

Comments
 (0)