Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
e381d4c
ci: Add tasks for linting with clang-tidy.
davidlion Jun 9, 2025
6032e98
git mistake
davidlion Jun 9, 2025
1caca4b
Add BufferParser.hpp to exclude list for macos.
davidlion Jun 9, 2025
e4efbfa
Remove check-cmake.
davidlion Jun 9, 2025
d1560fb
Update yaml lint naming.
davidlion Jun 9, 2025
3626dbe
Add ReaderParser.hpp to exclude list for macos.
davidlion Jun 9, 2025
7683363
Merge branch 'main' into clang-tidy
davidlion Jun 9, 2025
aaa4b04
Merge branch 'main' into clang-tidy
davidlion Jul 11, 2025
13f0bd7
Add more files to exclude.
davidlion Jul 11, 2025
7953b1f
Merge branch 'main' into clang-tidy
davidlion Jul 12, 2025
1d2b8e5
Rename lint.yml to lint.yaml.
davidlion Jul 12, 2025
27f5e32
clang-tidy workaround
davidlion Jul 12, 2025
c8fca75
Add sudo.
davidlion Jul 12, 2025
af32abd
Fix to clang-20.
davidlion Jul 12, 2025
1523731
Merge remote-tracking branch 'upstream/main' into clang-tidy
davidlion Jul 16, 2025
02ad628
Build tasks working. Examples tasks need refactor.
davidlion Jul 18, 2025
49f7c25
Refactor examples.
davidlion Jul 22, 2025
b93fb26
Merge remote-tracking branch 'upstream/main' into clang-tidy
davidlion Jul 31, 2025
9c7c838
Update lint.yaml, running with failures.
davidlion Jul 31, 2025
f331277
Bump dev-utils.
davidlion Jul 31, 2025
dbc6663
Build compile_commands for exampels by default.
davidlion Aug 1, 2025
e7e747f
lint task overhaul.
davidlion Aug 1, 2025
da54c57
Fix common files in examples so clang-tidy doesn't fail with all exam…
davidlion Aug 1, 2025
c8ba98c
Fix check-cpp-static-log-surgeon alias.
davidlion Aug 1, 2025
834aea1
Undo yml rename for this PR.
davidlion Aug 1, 2025
158543d
Remove old script.
davidlion Aug 1, 2025
1753510
add uv to workflows.
davidlion Aug 1, 2025
4428af4
Update readme.
davidlion Aug 1, 2025
802911c
Fix args size.
davidlion Aug 1, 2025
0a0e3de
Fix build issue maybe related to clang 20.1.8 vs 20.1.6.
davidlion Aug 1, 2025
9d07d11
autocomplete too lit.
davidlion Aug 1, 2025
3ba6934
Merge remote-tracking branch 'upstream/main' into clang-tidy
davidlion Aug 2, 2025
f25da50
Merge branch 'main' into clang-tidy
davidlion Aug 4, 2025
2698e1d
Fix merge mistake.
davidlion Aug 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
161 changes: 0 additions & 161 deletions .clang-format

This file was deleted.

11 changes: 11 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ jobs:
shell: "bash"
run: "npm install -g @go-task/cli"

- name: "Install uv"
shell: "bash"
run: |-
curl \
--fail \
--location \
--silent \
--show-error \
https://astral.sh/uv/0.8.4/install.sh \
| sh

- name: "Build and run unit tests"
run: "task test:run-${{matrix.build_type}}"

Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,25 @@ jobs:
- name: "Install task"
run: "npm install -g @go-task/cli"

- name: "Install uv"
shell: "bash"
run: |-
curl \
--fail \
--location \
--silent \
--show-error \
https://astral.sh/uv/0.8.4/install.sh \
| sh

# We use clang for linting so CMake doesn't generate compile_commands.json with any gcc
# specific flags that would confuse clang-tidy.
- if: "matrix.os == 'ubuntu-24.04'"
name: "Install clang."
run: |-
curl https://apt.llvm.org/llvm.sh | sudo bash -s -- 20
sudo ln -s /usr/bin/clang-20 /usr/local/bin/cc
sudo ln -s /usr/bin/clang++-20 /usr/local/bin/c++

- name: "Run lint task"
run: "task lint:check"
38 changes: 4 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ Requirements:
* [fmt] >= 8.0.1
* [GSL] >= 4.0.0
* [Task] >= 3.38
* [uv] >= 0.7.10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't match the version being installed. Is it suppose to be 0.8.4?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should reflect the minimum required version to work (uv in-particular is inherited from dev-utils). For CI we just use the latest stable so that we pick up any new changes. Ideally, we tested both sides (minimum and maximum versions), but it is awkward to setup.

Comment on lines 90 to +93
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to reflect the llvm clang-tidy 20 install?


To build and install the project to `$HOME/.local`:

Expand Down Expand Up @@ -153,45 +154,15 @@ is set to true and unit tests are built.
Before submitting a PR, ensure you've run our linting tools and either fixed any violations or
suppressed the warning.

### Requirements

We currently support running our linting tools on Linux and macOS. If you're developing on another
OS, you can submit a [feature request][feature-req]. If you can't run the linting workflows
locally, you can enable and run the [lint] workflow in your fork.

To run the linting tools, besides commonly installed tools like `tar`, you'll need:

* [clang-tidy]
* `md5sum`
* Python 3.8 or newer
* python3-venv
* [Task]

### Setup

```shell
./tools/init.sh
```

### Running the linters

Currently, `clang-tidy` has to be run manually:

