Skip to content

Commit 56322f0

Browse files
Merge remote-tracking branch 'origin/main' into houliston/newdocs
2 parents 40c6393 + 733b870 commit 56322f0

177 files changed

Lines changed: 3398 additions & 1529 deletions

File tree

Some content is hidden

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

.clang-tidy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Checks: >
3434
-readability-function-size,
3535
-readability-identifier-length,
3636
-readability-magic-numbers,
37+
-readability-math-missing-parentheses,
3738
-readability-uppercase-literal-suffix,
3839
modernize-*,
3940
-modernize-use-trailing-return-type,
@@ -70,3 +71,5 @@ CheckOptions:
7071
value: google
7172
- key: readability-braces-around-statements.ShortStatementLines
7273
value: "1"
74+
- key: misc-include-cleaner.IgnoreHeaders
75+
value: "asm-generic/.*;bits/.*"

.github/workflows/gcc.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
version: "7"
3737

3838
name: Linux GCC-${{ matrix.toolchain.version }}
39-
runs-on: ubuntu-latest
39+
runs-on: ubuntu-24.04
4040
continue-on-error: true
4141

4242
# Use the container for this specific version of gcc
@@ -92,11 +92,17 @@ jobs:
9292

9393
- name: Test
9494
timeout-minutes: 2
95-
working-directory: build/tests
96-
run: ctest --output-on-failure -E "dsl/UDP"
95+
working-directory: build
96+
run: ninja run_all_tests -k 0
97+
98+
- name: Test Summary
99+
if: ${{ !cancelled() }}
100+
uses: test-summary/action@v2
101+
with:
102+
paths: "build/reports/tests/*.junit.xml"
97103

98104
- name: Upload Traces
99-
if: always()
105+
if: ${{ !cancelled() }}
100106
uses: actions/upload-artifact@v4
101107
with:
102108
name: traces-gcc-${{ matrix.toolchain.version }}

.github/workflows/linting.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@ concurrency:
2020
jobs:
2121
linux-clang-tidy:
2222
name: Linux Clang-Tidy
23-
runs-on: ubuntu-latest
23+
runs-on: ubuntu-24.04
2424

2525
steps:
2626
- name: Checkout Code
2727
uses: actions/checkout@v4
2828

29-
- name: Install clang-tidy-15
29+
- name: Install clang-tidy
3030
run: |
3131
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
32-
echo "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main" | sudo tee /etc/apt/sources.list.d/llvm-15
33-
echo "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main" | sudo tee -a /etc/apt/sources.list.d/llvm-15
32+
echo "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-19 main" | sudo tee /etc/apt/sources.list.d/llvm-19.list
33+
echo "deb-src http://apt.llvm.org/noble/ llvm-toolchain-noble-19 main" | sudo tee -a /etc/apt/sources.list.d/llvm-19.list
3434
sudo apt-get update
35-
sudo apt-get install -y clang-tidy-15
35+
sudo apt-get install -y clang-tidy-19
3636
3737
# Download and install cmake
3838
- name: Install CMake
@@ -62,7 +62,7 @@ jobs:
6262
6363
mkdir -p ${{ github.workspace }}/.ctcache
6464
65-
echo CTCACHE_CLANG_TIDY='/usr/bin/clang-tidy-15' >> "$GITHUB_ENV"
65+
echo CTCACHE_CLANG_TIDY='/usr/bin/clang-tidy-19' >> "$GITHUB_ENV"
6666
echo CTCACHE_LOCAL=1 >> "$GITHUB_ENV"
6767
echo CTCACHE_SAVE_OUTPUT=1 >> "$GITHUB_ENV"
6868
echo CTCACHE_DIR='${{github.workspace}}/.ctcache' >> "$GITHUB_ENV"

.github/workflows/macos.yaml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,17 @@ jobs:
6060

