Skip to content

Commit 716347f

Browse files
paldepindCopilot
andcommitted
C++: Add BMN CI and developer guidance
Run Cargo and Bazel checks when the build-mode-none extractor changes, integrate its Rust lint into pre-commit, and document the standalone development workflow. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent c1aa041 commit 716347f

3 files changed

Lines changed: 77 additions & 22 deletions

File tree

‎.github/workflows/cpp-bmn.yml‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: C/C++ build mode none extractor
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "cpp/extractor/bmn/**"
7+
- "misc/bazel/3rdparty/cpp_bmn_deps/**"
8+
- "misc/bazel/3rdparty/cpp_bmn_deps_extension.bzl"
9+
- "misc/bazel/3rdparty/update_cpp_bmn_deps.sh"
10+
- "misc/bazel/3rdparty/BUILD.bazel"
11+
- "misc/bazel/rust.bzl"
12+
- "MODULE.bazel"
13+
- ".github/workflows/cpp-bmn.yml"
14+
push:
15+
branches:
16+
- main
17+
- "rc/*"
18+
paths:
19+
- "cpp/extractor/bmn/**"
20+
- "misc/bazel/3rdparty/cpp_bmn_deps/**"
21+
- "misc/bazel/3rdparty/cpp_bmn_deps_extension.bzl"
22+
- "misc/bazel/3rdparty/update_cpp_bmn_deps.sh"
23+
- "misc/bazel/3rdparty/BUILD.bazel"
24+
- "misc/bazel/rust.bzl"
25+
- "MODULE.bazel"
26+
- ".github/workflows/cpp-bmn.yml"
27+
28+
permissions:
29+
contents: read
30+
31+
jobs:
32+
cargo:
33+
runs-on: ubuntu-latest
34+
defaults:
35+
run:
36+
working-directory: cpp/extractor/bmn
37+
steps:
38+
- uses: actions/checkout@v5
39+
- name: Check formatting
40+
run: cargo fmt --check
41+
- name: Check
42+
run: cargo check
43+
- name: Clippy
44+
run: cargo clippy -- -D warnings
45+
- name: Test
46+
run: cargo test
47+
48+
bazel:
49+
runs-on: ubuntu-latest
50+
steps:
51+
- uses: actions/checkout@v5
52+
- name: Build
53+
run: bazel build //cpp/extractor/bmn:bmn
54+
- name: Test
55+
run: bazel test //cpp/extractor/bmn:tests

‎.pre-commit-config.yaml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,10 @@ repos:
8585
language: system
8686
entry: python3 rust/lint.py
8787
pass_filenames: false
88+
89+
- id: cpp-bmn-lint
90+
name: Run fmt and clippy on C/C++ BMN Rust code
91+
files: ^cpp/extractor/bmn/(.*rs|Cargo.toml)$
92+
language: system
93+
entry: cpp/extractor/bmn/lint --check
94+
pass_filenames: false

‎cpp/extractor/bmn/README.md‎

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,26 @@
1-
# C/C++ BMN
1+
# C/C++ build mode none extractor
22

3-
## Running in a container
3+
This directory contains the C/C++ build mode none (BMN) extractor. It scans a
4+
source tree and heuristically constructs extraction commands without observing
5+
a build.
46

5-
When dependency installation is enabled BMN assumes that it's running on Ubuntu
6-
and runs `sudo apt-get` to install packages.
7+
Run the Rust checks with:
78

8-
The `create-database-in-container.sh` script makes it possible to create
9-
databases in an Ubuntu container. This makes it possible to create databases on
10-
non-Ubuntu OSes and without dependencies being installed globally on the host
11-
OS.
12-
13-
### Prerequisites
14-
15-
- **SSH agent with GitHub access**: The container build clones the `semmle-code`
16-
repository via SSH. Ensure your SSH agent is running and has a key with access
17-
to `git@github.com:github/semmle-code.git`:
18-
```sh
19-
eval $(ssh-agent)
20-
ssh-add ~/.ssh/your_github_key
21-
```
9+
```sh
10+
./lint --check
11+
cargo test
12+
```
2213

23-
### Usage
14+
Build and test the Bazel target from the repository root with:
2415

2516
```sh
26-
./container/create-database-in-container.sh ~/projects/my-cpp-project /tmp/my-database
17+
bazel build //cpp/extractor/bmn:bmn
18+
bazel test //cpp/extractor/bmn:tests
2719
```
2820

29-
To enable automatic dependency installation (runs `apt-get` inside the container):
21+
After changing Cargo dependencies, regenerate the checked-in Bazel dependency
22+
definitions with:
3023

3124
```sh
32-
./container/create-database-in-container.sh --install-dependencies ~/projects/my-cpp-project /tmp/my-database
25+
misc/bazel/3rdparty/update_cpp_bmn_deps.sh
3326
```

0 commit comments

Comments
 (0)