Skip to content

Commit 49aa293

Browse files
committed
Add a single foss project to test rules on in ci
1 parent e5fe33b commit 49aa293

4 files changed

Lines changed: 112 additions & 3 deletions

File tree

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ jobs:
1818
- name: Checkout repository
1919
uses: actions/checkout@v4
2020

21-
- name: Set bazel version to 6.5.0
22-
run: echo "6.5.0" > .bazelversion
23-
2421
- name: Setup Bazel
2522
uses: bazel-contrib/setup-bazel@0.15.0
2623

@@ -48,3 +45,52 @@ jobs:
4845
"CodeChecker finds different analyzers when running in " \
4946
"bazel's sandbox environment!"
5047
CodeChecker analyzers
48+
49+
# TODO: Move installation of tools to a composite action (or use a docker img)
50+
# TODO: Generalize to handle multiple projects
51+
# TODO: Add script to run tests locally
52+
# TODO: Document how to add new project to the list.
53+
foss_test:
54+
name: "Test rules on FOSS project: yaml-cpp"
55+
runs-on: ubuntu-24.04
56+
57+
steps:
58+
- name: Checkout repository
59+
uses: actions/checkout@v4
60+
61+
- name: Set bazel version to 6.5.0
62+
run: echo "6.5.0" > .bazelversion
63+
64+
- name: Setup Bazel
65+
uses: bazel-contrib/setup-bazel@0.15.0
66+
67+
- name: Install python
68+
uses: actions/setup-python@v5
69+
with:
70+
python-version: '3.12'
71+
72+
- name: Install CodeChecker analyzers
73+
run: |
74+
sudo apt-get update --quiet
75+
sudo apt-get install --no-install-recommends \
76+
clang \
77+
clang-tools \
78+
clang-tidy
79+
80+
- name: Install CodeChecker
81+
run: pip3 install codechecker
82+
83+
- name: Setup yaml-cpp
84+
run: |
85+
cd test/foss/yaml-cpp
86+
sh init.sh
87+
88+
- name: Run Bazel CodeChecker
89+
run: |
90+
cd test/foss/yaml-cpp/test-proj
91+
bazel build :codechecker_test
92+
93+
- name: Run Per-File Bazel CodeChecker
94+
run: |
95+
cd test/foss/yaml-cpp/test-proj
96+
bazel build :code_checker_test

test/foss/templates/.bazelversion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6.5.0
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#----------------------------------------------------
2+
3+
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
4+
5+
local_repository(
6+
name = "bazel_codechecker",
7+
path = "../../../../",
8+
)
9+
10+
load(
11+
"@bazel_codechecker//src:tools.bzl",
12+
"register_default_codechecker",
13+
"register_default_python_toolchain",
14+
)
15+
16+
register_default_python_toolchain()
17+
18+
register_default_codechecker()
19+
20+
#----------------------------------------------------

test/foss/yaml-cpp/init.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
git clone --recurse https://github.com/jbeder/yaml-cpp.git test-proj
3+
cd test-proj
4+
git checkout yaml-cpp-0.7.0
5+
6+
# This file must be in the root of the project to be analyzed for bazelisk to work
7+
cp ../../templates/.bazelversion ./.bazelversion
8+
9+
# Add codechecker to the project
10+
cat <<EOF >> BUILD.bazel
11+
#-------------------------------------------------------
12+
13+
# codechecker rules
14+
load(
15+
"@bazel_codechecker//src:codechecker.bzl",
16+
"codechecker_test",
17+
)
18+
load(
19+
"@bazel_codechecker//src:code_checker.bzl",
20+
"code_checker_test",
21+
)
22+
23+
24+
codechecker_test(
25+
name = "codechecker_test",
26+
targets = [
27+
":yaml-cpp",
28+
],
29+
)
30+
31+
code_checker_test(
32+
name = "code_checker_test",
33+
targets = [
34+
":yaml-cpp",
35+
],
36+
)
37+
38+
#-------------------------------------------------------
39+
EOF
40+
41+
# Add codechecker_bazel repo to WORKSPACE
42+
cat ../../templates/WORKSPACE.template >> WORKSPACE

0 commit comments

Comments
 (0)