Skip to content

Commit dc64a07

Browse files
chore: portfolio alignment + MainUiState refactor
Brings the Linux client in line with the rest of the TinkerNorth portfolio (dish-android, dish-mac, satellite) on tooling, CI, hook semantics, and data-flow shape, and ships a release pipeline. Tooling - .clang-format / .clang-tidy replaced with the canonical TinkerNorth rulesets (md5 matches dish-android + satellite verbatim). Source tree reformatted; ctest still 100% pass (29/29). - .githooks/pre-commit flipped from --dry-run --Werror to autofix-and- re-stage, matching the dish-mac and satellite hooks. CI (.github/workflows/linux-ci.yml) - clang-format pinned to 22.1.4 via pipx (was unpinned apt — Ubuntu 24.04's v18 disagreed with brew's v22 on braced-init lists). AppModel refactor — MainUiState - Replaces the slotsChanged / connectionsChanged / pairingTargetChanged trio with one canonical stateChanged() signal carrying a MainUiState slice (slotList, connections, pairingTarget). Mirrors dish-android's MainViewModel + dish-mac's @published shape so the three clients all expose state the same way. - MainWindow subscribes once and reads model->state().{slotList, connections, pairingTarget}. Pairing dialog flow now driven from state-change observation instead of a separate signal. - Field is named slotList not slots because Qt's moc reserves that token. Release pipeline (new .github/workflows/release.yml) - Tag-triggered (v*) build of release binary on ubuntu-22.04 (matches oldest LTS we want to support at runtime). - Packages as both .deb (for Debian/Ubuntu) and AppImage (for everyone else), uploaded to GitHub Releases. Documentation - CONTRIBUTING.md updated to reflect autofix hook semantics.
1 parent 3131169 commit dc64a07

48 files changed

Lines changed: 703 additions & 766 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.clang-format‎

Lines changed: 50 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,62 @@
1-
---
2-
Language: Cpp
3-
BasedOnStyle: Google
1+
# TinkerNorth — canonical clang-format configuration.
2+
# This exact file is shared by satellite, dish-android (JNI), dish-linux,
3+
# and dish-mac (any C/C++ source). Pinned to clang-format 22.1.4 in CI;
4+
# older versions may produce small diffs on braced-init lists.
5+
# Run: clang-format -i <files>
6+
7+
BasedOnStyle: LLVM
8+
9+
# Indentation
410
IndentWidth: 4
511
TabWidth: 4
612
UseTab: Never
7-
ColumnLimit: 110
8-
AccessModifierOffset: -4
13+
IndentCaseLabels: false
14+
NamespaceIndentation: None
15+
16+
# Braces
17+
BreakBeforeBraces: Attach # K&R: opening brace on same line
18+
AllowShortBlocksOnASingleLine: Always
19+
AllowShortFunctionsOnASingleLine: All
20+
AllowShortIfStatementsOnASingleLine: WithoutElse
21+
AllowShortLoopsOnASingleLine: true
22+
AllowShortLambdasOnASingleLine: All
23+
24+
# Line length
25+
ColumnLimit: 100
26+
27+
# Alignment
928
AlignAfterOpenBracket: Align
29+
AlignConsecutiveAssignments: false
30+
AlignConsecutiveDeclarations: false
31+
AlignOperands: Align
1032
AlignTrailingComments: true
11-
AllowShortFunctionsOnASingleLine: Inline
12-
AllowShortIfStatementsOnASingleLine: Never
13-
AllowShortLoopsOnASingleLine: false
14-
AlwaysBreakTemplateDeclarations: Yes
15-
BinPackArguments: false
16-
BinPackParameters: false
17-
BreakBeforeBraces: Attach
33+
34+
# Spaces
35+
SpaceBeforeParens: ControlStatements # if (...) but func(...)
36+
SpaceAfterCStyleCast: false
37+
SpacesInParentheses: false
38+
SpacesInSquareBrackets: false
39+
SpaceBeforeSquareBrackets: false
40+
41+
# Includes
42+
SortIncludes: false # don't reorder — Windows headers are order-sensitive
43+
IncludeBlocks: Preserve
44+
45+
# Pointer/reference alignment
46+
PointerAlignment: Left # char* buf (not char *buf)
47+
ReferenceAlignment: Left
48+
49+
# Other
50+
AllowAllParametersOfDeclarationOnNextLine: true
51+
BinPackArguments: true
52+
BinPackParameters: true
1853
BreakConstructorInitializers: BeforeColon
19-
ConstructorInitializerAllOnOneLineOrOnePerLine: true
54+
ConstructorInitializerIndentWidth: 4
2055
ContinuationIndentWidth: 4
2156
Cpp11BracedListStyle: true
2257
DerivePointerAlignment: false
2358
FixNamespaceComments: true
24-
IncludeBlocks: Preserve
25-
IndentCaseLabels: true
26-
IndentPPDirectives: None
27-
KeepEmptyLinesAtTheStartOfBlocks: false
28-
NamespaceIndentation: None
29-
PointerAlignment: Left
59+
MaxEmptyLinesToKeep: 1
3060
ReflowComments: true
31-
SortIncludes: CaseInsensitive
32-
SortUsingDeclarations: true
33-
SpaceAfterCStyleCast: false
34-
SpaceAfterTemplateKeyword: false
35-
SpaceBeforeAssignmentOperators: true
36-
SpaceBeforeParens: ControlStatements
37-
SpaceInEmptyParentheses: false
38-
SpacesBeforeTrailingComments: 2
39-
SpacesInAngles: false
40-
SpacesInCStyleCastParentheses: false
41-
SpacesInContainerLiterals: false
42-
SpacesInParentheses: false
43-
SpacesInSquareBrackets: false
61+
SpaceBeforeCpp11BracedList: false
4462
Standard: c++17
45-
---