6161
- name: Test
6262
timeout-minutes: 5
63-
working-directory: build/tests
64-
run: ctest --output-on-failure
63+
working-directory: build
64+
run: ninja run_all_tests -k 0
65+
66+
- name: Test Summary
67+
if: ${{ !cancelled() }}
68+
uses: test-summary/action@v2
69+
with:
70+
paths: "build/reports/tests/*.junit.xml"
6571

6672
- name: Upload Traces
67-
if: always()
73+
if: ${{ !cancelled() }}
6874
uses: actions/upload-artifact@v4
6975
with:
7076
name: traces-macos

.github/workflows/sonarcloud.yaml

Lines changed: 46 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,26 @@ concurrency:
1818
jobs:
1919
sonarcloud:
2020
name: SonarCloud
21-
runs-on: ubuntu-latest
21+
runs-on: ubuntu-24.04
22+
container: silkeh/clang:18
2223
env:
2324
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
2425
steps:
2526
- uses: actions/checkout@v4
2627
with:
2728
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
2829

29-
- name: Install gcovr
30-
run: pip install gcovr==7.2
31-
32-
- name: Install sonar-scanner and build-wrapper
33-
uses: SonarSource/sonarcloud-github-c-cpp@v3
30+
- name: Install Prerequisites
31+
run: |
32+
apt-get update
33+
apt-get install -y \
34+
ccache \
35+
unzip
3436
3537
- name: Install CMake
36-
uses: lukka/get-cmake@latest
38+
uses: lukka/get-cmake@v3.30.5
3739
with:
38-
cmakeVersion: 3.27.1
40+
cmakeVersion: 3.30.5
3941
ninjaVersion: 1.11.1
4042

4143
- name: Setup CCache
@@ -45,43 +47,62 @@ jobs:
4547
max-size: 100M
4648

4749
- name: Configure CMake
50+
env:
51+
CXXFLAGS: -DNUCLEAR_TEST_TIME_UNIT_DEN=10
4852
run: |
4953
cmake -E make_directory build
5054
cmake -S . -B build \
5155
-GNinja \
52-
-DCMAKE_CXX_FLAGS="--coverage" \
5356
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
5457
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
58+
-DCMAKE_C_COMPILER=clang \
59+
-DCMAKE_CXX_COMPILER=clang++ \
60+
-DCMAKE_BUILD_TYPE=Release \
5561
-DBUILD_TESTS=ON \
56-
-DCMAKE_BUILD_TYPE=Debug \
5762
-DCI_BUILD=ON \
63+
-DENABLE_COVERAGE=ON \
5864
-DENABLE_CLANG_TIDY=OFF
5965
60-
- name: Build the code in debug mode
66+
- name: Build the code
6167
timeout-minutes: 30
62-
run: cmake --build build/ --config Debug
68+
run: cmake --build build/ --config Release
6369

6470
- name: Run tests to generate coverage statistics
6571
timeout-minutes: 10
66-
working-directory: build/tests
67-
run: ctest --output-on-failure
72+
working-directory: build
73+
run: ninja coverage -k 0
6874

69-
- name: Collect coverage into one XML report
70-
if: always()
71-
run: gcovr --gcov-ignore-parse-errors=negative_hits.warn_once_per_file --exclude-unreachable-branches --exclude-noncode-lines --sonarqube > coverage.xml
75+
- name: Test Summary
76+
if: ${{ !cancelled() }}
77+
uses: test-summary/action@v2
78+
with:
79+
paths: "build/reports/tests/*.junit.xml"
7280

