From 7965bb184393d41aca51bc4061c8d72283153a6c Mon Sep 17 00:00:00 2001 From: "F.Tibor" Date: Mon, 28 Jul 2025 10:46:41 +0200 Subject: [PATCH 1/6] Add unittests to CI --- .github/workflows/test.yml | 44 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 25003648..b8cdc251 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -48,3 +48,47 @@ jobs: "CodeChecker finds different analyzers when running in " \ "bazel's sandbox environment!" CodeChecker analyzers + + unit_test: + name: Unit Test + runs-on: ubuntu-24.04 + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set bazel version to 6.5.0 + run: echo "6.5.0" > .bazelversion + + - name: Setup Bazel + uses: bazel-contrib/setup-bazel@0.15.0 + + - name: Install python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Install CodeChecker analyzers + run: | + sudo apt-get update --quiet + sudo apt-get install --no-install-recommends \ + clang \ + clang-tools \ + clang-tidy + + - name: Install CodeChecker + run: pip3 install codechecker + + - name: Print versions + run: | + bazel version + CodeChecker version + echo "[NOTE]: If you are debugging, its possible that " \ + "CodeChecker finds different analyzers when running in " \ + "bazel's sandbox environment!" + CodeChecker analyzers + + - name: Run tests + run: | + cd test + python3 test.py -vvv From 3d469cde48b9621fa1002810801e0f7c5f1f3a89 Mon Sep 17 00:00:00 2001 From: "F.Tibor" Date: Mon, 28 Jul 2025 11:01:47 +0200 Subject: [PATCH 2/6] Remove stat flag --- test/BUILD | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/BUILD b/test/BUILD index ccd08940..6ba0500c 100644 --- a/test/BUILD +++ b/test/BUILD @@ -134,7 +134,6 @@ codechecker_test( name = "codechecker_pass", analyze = [ "--ctu", - "--stats", ], config = "codechecker_config_json", targets = [ @@ -260,7 +259,6 @@ code_checker_test( name = "code_checker_pass", options = [ "--ctu", - "--stats", ], targets = [ "test_pass", @@ -284,7 +282,6 @@ code_checker_test( name = "code_checker_ctu", options = [ "--ctu", - "--stats", ], tags = [ "manual", From b1c3fc9c3c922bfdca7256503e45db4e96c7252e Mon Sep 17 00:00:00 2001 From: "F.Tibor" Date: Mon, 28 Jul 2025 11:07:50 +0200 Subject: [PATCH 3/6] Ensure that extdef mapping is available through command clang-extdef-mapping --- .github/workflows/test.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b8cdc251..18f85ac9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,6 +36,11 @@ jobs: clang \ clang-tools \ clang-tidy + sudo update-alternatives --install \ + /usr/bin/clang-extdef-mapping \ + clang-extdef-mapping \ + /usr/bin/clang-extdef-mapping-$(clang --version | head -n 1 | sed -E 's/.*version ([0-9]+)\..*/\1/') \ + 100 - name: Install CodeChecker run: pip3 install codechecker @@ -75,6 +80,11 @@ jobs: clang \ clang-tools \ clang-tidy + sudo update-alternatives --install \ + /usr/bin/clang-extdef-mapping \ + clang-extdef-mapping \ + /usr/bin/clang-extdef-mapping-$(clang --version | head -n 1 | sed -E 's/.*version ([0-9]+)\..*/\1/') \ + 100 - name: Install CodeChecker run: pip3 install codechecker From 1c321e3cd2c456a155bb5727375ff576dba05e08 Mon Sep 17 00:00:00 2001 From: "F.Tibor" Date: Tue, 29 Jul 2025 08:09:03 +0200 Subject: [PATCH 4/6] Merge jobs, comment code --- .github/workflows/test.yml | 52 +++++--------------------------------- 1 file changed, 7 insertions(+), 45 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 18f85ac9..51e4d41c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,54 +36,16 @@ jobs: clang \ clang-tools \ clang-tidy + # clang-extdef-mapping is only available through + # clang-extdef-mapping-18 by default, but during ctu analysis + # we use it without version number (see clang_ctu.bzl). + # The sed command, extracts the version number from clang + # it reads the number from the word version to the first decimal point. sudo update-alternatives --install \ /usr/bin/clang-extdef-mapping \ clang-extdef-mapping \ - /usr/bin/clang-extdef-mapping-$(clang --version | head -n 1 | sed -E 's/.*version ([0-9]+)\..*/\1/') \ - 100 - - - name: Install CodeChecker - run: pip3 install codechecker - - - name: Print versions - run: | - bazel version - CodeChecker version - echo "[NOTE]: If you are debugging, its possible that " \ - "CodeChecker finds different analyzers when running in " \ - "bazel's sandbox environment!" - CodeChecker analyzers - - unit_test: - name: Unit Test - runs-on: ubuntu-24.04 - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set bazel version to 6.5.0 - run: echo "6.5.0" > .bazelversion - - - name: Setup Bazel - uses: bazel-contrib/setup-bazel@0.15.0 - - - name: Install python - uses: actions/setup-python@v5 - with: - python-version: '3.12' - - - name: Install CodeChecker analyzers - run: | - sudo apt-get update --quiet - sudo apt-get install --no-install-recommends \ - clang \ - clang-tools \ - clang-tidy - sudo update-alternatives --install \ - /usr/bin/clang-extdef-mapping \ - clang-extdef-mapping \ - /usr/bin/clang-extdef-mapping-$(clang --version | head -n 1 | sed -E 's/.*version ([0-9]+)\..*/\1/') \ + /usr/bin/clang-extdef-mapping-$(clang --version | head -n 1 | + sed -E 's/.*version ([0-9]+)\..*/\1/') \ 100 - name: Install CodeChecker From 88f66f3c7dc7ae5e825bc7f861c3091eab388e88 Mon Sep 17 00:00:00 2001 From: "F.Tibor" Date: Tue, 29 Jul 2025 10:59:55 +0200 Subject: [PATCH 5/6] Reword comment --- .github/workflows/test.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 51e4d41c..352d94b2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,11 +36,11 @@ jobs: clang \ clang-tools \ clang-tidy - # clang-extdef-mapping is only available through - # clang-extdef-mapping-18 by default, but during ctu analysis - # we use it without version number (see clang_ctu.bzl). - # The sed command, extracts the version number from clang - # it reads the number from the word version to the first decimal point. + # The default naming of the clang-extdef-mapping, needed for CTU, is + # installed by clang-tools also contains the major version + # (e.g. clang-extdef-mapping-18), but the bazel rules reference it + # without the version number. To this end, we use update-alternatives + # to rename the binary to omit it. sudo update-alternatives --install \ /usr/bin/clang-extdef-mapping \ clang-extdef-mapping \ From 60bd33838e34ab2dceb0977a73a4f03fd4c6bf26 Mon Sep 17 00:00:00 2001 From: "F.Tibor" Date: Tue, 29 Jul 2025 11:04:03 +0200 Subject: [PATCH 6/6] Rename job --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 352d94b2..b20213bb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ concurrency: jobs: rules_test: - name: Analysis + name: Unit tests runs-on: ubuntu-24.04 steps: @@ -47,6 +47,7 @@ jobs: /usr/bin/clang-extdef-mapping-$(clang --version | head -n 1 | sed -E 's/.*version ([0-9]+)\..*/\1/') \ 100 + - name: Install CodeChecker run: pip3 install codechecker