‎.clang-tidy‎

Lines changed: 45 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,51 @@
1-
---
1+
# TinkerNorth — canonical clang-tidy configuration.
2+
# This exact file is shared by satellite, dish-android (JNI), dish-linux,
3+
# and dish-mac (any C/C++ source).
4+
#
5+
# HeaderFilterRegex matches headers under src/, app/src/main/cpp/, or tests/
6+
# so the same config covers every repo without per-repo overrides.
7+
28
Checks: >
39
-*,
410
bugprone-*,
5-
clang-analyzer-*,
6-
cppcoreguidelines-*,
7-
modernize-*,
8-
performance-*,
9-
portability-*,
10-
readability-*,
1111
-bugprone-easily-swappable-parameters,
12-
-cppcoreguidelines-avoid-magic-numbers,
13-
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
14-
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
15-
-cppcoreguidelines-pro-bounds-constant-array-index,
16-
-cppcoreguidelines-pro-type-reinterpret-cast,
17-
-cppcoreguidelines-pro-type-vararg,
18-
-cppcoreguidelines-non-private-member-variables-in-classes,
19-
-cppcoreguidelines-owning-memory,
20-
-cppcoreguidelines-avoid-non-const-global-variables,
21-
-modernize-use-trailing-return-type,
22-
-modernize-avoid-c-arrays,
23-
-portability-avoid-pragma-once,
24-
-readability-magic-numbers,
25-
-readability-identifier-length,
26-
-readability-function-cognitive-complexity,
27-
-readability-redundant-access-specifiers
12+
-bugprone-narrowing-conversions,
13+
cert-*,
14+
-cert-err58-cpp,
15+
cppcoreguidelines-init-variables,
16+
cppcoreguidelines-avoid-goto,
17+
misc-redundant-expression,
18+
misc-unused-using-decls,
19+
modernize-use-auto,
20+
modernize-use-nullptr,
21+
modernize-use-override,
22+
modernize-use-using,
23+
modernize-loop-convert,
24+
modernize-redundant-void-arg,
25+
modernize-return-braced-init-list,
26+
performance-*,
27+
-performance-no-int-to-ptr,
28+
readability-braces-around-statements,
29+
readability-const-return-type,
30+
readability-container-size-empty,
31+
readability-duplicate-include,
32+
readability-else-after-return,
33+
readability-implicit-bool-conversion,
34+
readability-inconsistent-declaration-parameter-name,
35+
readability-misleading-indentation,
36+
readability-redundant-control-flow,
37+
readability-redundant-string-cstr,
38+
readability-simplify-boolean-expr,
39+
readability-string-compare,
40+
2841
WarningsAsErrors: ''
29-
HeaderFilterRegex: '^.*/dish-linux/src/.*$'
30-
FormatStyle: file
42+
43+
HeaderFilterRegex: '.*/(src|app/src/main/cpp|tests)/.*\.h$'
44+
3145
CheckOptions:
32-
- key: readability-identifier-naming.ClassCase
33-
value: CamelCase
34-
- key: readability-identifier-naming.StructCase
35-
value: CamelCase
36-
- key: readability-identifier-naming.EnumCase
37-
value: CamelCase
38-
- key: readability-identifier-naming.FunctionCase
39-
value: camelBack
40-
- key: readability-identifier-naming.VariableCase
41-
value: camelBack
42-
- key: readability-identifier-naming.PrivateMemberSuffix
43-
value: _
44-
- key: readability-identifier-naming.ConstexprVariableCase
45-
value: CamelCase
46-
- key: readability-identifier-naming.ConstexprVariablePrefix
47-
value: k
48-
- key: readability-identifier-naming.GlobalConstantCase
49-
value: CamelCase
50-
- key: readability-identifier-naming.GlobalConstantPrefix
51-
value: k
52-
---
46+
- key: modernize-use-auto.MinTypeNameLength
47+
value: 5
48+
- key: readability-braces-around-statements.ShortStatementLines
49+
value: 1
50+
- key: performance-move-const-arg.CheckTriviallyCopyableMove
51+
value: false