```shell
find src tests \
-type f \
\( -iname "*.cpp" -o -iname "*.hpp" \) \
-print0 | \
xargs -0 clang-tidy --config-file .clang-tidy -p build
```

To report all errors run:
To report all errors, run:

```shell
task lint:check
```

To fix cpp errors, and report yaml errors, run:
To automatically fix any supported format or linting errors, run:

```shell
task lint:fix
Expand All @@ -217,9 +188,8 @@ The following are issues we're aware of and working on:

[bug-report]: https://github.com/y-scope/log-surgeon/issues/new?assignees=&labels=bug&template=bug-report.yaml
[Catch2]: https://github.com/catchorg/Catch2/tree/devel
[clang-tidy]: https://clang.llvm.org/extra/clang-tidy/
[feature-req]: https://github.com/y-scope/log-surgeon/issues/new?assignees=&labels=enhancement&template=feature-request.yaml
[fmt]: https://github.com/fmtlib/fmt
[GSL]: https://github.com/microsoft/GSL
[lint]: https://github.com/y-scope/log-surgeon/blob/main/.github/workflows/lint.yaml
[Task]: https://taskfile.dev/
[uv]: https://docs.astral.sh/uv
7 changes: 7 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
cmake_minimum_required(VERSION 3.22.1)
project(log-surgeon-examples)

set(CMAKE_EXPORT_COMPILE_COMMANDS
ON
CACHE BOOL
"Enable/Disable output of compile commands during generation."
FORCE
)

if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(default_build_type "Release")
message(STATUS "No build type specified. Setting to '${default_build_type}'.")
Expand Down
9 changes: 4 additions & 5 deletions examples/buffer-parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
using namespace std;
using namespace log_surgeon;

auto process_logs(string& schema_path, string const& input_path) -> void {
auto process_logs(string const& schema_path, string const& input_path) -> void {
BufferParser parser{schema_path};
optional<uint32_t> loglevel_id{parser.get_variable_id("loglevel")};
if (false == loglevel_id.has_value()) {
Expand Down Expand Up @@ -91,11 +91,10 @@ auto process_logs(string& schema_path, string const& input_path) -> void {
}

auto main(int argc, char* argv[]) -> int {
if (int err{check_input(argc, argv)}; 0 != err) {
std::vector<std::string> const args(argv + 1, argv + argc);
if (int const err{check_input(args)}; 0 != err) {
return err;
}
string schema_path{argv[1]};
string input_path{argv[2]};
process_logs(schema_path, input_path);
process_logs(args[0], args[1]);
return 0;
}
21 changes: 11 additions & 10 deletions examples/common.cpp
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
#include "common.hpp"

#include <cstdint>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <string>
#include <vector>

#include <log_surgeon/LogEvent.hpp>
#include <log_surgeon/Token.hpp>

using namespace std;
using namespace log_surgeon;

auto check_input(int argc, char* argv[]) -> int {
auto check_input(std::vector<std::string> const& args) -> int {
int ret{0};
if (3 != argc) {
if (2 != args.size()) {
ret = 1;
cout << "Not enough arguments." << endl;
} else if (filesystem::path f{argv[1]}; false == filesystem::exists(f)) {
cout << "Not enough arguments.\n";
} else if (filesystem::path const f{args[0]}; false == filesystem::exists(f)) {
ret = 2;
cout << "Schema file does not exist." << endl;
} else if (filesystem::path f{argv[2]}; false == filesystem::exists(f)) {
cout << "Schema file does not exist.\n";
} else if (filesystem::path const f{args[1]}; false == filesystem::exists(f)) {
ret = 3;
cout << "Input file does not exist." << endl;
cout << "Input file does not exist.\n";
}
if (0 != ret) {
cout << "usage: <path to schema file> <path to input log file>" << endl;
cout << "usage: <path to schema file> <path to input log file>\n";
}
return ret;
}
Expand All @@ -45,5 +46,5 @@ auto print_timestamp_loglevel(LogEventView const& event, uint32_t loglevel_id) -
cout << ", loglevel:";
cout << loglevel->to_string_view();
}
cout << endl;
cout << "\n";
}
3 changes: 2 additions & 1 deletion examples/common.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#ifndef COMMON_HPP
#define COMMON_HPP

#include <cstdint>
#include <string>
#include <vector>

#include <log_surgeon/LogEvent.hpp>

auto check_input(int argc, char* argv[]) -> int;
auto check_input(std::vector<std::string> const& args) -> int;

auto print_timestamp_loglevel(log_surgeon::LogEventView const& event, uint32_t loglevel_id) -> void;

Expand Down
9 changes: 4 additions & 5 deletions examples/reader-parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
using namespace std;
using namespace log_surgeon;

auto process_logs(string& schema_path, string const& input_path) -> void {
auto process_logs(string const& schema_path, string const& input_path) -> void {
ReaderParser parser{schema_path};
optional<uint32_t> loglevel_id{parser.get_variable_id("loglevel")};
if (false == loglevel_id.has_value()) {
Expand Down Expand Up @@ -60,11 +60,10 @@ auto process_logs(string& schema_path, string const& input_path) -> void {
}

auto main(int argc, char* argv[]) -> int {
if (int err{check_input(argc, argv)}; 0 != err) {
std::vector<std::string> const args(argv + 1, argv + argc);
if (int const err{check_input(args)}; 0 != err) {
return err;
}
string schema_path{argv[1]};
string input_path{argv[2]};
process_logs(schema_path, input_path);
process_logs(args[0], args[1]);
return 0;
}
Loading
Loading