73-
- name: Run sonar-scanner
74-
if: always()
81+
- name: Upload coverage report
82+
if: ${{ !cancelled() }}
83+
uses: actions/upload-artifact@v4
84+
with:
85+
name: coverage
86+
path: build/reports/coverage.txt
87+
retention-days: 1 # This sets the artifact TTL to 1 day (minimum is 1 day)
88+
overwrite: true
89+
90+
- name: SonarQube Scan
91+
uses: SonarSource/sonarqube-scan-action@v5
92+
if: ${{ !cancelled() }}
7593
env:
76-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7794
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
78-
run: |
79-
sonar-scanner \
80-
--define sonar.cfamily.compile-commands=build/compile_commands.json \
81-
--define sonar.coverageReportPaths=coverage.xml
95+
with:
96+
args: >
97+
--define sonar.projectKey=Fastcode_NUClear
98+
--define sonar.organization=fastcode
99+
--define sonar.sources=src
100+
--define sonar.tests=tests
101+
--define sonar.cfamily.compile-commands=build/compile_commands.json
102+
--define sonar.cfamily.llvm-cov.reportPath=build/reports/coverage.txt
82103
83104
- name: Upload Traces
84-
if: always()
105+
if: ${{ !cancelled() }}
85106
uses: actions/upload-artifact@v4
86107
with:
87108
name: traces-sonar

.github/workflows/windows.yaml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,17 @@ jobs:
8181

8282
- name: Test
8383
timeout-minutes: 5
84-
working-directory: build/tests
85-
run: ctest --output-on-failure
84+
working-directory: build
85+
run: ninja run_all_tests -k 0
86+
87+
- name: Test Summary
88+
if: ${{ !cancelled() }}
89+
uses: test-summary/action@v2
90+
with:
91+
paths: "build/reports/tests/*.junit.xml"
8692