‎.githooks/pre-commit‎

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,46 @@
11
#!/usr/bin/env bash
2-
# Dish Linux pre-commit hook: runs clang-format (check) and clang-tidy
3-
# (warnings → errors) on staged C++ sources. Skips gracefully if either
4-
# tool is missing so contributors who haven't run setup-hooks.sh aren't
5-
# blocked — CI enforces both checks in strict mode.
2+
# Dish Linux pre-commit hook: autofixes clang-format on staged C/C++ sources
3+
# (mirroring the satellite and dish-mac hook semantics) and runs clang-tidy
4+
# in advisory mode. Skips gracefully if either tool is missing — CI enforces
5+
# both checks in strict mode.
66
set -euo pipefail
77

88
repo_root=$(git rev-parse --show-toplevel)
99
cd "$repo_root"
1010

11-
# Collect staged C/C++ sources under src/ and tests/ (added/copied/modified).
12-
mapfile -t staged < <(
13-
git diff --cached --name-only --diff-filter=ACM \
14-
-- 'src/*.cpp' 'src/*.h' 'src/*.hpp' 'tests/*.cpp' 'tests/*.h'
15-
)
16-
17-
if [ "${#staged[@]}" -eq 0 ]; then
11+
# Collect staged C/C++ sources under src/ and tests/ (added/copied/modified),
12+
# NUL-separated to handle paths with spaces.
13+
staged=$(git diff --cached --name-only --diff-filter=ACM -z \
14+
-- 'src/*.cpp' 'src/*.h' 'src/*.hpp' 'tests/*.cpp' 'tests/*.h' \
15+
| tr '\0' '\n' | sed '/^$/d')
16+
if [ -z "$staged" ]; then
1817
exit 0
1918
fi
2019

21-
format_ok=1
22-
tidy_ok=1
23-
24-
# ── clang-format ─────────────────────────────────────────────────────────
20+
# ── clang-format (autofix) ───────────────────────────────────────────────
2521
if command -v clang-format >/dev/null 2>&1; then
26-
echo "▶ clang-format --dry-run --Werror (${#staged[@]} file(s))"
27-
if ! clang-format --dry-run --Werror "${staged[@]}"; then
28-
echo " run: clang-format -i ${staged[*]}"
29-
format_ok=0
30-
fi
22+
echo "▶ clang-format (staged files)"
23+
echo "$staged" | while IFS= read -r file; do
24+
clang-format -i "$file"
25+
git add "$file"
26+
done
3127
else
32-
echo "⚠ clang-format not installed — skipping (install clang-format)"
28+
echo "⚠ clang-format not installed — skipping (sudo apt install clang-format)"
3329
fi
3430

35-
# ── clang-tidy ───────────────────────────────────────────────────────────
31+
# ── clang-tidy (advisory) ────────────────────────────────────────────────
3632
# Needs a compile_commands.json. We generate one in build-debug via CMake
3733
# (CMAKE_EXPORT_COMPILE_COMMANDS is ON in CMakeLists.txt). Match CI: report
3834
# warnings but don't block the commit on stylistic findings — .clang-tidy's
3935
# WarningsAsErrors='' is authoritative.
4036
if command -v clang-tidy >/dev/null 2>&1; then
4137
if [ -f build-debug/compile_commands.json ]; then
4238
cpp_files=()
43-
for f in "${staged[@]}"; do
39+
while IFS= read -r f; do
4440
case "$f" in
4541
*.cpp) cpp_files+=("$f") ;;
4642
esac
47-
done
43+
done <<<"$staged"
4844
if [ "${#cpp_files[@]}" -gt 0 ]; then
4945
echo "▶ clang-tidy -p build-debug (${#cpp_files[@]} file(s))"
5046
clang-tidy -p build-debug --quiet "${cpp_files[@]}" || true
@@ -53,11 +49,5 @@ if command -v clang-tidy >/dev/null 2>&1; then
5349
echo "⚠ build-debug/compile_commands.json missing — run scripts/build.sh debug"
5450
fi
5551
else
56-
echo "⚠ clang-tidy not installed — skipping (install clang-tidy)"
57-
fi
58-
59-
if [ "$format_ok" -eq 0 ] || [ "$tidy_ok" -eq 0 ]; then
60-
echo
61-
echo "✗ pre-commit failed — fix the issues above and re-stage."
62-
exit 1
52+
echo "⚠ clang-tidy not installed — skipping (sudo apt install clang-tidy)"
6353
fi

‎.github/workflows/linux-ci.yml‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,21 @@ jobs:
2626
build-essential cmake ninja-build pkg-config \
2727
qt6-base-dev qt6-base-dev-tools \
2828
libsodium-dev libsdl2-dev \
29-
clang-format clang-tidy
29+
clang-tidy
30+
31+
- name: Set up Python
32+
uses: actions/setup-python@v5
33+
with:
34+
python-version: "3.12"
35+
36+
# Pinned to match satellite + dish-android + dish-mac. Ubuntu 24.04 ships
37+
# clang-format 18 which disagrees with brew's 22.x on braced-init lists,
38+
# so we pull the matching wheel from PyPI to keep the four repos in sync.
39+
- name: Install clang-format (pinned 22.1.4)
40+
run: |
41+
pipx install clang-format==22.1.4
42+
pipx ensurepath
43+
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
3044
3145
- name: clang-format (check only)
3246
run: |

0 commit comments

Comments
 (0)