Skip to content

Commit c4dd236

Browse files
committed
tests: add reusable QML test infrastructure and run it in CI
Signed-off-by: Patrizio Bekerle <patrizio@bekerle.com>
1 parent 2058fd5 commit c4dd236

4 files changed

Lines changed: 43 additions & 2 deletions

File tree

.github/workflows/run-tests.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ jobs:
88
test:
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v2
11+
- name: "🧰 Checkout code"
12+
uses: actions/checkout@v6
13+
- name: "⚙️ Install Nix"
14+
uses: cachix/install-nix-action@v31
15+
with:
16+
nix_path: nixpkgs=channel:nixos-unstable
17+
- name: "🔒 Cache dependencies"
18+
uses: cachix/cachix-action@v16
19+
with:
20+
name: devenv
21+
- name: "🔧 Install devenv.sh"
22+
run: nix profile add nixpkgs#devenv
1223
- name: "✅ Run tests"
13-
run: php ./.github/workflows/scripts/run-tests.php
24+
run: devenv shell "just test"
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
if ! command -v qmltestrunner >/dev/null 2>&1; then
6+
printf 'qmltestrunner was not found in PATH\n' >&2
7+
exit 1
8+
fi
9+
10+
shopt -s nullglob
11+
test_directories=(*/tests)
12+
qml_import_arguments=()
13+
14+
if [[ -n "${QML_TEST_IMPORT_PATH:-}" ]]; then
15+
qml_import_arguments=(-import "$QML_TEST_IMPORT_PATH")
16+
fi
17+
18+
if ((${#test_directories[@]} == 0)); then
19+
printf 'No QML tests were found\n'
20+
exit 0
21+
fi
22+
23+
for test_directory in "${test_directories[@]}"; do
24+
printf 'Running QML tests in %s\n' "$test_directory"
25+
QT_QPA_PLATFORM="${QT_QPA_PLATFORM:-offscreen}" qmltestrunner "${qml_import_arguments[@]}" -input "$test_directory"
26+
done

devenv.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
}:
55

66
{
7+
packages = [ pkgs.qt6.qtdeclarative ];
8+
env.QML_TEST_IMPORT_PATH = "${pkgs.qt6.qtdeclarative}/lib/qt-6/qml";
9+
710
# https://devenv.sh/git-hooks/
811
git-hooks.hooks = {
912
php-cs-fixer = {

justfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ git-apply-patch:
2727
[group('test')]
2828
@test:
2929
php ./.github/workflows/scripts/run-tests.php
30+
bash ./.github/workflows/scripts/run-qml-tests.sh

0 commit comments

Comments
 (0)