-
Notifications
You must be signed in to change notification settings - Fork 132
73 lines (71 loc) · 2.7 KB
/
linting.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# ns-3 CI/CD script with jobs of the code-linting stage
#
# Contains jobs to perform lint checking.
name: "Check code linting"
run-name: "linting"
on:
workflow_call:
workflow_dispatch:
jobs:
# Clang-tidy
clang-tidy-18:
runs-on: ubuntu-latest
container:
image: ubuntu:rolling
timeout-minutes: 180
env:
CLANG_TIDY_OUTPUT: clang-tidy-output.log
CI_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
steps:
# The following step is required in all jobs that use this repo's actions
- name: "Retrieve actions from repository"
uses: actions/checkout@v4
with:
sparse-checkout: .github/actions
- name: "Install required system packages"
run: >
apt update && DEBIAN_FRONTEND=noninteractive apt install -y
clang cmake
clang-tidy clang-tidy-18
git wget
- name: "Checkout this repository as ns-3 module"
uses: ./.github/actions/checkout-in-ns3
- name: "Configure ns-3 CMake"
run: >
./ns3 configure -d debug
--enable-clang-tidy
--enable-examples --enable-tests --enable-asserts
--enable-modules lorawan
- name: "Prepare git environment"
run: >
if (git -C src/lorawan/ remote | grep -qw upstream) ; then
git -C src/lorawan/ remote remove upstream ;
fi &&
git -C src/lorawan/ remote add -t $CI_DEFAULT_BRANCH --no-tags -f upstream https://github.com/signetlabdei/lorawan.git
- name: "Running clang-tidy"
shell: bash
run: >
if [[ $GITHUB_REF_NAME == $CI_DEFAULT_BRANCH ]] ; then
echo "Running full clang-tidy" ;
run-clang-tidy-18 -p cmake-cache/ -quiet "src\/lorawan\/.+\.(cpp|cc|cxx|c|h|hpp)"
1> $CLANG_TIDY_OUTPUT
2> /dev/null ;
else
echo "Running clang-tidy-diff" ;
git -C src/lorawan/ diff -U0 upstream/$CI_DEFAULT_BRANCH --src-prefix=a/src/lorawan/ --dst-prefix=b/src/lorawan/ |
clang-tidy-diff-18.py -path cmake-cache/ -p1 -quiet -use-color -iregex "src\/lorawan\/.+\.(cpp|cc|cxx|c|h|hpp)"
1> $CLANG_TIDY_OUTPUT
2> /dev/null || true ;
fi
- name: "Trim empty lines from output file"
run: sed -i '/^$/d' $CLANG_TIDY_OUTPUT
- name: "Check job results"
run: |
(! egrep -v "file not found \[clang-diagnostic-error\]" $CLANG_TIDY_OUTPUT | egrep -A3 "error:|warning:|note:")
echo "No clang-tidy errors found"
- if: failure()
name: "Upload clang-tidy-output.log"
uses: actions/upload-artifact@v4
with:
name: ${{ env.CLANG_TIDY_OUTPUT }}
path: ${{ env.CLANG_TIDY_OUTPUT }}