Skip to content

Commit 16c0efb

Browse files
committed
feat: add pre-commit-hooks
1 parent 7e537b6 commit 16c0efb

File tree

5 files changed

+38
-9
lines changed

5 files changed

+38
-9
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ on:
77
workflow_dispatch:
88

99
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: pre-commit/action@v3.0.1
15+
with:
16+
extra_args: --all-files
17+
1018
tests:
1119
runs-on: ubuntu-latest
1220
steps:

.pre-commit-config.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
exclude: '^(google_benchmark/.*|core/instrument-hooks/.*|.*/build/.*|build/.*|core/include/valgrind\.h|core/include/callgrind\.h)'
4+
files: ^(core|examples)/.*$
5+
6+
repos:
7+
- repo: https://github.com/pre-commit/pre-commit-hooks
8+
rev: v4.5.0
9+
hooks:
10+
- id: trailing-whitespace
11+
- id: end-of-file-fixer
12+
- id: check-added-large-files
13+
- repo: https://github.com/cpp-linter/cpp-linter-hooks
14+
rev: v0.6.1
15+
hooks:
16+
- id: clang-format
17+
files: \.(cpp|cc|cxx|h|hpp)$

core/src/utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ std::string safe_getenv(const char* var_name);
1010

1111
} // namespace codspeed
1212

13-
#endif // CODSPEED_UTILS_H
13+
#endif // CODSPEED_UTILS_H

examples/google_benchmark_cmake/fixture_bench.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ BENCHMARK_TEMPLATE_F(MyTemplatedFixture, IntTest, int)(benchmark::State &st) {
3636
benchmark::ClobberMemory();
3737
}
3838
}
39-
BENCHMARK_TEMPLATE_DEFINE_F(MyTemplatedFixture, DoubleTest,
40-
double)(benchmark::State &st) {
39+
BENCHMARK_TEMPLATE_DEFINE_F(MyTemplatedFixture, DoubleTest, double)
40+
(benchmark::State &st) {
4141
for (auto _ : st) {
4242
benchmark::ClobberMemory();
4343
}
@@ -61,8 +61,8 @@ BENCHMARK_REGISTER_F(MyTemplate1, TestA);
6161

6262
template <typename T, typename U>
6363
class MyTemplate2 : public benchmark::Fixture {};
64-
BENCHMARK_TEMPLATE2_DEFINE_F(MyTemplate2, TestB, int,
65-
double)(benchmark::State &st) {
64+
BENCHMARK_TEMPLATE2_DEFINE_F(MyTemplate2, TestB, int, double)
65+
(benchmark::State &st) {
6666
for (auto _ : st) {
6767
benchmark::ClobberMemory();
6868
}

examples/google_benchmark_cmake/template_bench.hpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
#define TEMPLATE_BENCH_HPP
33

44
#include <benchmark/benchmark.h>
5+
56
#include <cstring>
67
#include <string>
78

89
namespace test {
9-
template <class T> void BM_Template(benchmark::State &state) {
10+
template <class T>
11+
void BM_Template(benchmark::State &state) {
1012
std::vector<T> v;
1113
for (auto _ : state) {
1214
v.push_back(T());
@@ -16,12 +18,13 @@ template <class T> void BM_Template(benchmark::State &state) {
1618
}
1719
BENCHMARK_TEMPLATE(BM_Template, int);
1820
BENCHMARK_TEMPLATE(BM_Template, std::string);
19-
} // namespace test
21+
} // namespace test
2022

2123
//
2224
//
2325

24-
template <typename T> void BM_Template1(benchmark::State &state) {
26+
template <typename T>
27+
void BM_Template1(benchmark::State &state) {
2528
T val = T();
2629
for (auto _ : state) {
2730
benchmark::DoNotOptimize(val++);
@@ -32,7 +35,8 @@ BENCHMARK_TEMPLATE1(BM_Template1, int);
3235
//
3336
//
3437

35-
template <typename T, typename U> void BM_Template2(benchmark::State &state) {
38+
template <typename T, typename U>
39+
void BM_Template2(benchmark::State &state) {
3640
T t = T();
3741
U u = U();
3842
for (auto _ : state) {

0 commit comments

Comments
 (0)