Skip to content

Commit 8cc2e85

Browse files
committed
Add QML format checking to CI
Also expands the Python file glob to include more files.
1 parent f45d984 commit 8cc2e85

File tree

7 files changed

+73
-17
lines changed

7 files changed

+73
-17
lines changed

Makefile.toml

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,32 @@
1+
env_scripts = [
2+
# Two proposed methods of simplifying path globbing
3+
# https://github.com/sagiegurari/cargo-make/issues/542
4+
# https://github.com/sagiegurari/cargo-make/issues/543
5+
'''
6+
#!@duckscript
7+
!include_files ./utils/glob.ds
8+
9+
py_files = glob_paths_excluding_target ./**/*.py
10+
11+
set_env PYTHON_FILES ${py_files}
12+
echo PYTHON_FILES=${py_files}
13+
14+
qml_files = glob_paths_excluding_target resources/**/*.qml
15+
16+
set_env QML_FILES ${qml_files}
17+
echo QML_FILES=${qml_files}
18+
''']
19+
120
[env]
2-
PYTHON_FILES = { script = ["python utils/glob_python_files.py"] }
321
CONDA_ENV = "console_pp"
422
REQUIREMENTS_FILE = "requirements.txt"
523
REQUIREMENTS_DEV_FILE = "requirements-dev.txt"
624

725
[config]
826
default_to_workspace = false
27+
init_task = "init"
28+
29+
[tasks.init]
930

1031
[tasks.poetry-export-dev]
1132
script_runner = "@shell"
@@ -172,6 +193,20 @@ conda run -n $CONDA_ENV python src/build/generate-mac-info-plist.py
172193
hdiutil create -volname SwiftNavConsole -srcfolder main.app -ov -format UDZO 'swift_navigation_console.dmg'
173194
'''
174195

196+
[tasks.qml-format.linux]
197+
env = { QT_APP = { script = ["conda run -n $CONDA_ENV python utils/echo-qt-dir.py"] } }
198+
script_runner = "@shell"
199+
script = '''
200+
${QT_APP}/Qt/bin/qmlformat -i $QML_FILES
201+
'''
202+
203+
[tasks.qml-format-check.linux]
204+
dependencies = ["qml-format"]
205+
script_runner = "@shell"
206+
script = '''
207+
git diff --exit-code -- $QML_FILES
208+
'''
209+
175210
[tasks.rust-format]
176211
dependencies = ["copy-capnp"]
177212
command = "cargo"
@@ -225,13 +260,13 @@ conda run -n $CONDA_ENV pylint --output-format=parseable $PYTHON_FILES
225260
'''
226261

227262
[tasks.format-all]
228-
dependencies = ["python-format-all", "rust-format"]
263+
dependencies = ["python-format-all", "qml-format", "rust-format"]
229264

230265
[tasks.format]
231266
alias = "format-all"
232267

233268
[tasks.format-check]
234-
dependencies = ["python-format-check", "rust-format-check"]
269+
dependencies = ["python-format-check", "qml-format-check", "rust-format-check"]
235270

236271
[tasks.lint]
237272
dependencies = ["python-lint", "rust-lint", "format-check"]

poetry.lock

Lines changed: 14 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pkgconfig = "^1.5.1"
2121
Cython = "^0.29.21"
2222
nuitka = "^0.6.11"
2323
psutil = "5.8.0"
24+
qt5-applications = [{ version = "^5.15.2", platform = "linux" }]
2425

2526
[build-system]
2627
requires = ["poetry-core>=1.0.0", "setuptools>=41.0.0", "wheel", "setuptools_rust>=0.10.2"]

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ pyparsing==2.4.7; python_version >= "3.5" and python_full_version < "3.0.0" or p
3434
pyside2==5.15.2; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0" and python_version < "3.10")
3535
pytest==5.4.3; python_version >= "3.5"
3636
pywin32-ctypes==0.2.0; sys_platform == "win32" and python_version >= "3.5"
37+
qt5-applications==5.15.2.2.1; sys_platform == "linux"
3738
regex==2020.11.13; python_version >= "3.6"
3839
semantic-version==2.8.5; python_version >= "3.5" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.5"
3940
setuptools-rust==0.11.6; python_version >= "3.5"

utils/echo-qt-dir.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import pathlib
2+
3+
try:
4+
import qt5_applications # type: ignore
5+
6+
print(pathlib.Path(qt5_applications.__file__).parent)
7+
except ImportError:
8+
pass

utils/glob.ds

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
fn glob_paths_excluding_target
2+
handle = glob_array ${1}
3+
out = array
4+
for i in ${handle}
5+
if not starts_with ${i} "target"
6+
array_push ${out} ${i}
7+
end
8+
end
9+
s = array_join ${out} " "
10+
return ${s}
11+
end

utils/glob_python_files.py

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)