Skip to content

Commit 81e8877

Browse files
Add job to check formatting on CI
Relates-To: MINOR
1 parent 7d33c0b commit 81e8877

2 files changed

Lines changed: 70 additions & 0 deletions

File tree

.github/workflows/psv_pipelines.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,3 +273,23 @@ jobs:
273273
- name: Commit checker script. Verify commit text
274274
run: scripts/misc/commit_checker.sh
275275
shell: bash
276+
277+
psv-formatting-checker:
278+
name: PSV.Clang.Format.Checker
279+
runs-on: ubuntu-22.04
280+
env:
281+
BUILD_TYPE: RelWithDebInfo
282+
CC: gcc-9
283+
CXX: g++-9
284+
steps:
285+
- name: Check out repository
286+
uses: actions/checkout@v4
287+
- name: "C++ Lint checker script"
288+
run: ./scripts/misc/cpplint_ci.sh
289+
shell: bash
290+
- name: Install Ubuntu dependencies
291+
run: sudo apt-get update && sudo apt-get install -y libboost-all-dev ccache libssl-dev libcurl4-openssl-dev gcc-9 g++-9 --no-install-recommends
292+
shell: bash
293+
- name: Compile project with cmake and ccache
294+
run: gcc --version && ./scripts/linux/psv/build_psv.sh
295+
shell: bash

scripts/misc/clang_format_ci.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
#
3+
# Copyright (C) 2025 HERE Europe B.V.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
# SPDX-License-Identifier: Apache-2.0
18+
# License-Filename: LICENSE
19+
#
20+
21+
# Important 2 lines
22+
set +e
23+
set -x
24+
25+
# This script gets the changed files in the pull request, and runs
26+
# cpplint tool to verify them
27+
28+
# Get the current branch name
29+
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
30+
31+
if [[ $CURRENT_BRANCH == "master" ]]; then
32+
printf "Currently in master branch, skipping cpplint.\n"
33+
exit 0
34+
else
35+
printf "Currently in %s branch. Running cpplint.\n" "$CURRENT_BRANCH"
36+
fi
37+
38+
git branch --all
39+
git fetch origin master
40+
git branch --all
41+
# Get affected files and filter source files
42+
FILES=$(git diff-tree --no-commit-id --name-only -r origin/master "$CURRENT_BRANCH" \
43+
| grep '\.c\|\.cpp\|\.cxx\|\.h\|\.hpp\|\.hxx')
44+
45+
if [ -z "$FILES" ]; then
46+
printf "No affected files, exiting.\n"
47+
exit 0
48+
else
49+
printf "Affected files:\n %s\n" "$FILES"
50+
fi

0 commit comments

Comments
 (0)