Skip to content

Commit e81ce25

Browse files
committed
Upload clang-tidy report only if findings are found
Create an id for the clang-tidy step and use its outcome to decide if uploading the clang-tidy report is necessary. Added some options of the clang-tidy script as required. Changed a name of a method used in the unit tests of uds. Fixed typo on practices.rst
1 parent 6b7e65e commit e81ce25

5 files changed

Lines changed: 9 additions & 5 deletions

File tree

.ci/clang-tidy.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,14 @@ def parse_arguments():
4141
"--build_directory",
4242
type=Path,
4343
help="Path to the build directory containing compile_commands.json generated by CMake",
44+
required=True,
4445
)
4546

4647
parser.add_argument(
4748
"--output_file",
4849
type=str,
4950
help="Path to the output YAML file where clang-tidy findings will be stored",
51+
required=True,
5052
)
5153

5254
parser.add_argument(

.github/workflows/clang-tidy.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,15 @@ jobs:
4040
run: >-
4141
DOCKER_UID=$(id -u) DOCKER_GID=$(id -g) DOCKER_HISTORY=/dev/null docker compose run --rm development
4242
python3 .ci/build.py --preset ${{ matrix.preset }} --platform "linux" --cxxid "clang" --cxxstd "14" --config "${{ matrix.config }}"
43+
4344
- name: Run the clang-tidy.py inside the docker container
45+
id: clang-tidy
4446
run: >-
4547
DOCKER_UID=$(id -u) DOCKER_GID=$(id -g) DOCKER_HISTORY=/dev/null docker compose run --rm development
4648
python3 .ci/clang-tidy.py --build_directory=build/tests/${{ matrix.platform }}/${{ matrix.config }} --output_file=ct-findings.yaml --exclude="3rdparty" --ignore-checks="clang-diagnostic-error"
4749
4850
- name: Upload clang-tidy findings
49-
if: always()
51+
if: ${{ steps.clang_tidy.outcome == 'failure' }}
5052
uses: actions/upload-artifact@v4
5153
with:
5254
name: ct-findings-${{ matrix.platform }}-${{ matrix.config }}

doc/dev/guidelines/practices.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Clang-tidy
1212

1313
Additionally, most of these practices are enforced by clang-tidy which is run as part of our CI pipeline.
1414
The clang-tidy configuration can be found in the file ``.clang-tidy`` in the root directory of openbsw repository.
15-
The ci script for running clang-tidy is located in ``.ci/clang-tidy.py``, which runs an llvm helper tool called
15+
The CI script for running clang-tidy is located in ``.ci/clang-tidy.py``, which runs an llvm helper tool called
1616
``run-clang-tidy`` which checks all compilation units specified in a compile_commands.json file, which is generated by
1717
current CMake configurations.
1818
In case you want to run the llvm helper tool ``run-clang-tidy`` locally, you can use the dev container in the root

libs/bsw/uds/include/uds/base/AbstractDiagJob.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class AbstractDiagJob : public ::etl::uncopyable
159159
}
160160

161161
#ifdef UNIT_TEST
162-
static void unsetDiagSession() { sfpSessionManager = nullptr; }
162+
static void unsetDiagSessionManager() { sfpSessionManager = nullptr; }
163163

164164
virtual ~AbstractDiagJob() {}
165165
#endif

libs/bsw/uds/test/src/uds/base/AbstractDiagJobTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,15 +287,15 @@ TEST_F(
287287
AbstractDiagJobTest,
288288
getDiagSessionManager_calls_an_exception_if_a_sessionManager_does_not_exist)
289289
{
290-
AbstractDiagJob::unsetDiagSession();
290+
AbstractDiagJob::unsetDiagSessionManager();
291291
ASSERT_THROW(fTestableDiagJob.getDiagSessionManager(), ::etl::exception);
292292
}
293293

294294
TEST_F(
295295
AbstractDiagJobTest,
296296
const_getDiagSessionManager_calls_an_exception_if_a_sessionManager_does_not_exist)
297297
{
298-
AbstractDiagJob::unsetDiagSession();
298+
AbstractDiagJob::unsetDiagSessionManager();
299299
TestableDiagJob const diagJob(IMPLEMENTED_REQUEST, sizeof(IMPLEMENTED_REQUEST), 0U, 0U, 1U);
300300

301301
ASSERT_THROW(diagJob.getDiagSessionManager(), ::etl::exception);

0 commit comments

Comments
 (0)