Skip to content

Commit c361eb3

Browse files
committed
feat: add pre-commit-hooks
1 parent 719c41f commit c361eb3

File tree

5 files changed

+33
-12
lines changed

5 files changed

+33
-12
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
jobs:
1010
tests:
1111
runs-on: ubuntu-latest
12-
steps:
12+
steps:
1313
- name: Checkout code
1414
uses: actions/checkout@v3
1515

@@ -29,7 +29,7 @@ jobs:
2929
make -j
3030
3131
- name: Run tests
32-
run: |
32+
run: |
3333
cd core/build-tests
3434
GTEST_OUTPUT=json:test-results/ ctest
3535
@@ -104,7 +104,7 @@ jobs:
104104
- name: Build and run benchmarks
105105
run: |
106106
bazel build //examples/google_benchmark_bazel:my_benchmark --//core:codspeed_mode=${{ matrix.codspeed-mode }}
107-
107+
108108
- name: Run the benchmarks
109109
uses: CodSpeedHQ/action@main
110110
if: matrix.codspeed-mode != 'off'

.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
@@ -33,8 +33,8 @@ BENCHMARK_TEMPLATE_F(MyTemplatedFixture, IntTest, int)(benchmark::State &st) {
3333
for (auto _ : st) {
3434
}
3535
}
36-
BENCHMARK_TEMPLATE_DEFINE_F(MyTemplatedFixture, DoubleTest,
37-
double)(benchmark::State &st) {
36+
BENCHMARK_TEMPLATE_DEFINE_F(MyTemplatedFixture, DoubleTest, double)
37+
(benchmark::State &st) {
3838
for (auto _ : st) {
3939
}
4040
}
@@ -56,8 +56,8 @@ BENCHMARK_REGISTER_F(MyTemplate1, TestA);
5656

5757
template <typename T, typename U>
5858
class MyTemplate2 : public benchmark::Fixture {};
59-
BENCHMARK_TEMPLATE2_DEFINE_F(MyTemplate2, TestB, int,
60-
double)(benchmark::State &st) {
59+
BENCHMARK_TEMPLATE2_DEFINE_F(MyTemplate2, TestB, int, double)
60+
(benchmark::State &st) {
6161
for (auto _ : st) {
6262
}
6363
}

examples/google_benchmark_cmake/template_bench.hpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,27 @@
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());
1315
}
1416
}
1517
BENCHMARK_TEMPLATE(BM_Template, int);
1618
BENCHMARK_TEMPLATE(BM_Template, std::string);
17-
} // namespace test
19+
} // namespace test
1820

1921
//
2022
//
2123

22-
template <typename T> void BM_Template1(benchmark::State &state) {
24+
template <typename T>
25+
void BM_Template1(benchmark::State &state) {
2326
T val = T();
2427
for (auto _ : state) {
2528
benchmark::DoNotOptimize(val++);
@@ -30,7 +33,8 @@ BENCHMARK_TEMPLATE1(BM_Template1, int);
3033
//
3134
//
3235

33-
template <typename T, typename U> void BM_Template2(benchmark::State &state) {
36+
template <typename T, typename U>
37+
void BM_Template2(benchmark::State &state) {
3438
T t = T();
3539
U u = U();
3640
for (auto _ : state) {

0 commit comments

Comments
 (0)