8793
- name: Upload Traces
88-
if: always()
94+
if: ${{ !cancelled() }}
8995
uses: actions/upload-artifact@v4
9096
with:
9197
name: traces-windows-${{ matrix.toolchain.name }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ tags
2727
docs/doxygen
2828
docs/doxygen_sqlite3.db
2929
*.sublime-workspace
30+
.DS_Store

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
6363
set(MASTER_PROJECT ON)
6464
endif()
6565

66-
# If this option is set we are building using continous integration
66+
# If this option is set we are building using continuous integration
6767
option(CI_BUILD "Enable build options for building in the CI server" OFF)
6868

6969
# Include files to set up the compiler options
@@ -89,6 +89,7 @@ option(BUILD_TESTS "Builds all of the NUClear unit tests." ON)
8989
if(BUILD_TESTS)
9090
enable_testing()
9191
add_subdirectory(tests)
92+
include(TestRunner)
9293
endif()
9394

9495
# Add the documentation subdirectory

cmake/ClangTidy.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Default not to run the clang-tidy checks, default to whatever our CI_BUILD is
22
option(ENABLE_CLANG_TIDY "Enable building with clang-tidy checks.")
33
if(ENABLE_CLANG_TIDY)
4-
# Search for clang-tidy-15 first as this is the version installed in CI
5-
find_program(CLANG_TIDY_EXECUTABLE NAMES clang-tidy-15 clang-tidy)
4+
# Search for the same version of clang-tidy as is used in CI first
5+
find_program(CLANG_TIDY_EXECUTABLE NAMES clang-tidy-19 clang-tidy)
66
if(NOT CLANG_TIDY_EXECUTABLE)
7-
message(FATAL_ERROR "clang-tidy-15 not found.")
7+
message(FATAL_ERROR "clang-tidy not found.")
88
endif()
99

1010
# Report clang-tidy executable details

cmake/TestRunner.cmake

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Collect all currently added targets in all subdirectories
2+
#
3+
# Parameters:
4+
# - _result the list containing all found targets
5+
# - _dir root directory to start looking from
6+
function(get_all_catch_test_targets _result _dir)
7+
get_property(
8+
_subdirs
9+
DIRECTORY "${_dir}"
10+
PROPERTY SUBDIRECTORIES
11+
)
12+
foreach(_subdir IN LISTS _subdirs)
13+
get_all_catch_test_targets(${_result} "${_subdir}")
14+
endforeach()
15+
16+
unset(catch_targets)
17+
get_directory_property(_sub_targets DIRECTORY "${_dir}" BUILDSYSTEM_TARGETS)
18+
foreach(target ${_sub_targets})
19+
get_target_property(target_type ${target} TYPE)
20+
if(target_type STREQUAL "EXECUTABLE")
21+
get_target_property(target_link_libraries ${target} INTERFACE_LINK_LIBRARIES)
22+
if(target_link_libraries MATCHES "Catch2::Catch2")
23+
list(APPEND catch_targets ${target})
24+
endif()
25+
endif()
26+
endforeach()
27+
28+
set(${_result}
29+
${${_result}} ${catch_targets}
30+
PARENT_SCOPE
31+
)
32+
endfunction()
33+
34+
# Find all executable targets that link to Catch2::Catch2WithMain || Catch2::Catch2
35+
get_all_catch_test_targets(all_targets ${PROJECT_SOURCE_DIR})
36+
37+
# Create a custom command for each test target to run it
38+
# Make sure that coverage data is written with paths relative to the source directory
39+
unset(report_outputs)
40+
unset(coverage_reports)
41+
foreach(target ${all_targets})
42+
43+
unset(command_prefix)
44+
if(ENABLE_COVERAGE AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
45+
# Extra output files for the profile data
46+
set(raw_coverage "${PROJECT_BINARY_DIR}/reports/tests/${target}.profraw")
47+
set(indexed_coverage "${PROJECT_BINARY_DIR}/reports/tests/${target}.profdata")
48+
set(coverage_report "${PROJECT_BINARY_DIR}/reports/tests/${target}.txt")
49+
set(command_prefix "cmake" "-E" "env" "LLVM_PROFILE_FILE=${raw_coverage}")
50+
list(APPEND coverage_reports ${coverage_report})
51+
endif()
52+
53+
set(junit_report_file "${PROJECT_BINARY_DIR}/reports/tests/${target}.junit.xml")
54+
list(APPEND report_outputs ${junit_report_file})
55+
add_custom_command(
56+
OUTPUT ${junit_report_file} ${raw_coverage}
57+
COMMAND ${command_prefix} $<TARGET_FILE:${target}> --reporter console --reporter JUnit::out=${junit_report_file}
58+
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
59+
DEPENDS ${target}
60+
USES_TERMINAL
61+
COMMENT "Running test ${target}"
62+
)
63+
64+
if(ENABLE_COVERAGE AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
65+
add_custom_command(
66+
OUTPUT ${indexed_coverage}
67+
COMMAND llvm-profdata merge -sparse ${raw_coverage} -o ${indexed_coverage}
68+
DEPENDS ${raw_coverage}
69+
)
70+
71+
add_custom_command(
72+
OUTPUT ${coverage_report}
73+
COMMAND llvm-cov show --show-branches=count -Xdemangler c++filt -instr-profile=${indexed_coverage}
74+
$<TARGET_FILE:${target}> > ${coverage_report}
75+
DEPENDS ${indexed_coverage}
76+
)
77+
endif()
78+
79+
endforeach()
80+
81+
# Create a custom target that depends on all test targets
82+
add_custom_target(
83+
run_all_tests
84+
DEPENDS ${report_outputs} ${all_targets}
85+
COMMENT "Running all Catch2 tests"
86+
)
87+
88+
# Concatenate all the coverage reports together
89+
if(ENABLE_COVERAGE AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
90+
91+
add_custom_command(
92+
OUTPUT ${PROJECT_BINARY_DIR}/reports/coverage.txt
93+
COMMAND cat ${coverage_reports} > ${PROJECT_BINARY_DIR}/reports/coverage.txt
94+
DEPENDS ${coverage_reports}
95+
)
96+
97+
add_custom_target(
98+
coverage
99+
DEPENDS ${PROJECT_BINARY_DIR}/reports/coverage.txt
100+
COMMENT "Running all Catch2 tests with coverage"
101+
)
102+
103+
endif()

0 commit comments

Comments
 (0)