From a9d9b673d3db956556c823878321018daae98836 Mon Sep 17 00:00:00 2001 From: Brad Wu <26424577+wusatosi@users.noreply.github.com> Date: Fri, 27 Sep 2024 03:09:45 -0400 Subject: [PATCH 01/28] introduce clang-format --- .clang-format | 241 ++++++++++++++++++++++++++++ include/beman/exemplar/identity.hpp | 8 +- src/beman/exemplar/identity.t.cpp | 26 ++- 3 files changed, 253 insertions(+), 22 deletions(-) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..01d5fac --- /dev/null +++ b/.clang-format @@ -0,0 +1,241 @@ +--- +Language: Cpp +AccessModifierOffset: -2 +AlignAfterOpenBracket: Align +AlignArrayOfStructures: None +AlignConsecutiveAssignments: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + PadOperators: true +AlignConsecutiveBitFields: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + PadOperators: false +AlignConsecutiveDeclarations: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + PadOperators: true +AlignConsecutiveMacros: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + PadOperators: false +AlignConsecutiveShortCaseStatements: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCaseColons: false +AlignEscapedNewlines: Left +AlignOperands: Align +AlignTrailingComments: + Kind: Always + OverEmptyLines: 0 +AllowAllArgumentsOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: Never +AllowShortCaseLabelsOnASingleLine: false +AllowShortEnumsOnASingleLine: true +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: Yes +AttributeMacros: + - __capability +BinPackArguments: false +BinPackParameters: false +BitFieldColonSpacing: Both +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterExternBlock: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakAfterAttributes: Never +BreakAfterJavaFieldAnnotations: false +BreakArrays: true +BreakBeforeBinaryOperators: None +BreakBeforeConceptDeclarations: Always +BreakBeforeBraces: Custom +BreakBeforeInlineASMColon: OnlyMultiline +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeColon +BreakInheritanceList: BeforeColon +BreakStringLiterals: true +ColumnLimit: 119 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: false +DisableFormat: false +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: LogicalBlock +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IfMacros: + - KJ_IF_MAYBE +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + SortPriority: 0 + CaseSensitive: false + - Regex: '^(<|"(gtest|isl|json)/)' + Priority: 3 + SortPriority: 0 + CaseSensitive: false + - Regex: '.*' + Priority: 1 + SortPriority: 0 + CaseSensitive: false +IncludeIsMainRegex: '$' +IncludeIsMainSourceRegex: '' +IndentAccessModifiers: false +IndentCaseBlocks: false +IndentCaseLabels: false +IndentExternBlock: AfterExternBlock +IndentGotoLabels: true +IndentPPDirectives: None +IndentRequiresClause: true +IndentWidth: 4 +IndentWrappedFunctionNames: false +InsertBraces: false +InsertNewlineAtEOF: false +InsertTrailingCommas: None +IntegerLiteralSeparator: + Binary: 0 + BinaryMinDigits: 0 + Decimal: 0 + DecimalMinDigits: 0 + Hex: 0 + HexMinDigits: 0 +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: true +KeepEmptyLinesAtEOF: false +LambdaBodyIndentation: Signature +LineEnding: DeriveLF +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBinPackProtocolList: Auto +ObjCBlockIndentWidth: 4 +ObjCBreakBeforeNestedBlockParam: true +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PackConstructorInitializers: NextLine +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakOpenParenthesis: 0 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyIndentedWhitespace: 0 +PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Left +PPIndentWidth: -1 +QualifierAlignment: Custom +QualifierOrder: + - inline + - static + - constexpr + - const + - volatile + - type +ReferenceAlignment: Pointer +ReflowComments: true +RemoveBracesLLVM: false +RemoveParentheses: Leave +RemoveSemicolon: false +RequiresClausePosition: OwnLine +RequiresExpressionIndentation: OuterScope +SeparateDefinitionBlocks: Leave +ShortNamespaceLines: 1 +SortIncludes: Never +SortJavaStaticImport: Before +SortUsingDeclarations: LexicographicNumeric +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceAroundPointerQualifiers: Default +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeJsonColon: false +SpaceBeforeParens: ControlStatements +SpaceBeforeParensOptions: + AfterControlStatements: true + AfterForeachMacros: true + AfterFunctionDefinitionName: false + AfterFunctionDeclarationName: false + AfterIfMacros: true + AfterOverloadedOperator: false + AfterRequiresInClause: false + AfterRequiresInExpression: false + BeforeNonEmptyParentheses: false +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBlock: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: Never +SpacesInContainerLiterals: true +SpacesInLineCommentPrefix: + Minimum: 1 + Maximum: -1 +SpacesInParens: Never +SpacesInParensOptions: + InCStyleCasts: false + InConditionalStatements: false + InEmptyParentheses: false + Other: false +SpacesInSquareBrackets: false +Standard: Auto +StatementAttributeLikeMacros: + - Q_EMIT +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TabWidth: 8 +UseTab: Never +VerilogBreakBetweenInstancePorts: true +WhitespaceSensitiveMacros: + - STRINGIZE + - PP_STRINGIZE + - BOOST_PP_STRINGIZE + - NS_SWIFT_NAME + - CF_SWIFT_NAME +... diff --git a/include/beman/exemplar/identity.hpp b/include/beman/exemplar/identity.hpp index 0a121eb..789c319 100644 --- a/include/beman/exemplar/identity.hpp +++ b/include/beman/exemplar/identity.hpp @@ -27,16 +27,14 @@ namespace beman::exemplar { struct __is_transparent; // not defined // A function object that returns its argument unchanged. -struct identity -{ +struct identity { // Returns `t`. template #if defined(__cpp_constexpr) constexpr #endif - T && - operator()(T &&t) const noexcept - { + T&& + operator()(T&& t) const noexcept { return std::forward(t); } diff --git a/src/beman/exemplar/identity.t.cpp b/src/beman/exemplar/identity.t.cpp index 64a687c..7f68fdf 100644 --- a/src/beman/exemplar/identity.t.cpp +++ b/src/beman/exemplar/identity.t.cpp @@ -9,51 +9,43 @@ namespace exe = beman::exemplar; -TEST(IdentityTest, call_identity_with_int) -{ - for (int i = -100; i < 100; ++i) - { +TEST(IdentityTest, call_identity_with_int) { + for (int i = -100; i < 100; ++i) { EXPECT_EQ(i, exe::identity()(i)); } } -TEST(IdentityTest, call_identity_with_custom_type) -{ - struct S - { +TEST(IdentityTest, call_identity_with_custom_type) { + struct S { int i; }; - for (int i = -100; i < 100; ++i) - { + for (int i = -100; i < 100; ++i) { const S s{i}; const S s_id = exe::identity()(s); EXPECT_EQ(s.i, s_id.i); } } -TEST(IdentityTest, compare_std_vs_beman) -{ +TEST(IdentityTest, compare_std_vs_beman) { // Requires: std::identity support. #if defined(__cpp_lib_identity) std::identity std_id; exe::identity beman_id; - for (int i = -100; i < 100; ++i) - { + for (int i = -100; i < 100; ++i) { EXPECT_EQ(std_id(i), beman_id(i)); } #endif } -TEST(IdentityTest, check_is_transparent) -{ +TEST(IdentityTest, check_is_transparent) { // Requires: transparent operators support. #if defined(__cpp_lib_transparent_operators) exe::identity id; const auto container = {1, 2, 3, 4, 5}; - auto it = std::find(std::begin(container), std::end(container), 3); + auto it = std::find(std::begin(container), std::end(container), 3); EXPECT_EQ(3, *it); auto it_with_id = std::find(std::begin(container), std::end(container), id(3)); EXPECT_EQ(3, *it_with_id); From 92b62736171fa9fd7692fc555f483ec85f0cdb5e Mon Sep 17 00:00:00 2001 From: Brad Wu <26424577+wusatosi@users.noreply.github.com> Date: Tue, 1 Oct 2024 23:34:14 -0400 Subject: [PATCH 02/28] update format --- examples/identity_as_default_projection.cpp | 37 ++++++--------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/examples/identity_as_default_projection.cpp b/examples/identity_as_default_projection.cpp index a2139b7..eecabac 100644 --- a/examples/identity_as_default_projection.cpp +++ b/examples/identity_as_default_projection.cpp @@ -16,15 +16,13 @@ namespace exe = beman::exemplar; // Class with a pair of values. -struct Pair -{ - int n; +struct Pair { + int n; std::string s; // Output the pair in the form {n, s}. // Used by the range-printer if no custom projection is provided (default: identity projection). - friend std::ostream &operator<<(std::ostream &os, const Pair &p) - { + friend std::ostream& operator<<(std::ostream& os, const Pair& p) { return os << "Pair" << '{' << p.n << ", " << p.s << '}'; } }; @@ -33,37 +31,28 @@ struct Pair // All the elements of the range are printed in the form {element1, element2, ...}. // e.g., pairs with identity: Pair{1, one}, Pair{2, two}, Pair{3, three} // e.g., pairs with custom projection: {1:one, 2:two, 3:three} -template -void print_helper(const std::string_view rem, R &&range, Projection projection) -{ +template +void print_helper(const std::string_view rem, R&& range, Projection projection) { std::cout << rem << '{'; - std::ranges::for_each( - range, - [O = 0](const auto &o) mutable - { std::cout << (O++ ? ", " : "") << o; }, - projection); + std::ranges::for_each(range, [O = 0](const auto& o) mutable { std::cout << (O++ ? ", " : "") << o; }, projection); std::cout << "}\n"; }; // Print wrapper with exe::identity. template // <- Notice the default projection. -void print_beman(const std::string_view rem, R &&range, Projection projection = {}) -{ +void print_beman(const std::string_view rem, R&& range, Projection projection = {}) { print_helper(rem, range, projection); } // Print wrapper with std::identity. template // <- Notice the default projection. -void print_std(const std::string_view rem, R &&range, Projection projection = {}) -{ +void print_std(const std::string_view rem, R&& range, Projection projection = {}) { print_helper(rem, range, projection); } -int main() -{ +int main() { // A vector of pairs to print. const std::vector pairs = { {1, "one"}, @@ -78,12 +67,8 @@ int main() // Print the pairs using a custom projection. std::cout << "Custom projection:\n"; - print_beman("\tpairs with beman: ", pairs, - [](const auto &p) - { return std::to_string(p.n) + ':' + p.s; }); - print_std("\tpairs with std: ", pairs, - [](const auto &p) - { return std::to_string(p.n) + ':' + p.s; }); + print_beman("\tpairs with beman: ", pairs, [](const auto& p) { return std::to_string(p.n) + ':' + p.s; }); + print_std("\tpairs with std: ", pairs, [](const auto& p) { return std::to_string(p.n) + ':' + p.s; }); return 0; } From af300b43891ce3113f5556ccb501ca8dab3278f7 Mon Sep 17 00:00:00 2001 From: Brad Wu <26424577+wusatosi@users.noreply.github.com> Date: Tue, 1 Oct 2024 23:37:26 -0400 Subject: [PATCH 03/28] initalized pre-commit config --- .pre-commit-config.yaml | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..10fbf79 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,41 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + + - repo: local + hooks: + - id: clang-format-fix + name: clang-format-fix + entry: clang-format-18 + files: ^(src/|include/) + types_or: [c++, c] + language: system + args: ['-i'] + stages: [manual] + + - repo: https://github.com/pocc/pre-commit-hooks + rev: v1.3.5 + hooks: + - id: clang-format + additional_dependencies: ['clang-format==18.1.8'] + + - repo: https://github.com/pocc/pre-commit-hooks + rev: v1.3.5 + hooks: + - id: clang-tidy + stages: [manual] + additional_dependencies: ['clang-tidy==18.1.8'] + + - repo: https://github.com/cheshirekow/cmake-format-precommit + rev: "v0.6.13" + hooks: + - id: cmake-format + additional_dependencies: [pyyaml] + - id: cmake-lint From fbace634540019b9d9d60f250636bea998a084da Mon Sep 17 00:00:00 2001 From: Brad Wu <26424577+wusatosi@users.noreply.github.com> Date: Tue, 1 Oct 2024 23:39:04 -0400 Subject: [PATCH 04/28] apply precommit --- .github/CODEOWNERS | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index dd041dd..90d9ff2 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,4 +1,4 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # Codeowners for reviews on PRs -* @bretbrownjr @camio @dietmarkuehl @neatudarius @steve-downey +* @bretbrownjr @camio @dietmarkuehl @neatudarius @steve-downey diff --git a/README.md b/README.md index 66fcbb1..1bdad83 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Implements: `std::identity` proposed in [Standard Library Concepts (P0898R3)](ht ```cpp -#include +#include namespace exe = beman::exemplar; From 7faca742ee20b76133b38a63399066034f275211 Mon Sep 17 00:00:00 2001 From: Brad Wu <26424577+wusatosi@users.noreply.github.com> Date: Tue, 1 Oct 2024 23:40:06 -0400 Subject: [PATCH 05/28] cmake format config --- .cmake-format.json | 85 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 .cmake-format.json diff --git a/.cmake-format.json b/.cmake-format.json new file mode 100644 index 0000000..f5120cc --- /dev/null +++ b/.cmake-format.json @@ -0,0 +1,85 @@ +{ + "parse": { + "additional_commands": { + "foo": { + "flags": [ + "BAR", + "BAZ" + ], + "kwargs": { + "HEADERS": "*", + "SOURCES": "*", + "DEPENDS": "*" + } + } + }, + "override_spec": {}, + "vartags": [], + "proptags": [] + }, + "format": { + "disable": false, + "line_width": 80, + "tab_size": 2, + "use_tabchars": false, + "fractional_tab_policy": "use-space", + "max_subgroups_hwrap": 2, + "max_pargs_hwrap": 6, + "max_rows_cmdline": 2, + "separate_ctrl_name_with_space": false, + "separate_fn_name_with_space": false, + "dangle_parens": false, + "dangle_align": "prefix", + "min_prefix_chars": 4, + "max_prefix_chars": 10, + "max_lines_hwrap": 2, + "line_ending": "unix", + "command_case": "canonical", + "keyword_case": "unchanged", + "always_wrap": [], + "enable_sort": true, + "autosort": false, + "require_valid_layout": false, + "layout_passes": {} + }, + "markup": { + "bullet_char": "*", + "enum_char": ".", + "first_comment_is_literal": false, + "literal_comment_pattern": null, + "fence_pattern": "^\\s*([`~]{3}[`~]*)(.*)$", + "ruler_pattern": "^\\s*[^\\w\\s]{3}.*[^\\w\\s]{3}$", + "explicit_trailing_pattern": "#<", + "hashruler_min_length": 10, + "canonicalize_hashrulers": true, + "enable_markup": true + }, + "lint": { + "disabled_codes": [], + "function_pattern": "[0-9a-z_]+", + "macro_pattern": "[0-9A-Z_]+", + "global_var_pattern": "[A-Z][0-9A-Z_]+", + "internal_var_pattern": "_[A-Z][0-9A-Z_]+", + "local_var_pattern": "[a-z][a-z0-9_]+", + "private_var_pattern": "_[0-9a-z_]+", + "public_var_pattern": "[A-Z][0-9A-Z_]+", + "argument_var_pattern": "[a-z][a-z0-9_]+", + "keyword_pattern": "[A-Z][0-9A-Z_]+", + "max_conditionals_custom_parser": 2, + "min_statement_spacing": 1, + "max_statement_spacing": 2, + "max_returns": 6, + "max_branches": 12, + "max_arguments": 5, + "max_localvars": 15, + "max_statements": 50 + }, + "encode": { + "emit_byteorder_mark": false, + "input_encoding": "utf-8", + "output_encoding": "utf-8" + }, + "misc": { + "per_command": {} + } +} From 08addeb50fcee73135a3e048e4fe466756f6ee62 Mon Sep 17 00:00:00 2001 From: Brad Wu <26424577+wusatosi@users.noreply.github.com> Date: Tue, 1 Oct 2024 23:40:22 -0400 Subject: [PATCH 06/28] format cmake --- examples/CMakeLists.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 60032ff..f3b47fa 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,8 +1,7 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -set(ALL_EXAMPLES - #identity_as_default_projection -identity_direct_usage) +set(ALL_EXAMPLES # identity_as_default_projection + identity_direct_usage) foreach(example ${ALL_EXAMPLES}) add_executable(beman.exemplar.examples.${example}) From 18437bac76280565df0033b703493231d41e313d Mon Sep 17 00:00:00 2001 From: Brad Wu <26424577+wusatosi@users.noreply.github.com> Date: Tue, 1 Oct 2024 23:46:20 -0400 Subject: [PATCH 07/28] add CI --- .github/workflows/pre-commit.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/workflows/pre-commit.yml diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 0000000..084302f --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,13 @@ +name: Lint Check (pre-commit) + +on: + pull_request: + push: + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v3 + - uses: pre-commit/action@v3.0.1 From 524d57c9a82c9002afae49aa038e582d84e9e7a6 Mon Sep 17 00:00:00 2001 From: Brad Wu <26424577+wusatosi@users.noreply.github.com> Date: Wed, 2 Oct 2024 12:23:06 -0400 Subject: [PATCH 08/28] format pre-commit config --- .pre-commit-config.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 10fbf79..8af8859 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,10 +25,6 @@ repos: hooks: - id: clang-format additional_dependencies: ['clang-format==18.1.8'] - - - repo: https://github.com/pocc/pre-commit-hooks - rev: v1.3.5 - hooks: - id: clang-tidy stages: [manual] additional_dependencies: ['clang-tidy==18.1.8'] From aa983d92ddff1f0ce9481e3bf1179b7e9c1542c8 Mon Sep 17 00:00:00 2001 From: Brad Wu <26424577+wusatosi@users.noreply.github.com> Date: Wed, 2 Oct 2024 12:40:29 -0400 Subject: [PATCH 09/28] remove cmake format --- .cmake-format.json | 85 ----------------------------------------- .pre-commit-config.yaml | 6 --- 2 files changed, 91 deletions(-) delete mode 100644 .cmake-format.json diff --git a/.cmake-format.json b/.cmake-format.json deleted file mode 100644 index f5120cc..0000000 --- a/.cmake-format.json +++ /dev/null @@ -1,85 +0,0 @@ -{ - "parse": { - "additional_commands": { - "foo": { - "flags": [ - "BAR", - "BAZ" - ], - "kwargs": { - "HEADERS": "*", - "SOURCES": "*", - "DEPENDS": "*" - } - } - }, - "override_spec": {}, - "vartags": [], - "proptags": [] - }, - "format": { - "disable": false, - "line_width": 80, - "tab_size": 2, - "use_tabchars": false, - "fractional_tab_policy": "use-space", - "max_subgroups_hwrap": 2, - "max_pargs_hwrap": 6, - "max_rows_cmdline": 2, - "separate_ctrl_name_with_space": false, - "separate_fn_name_with_space": false, - "dangle_parens": false, - "dangle_align": "prefix", - "min_prefix_chars": 4, - "max_prefix_chars": 10, - "max_lines_hwrap": 2, - "line_ending": "unix", - "command_case": "canonical", - "keyword_case": "unchanged", - "always_wrap": [], - "enable_sort": true, - "autosort": false, - "require_valid_layout": false, - "layout_passes": {} - }, - "markup": { - "bullet_char": "*", - "enum_char": ".", - "first_comment_is_literal": false, - "literal_comment_pattern": null, - "fence_pattern": "^\\s*([`~]{3}[`~]*)(.*)$", - "ruler_pattern": "^\\s*[^\\w\\s]{3}.*[^\\w\\s]{3}$", - "explicit_trailing_pattern": "#<", - "hashruler_min_length": 10, - "canonicalize_hashrulers": true, - "enable_markup": true - }, - "lint": { - "disabled_codes": [], - "function_pattern": "[0-9a-z_]+", - "macro_pattern": "[0-9A-Z_]+", - "global_var_pattern": "[A-Z][0-9A-Z_]+", - "internal_var_pattern": "_[A-Z][0-9A-Z_]+", - "local_var_pattern": "[a-z][a-z0-9_]+", - "private_var_pattern": "_[0-9a-z_]+", - "public_var_pattern": "[A-Z][0-9A-Z_]+", - "argument_var_pattern": "[a-z][a-z0-9_]+", - "keyword_pattern": "[A-Z][0-9A-Z_]+", - "max_conditionals_custom_parser": 2, - "min_statement_spacing": 1, - "max_statement_spacing": 2, - "max_returns": 6, - "max_branches": 12, - "max_arguments": 5, - "max_localvars": 15, - "max_statements": 50 - }, - "encode": { - "emit_byteorder_mark": false, - "input_encoding": "utf-8", - "output_encoding": "utf-8" - }, - "misc": { - "per_command": {} - } -} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8af8859..989869e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,9 +29,3 @@ repos: stages: [manual] additional_dependencies: ['clang-tidy==18.1.8'] - - repo: https://github.com/cheshirekow/cmake-format-precommit - rev: "v0.6.13" - hooks: - - id: cmake-format - additional_dependencies: [pyyaml] - - id: cmake-lint From a670f87d04ade537454ee30e7ac788966550d8f3 Mon Sep 17 00:00:00 2001 From: Brad Wu <26424577+wusatosi@users.noreply.github.com> Date: Wed, 2 Oct 2024 12:54:48 -0400 Subject: [PATCH 10/28] update ci dependency --- .github/workflows/pre-commit.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 084302f..e33f13a 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -8,6 +8,6 @@ jobs: pre-commit: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 - uses: pre-commit/action@v3.0.1 From bf70eb8541002a03f47e005b80e2b23baf7d6ee8 Mon Sep 17 00:00:00 2001 From: Brad Wu <26424577+wusatosi@users.noreply.github.com> Date: Wed, 2 Oct 2024 12:55:07 -0400 Subject: [PATCH 11/28] format --- .pre-commit-config.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 989869e..9bbe554 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,4 +28,3 @@ repos: - id: clang-tidy stages: [manual] additional_dependencies: ['clang-tidy==18.1.8'] - From 16f2bd3ef7ef95d5e950b63403d3f88ca0192664 Mon Sep 17 00:00:00 2001 From: Brad Wu <26424577+wusatosi@users.noreply.github.com> Date: Wed, 2 Oct 2024 13:07:09 -0400 Subject: [PATCH 12/28] format CMmakeList with gersemi --- CMakeLists.txt | 11 ++++++----- examples/CMakeLists.txt | 9 +++++---- src/beman/exemplar/CMakeLists.txt | 14 ++++++++------ 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 828ed70..9292b52 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,16 +3,17 @@ cmake_minimum_required(VERSION 3.25) project( - beman.exemplar # CMake Project Name, which is also the name of the top-level - # targets (e.g., library, executable, etc.). - DESCRIPTION "A Beman library exemplar" - LANGUAGES CXX) + beman.exemplar # CMake Project Name, which is also the name of the top-level + # targets (e.g., library, executable, etc.). + DESCRIPTION "A Beman library exemplar" + LANGUAGES CXX +) include(CTest) include(FetchContent) if(BUILD_TESTING) - enable_testing() + enable_testing() block() # Disable installing google test dependency on cmake --install diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index f3b47fa..b0c64eb 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,10 +1,11 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception set(ALL_EXAMPLES # identity_as_default_projection - identity_direct_usage) + identity_direct_usage +) foreach(example ${ALL_EXAMPLES}) - add_executable(beman.exemplar.examples.${example}) - target_sources(beman.exemplar.examples.${example} PRIVATE ${example}.cpp) - target_link_libraries(beman.exemplar.examples.${example} beman::exemplar) + add_executable(beman.exemplar.examples.${example}) + target_sources(beman.exemplar.examples.${example} PRIVATE ${example}.cpp) + target_link_libraries(beman.exemplar.examples.${example} beman::exemplar) endforeach() diff --git a/src/beman/exemplar/CMakeLists.txt b/src/beman/exemplar/CMakeLists.txt index da3d195..5a677cc 100644 --- a/src/beman/exemplar/CMakeLists.txt +++ b/src/beman/exemplar/CMakeLists.txt @@ -25,12 +25,14 @@ install( ) if(BUILD_TESTING) - include(GoogleTest) + include(GoogleTest) - add_executable(beman.exemplar.tests) - target_sources(beman.exemplar.tests PRIVATE identity.t.cpp) - target_link_libraries(beman.exemplar.tests - PRIVATE beman::exemplar GTest::gtest GTest::gtest_main) + add_executable(beman.exemplar.tests) + target_sources(beman.exemplar.tests PRIVATE identity.t.cpp) + target_link_libraries( + beman.exemplar.tests + PRIVATE beman::exemplar GTest::gtest GTest::gtest_main + ) - gtest_add_tests(beman.exemplar.tests "" AUTO) + gtest_add_tests(beman.exemplar.tests "" AUTO) endif() From 52871159fc4b25f2307ce0c42f20809d7a9ec086 Mon Sep 17 00:00:00 2001 From: Brad Wu <26424577+wusatosi@users.noreply.github.com> Date: Wed, 2 Oct 2024 13:08:19 -0400 Subject: [PATCH 13/28] use gersemi to format cmake file in precommit --- .pre-commit-config.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9bbe554..3106518 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,3 +28,8 @@ repos: - id: clang-tidy stages: [manual] additional_dependencies: ['clang-tidy==18.1.8'] + + - repo: https://github.com/BlankSpruce/gersemi + rev: 0.15.1 + hooks: + - id: gersemi From f3557fc485517922a656653a38c0a1c3fa662b60 Mon Sep 17 00:00:00 2001 From: Brad Wu <26424577+wusatosi@users.noreply.github.com> Date: Wed, 2 Oct 2024 13:14:11 -0400 Subject: [PATCH 14/28] reformat --- CMakeLists.txt | 28 ++++++++++++++++------------ src/beman/exemplar/CMakeLists.txt | 22 ++++++++++++---------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9292b52..0b48158 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,18 +15,22 @@ include(FetchContent) if(BUILD_TESTING) enable_testing() - block() - # Disable installing google test dependency on cmake --install - set(INSTALL_GTEST OFF) - - # Fetch GoogleTest - FetchContent_Declare( - googletest - GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG f8d7d77c06936315286eb55f8de22cd23c188571 # release-1.14.0 - EXCLUDE_FROM_ALL CMAKE_ARGS -DBUILD_TESTING=OFF) - FetchContent_MakeAvailable(googletest) - endblock() + block() + # Disable installing google test dependency on cmake --install + set(INSTALL_GTEST OFF) + + # Fetch GoogleTest + FetchContent_Declare( + googletest + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG + f8d7d77c06936315286eb55f8de22cd23c188571 # release-1.14.0 + EXCLUDE_FROM_ALL + CMAKE_ARGS + -DBUILD_TESTING=OFF + ) + FetchContent_MakeAvailable(googletest) + endblock() endif() add_subdirectory(src/beman/exemplar) diff --git a/src/beman/exemplar/CMakeLists.txt b/src/beman/exemplar/CMakeLists.txt index 5a677cc..9493be0 100644 --- a/src/beman/exemplar/CMakeLists.txt +++ b/src/beman/exemplar/CMakeLists.txt @@ -8,20 +8,22 @@ target_sources(beman.exemplar PRIVATE identity.cpp) set(INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../include/) target_sources( - beman.exemplar PUBLIC - FILE_SET HEADERS - BASE_DIRS ${INCLUDE_DIR} - FILES ${INCLUDE_DIR}/beman/exemplar/identity.hpp) + beman.exemplar + PUBLIC + FILE_SET HEADERS + BASE_DIRS ${INCLUDE_DIR} + FILES ${INCLUDE_DIR}/beman/exemplar/identity.hpp +) set_target_properties(beman.exemplar PROPERTIES VERIFY_INTERFACE_HEADER_SETS ON) install( - TARGETS beman.exemplar - EXPORT beman.exemplar - DESTINATION $<$:debug/>${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION $<$:debug/>${CMAKE_INSTALL_BINDIR} - FILE_SET HEADERS - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + TARGETS beman.exemplar + EXPORT beman.exemplar + DESTINATION + $<$:debug/>${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION $<$:debug/>${CMAKE_INSTALL_BINDIR} + FILE_SET HEADERS DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) if(BUILD_TESTING) From 7c2ee2821bfe0d36a0f60333b104dc4e3a7353bf Mon Sep 17 00:00:00 2001 From: Brad Wu <26424577+wusatosi@users.noreply.github.com> Date: Wed, 2 Oct 2024 13:43:35 -0400 Subject: [PATCH 15/28] enable auto-formatting --- .pre-commit-config.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3106518..dbb6a86 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,6 +24,7 @@ repos: rev: v1.3.5 hooks: - id: clang-format + args: [-i] additional_dependencies: ['clang-format==18.1.8'] - id: clang-tidy stages: [manual] From 1a35d9f43a10b25f0e09c01c3c4852959b96dbac Mon Sep 17 00:00:00 2001 From: Brad Wu <26424577+wusatosi@users.noreply.github.com> Date: Wed, 2 Oct 2024 14:04:11 -0400 Subject: [PATCH 16/28] add markdown lint --- .pre-commit-config.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index dbb6a86..43bde94 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,3 +34,8 @@ repos: rev: 0.15.1 hooks: - id: gersemi + + - repo: https://github.com/markdownlint/markdownlint + rev: v0.13.0 + hooks: + - id: markdownlint From f7c9136b1a0d3d5194a7c4c1726cb1324d4e498a Mon Sep 17 00:00:00 2001 From: Brad Wu <26424577+wusatosi@users.noreply.github.com> Date: Wed, 2 Oct 2024 14:19:04 -0400 Subject: [PATCH 17/28] switch to igorshubovych/markdownlint-cli --- .pre-commit-config.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 43bde94..80692f3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -35,7 +35,8 @@ repos: hooks: - id: gersemi - - repo: https://github.com/markdownlint/markdownlint - rev: v0.13.0 + - repo: https://github.com/igorshubovych/markdownlint-cli + rev: v0.42.0 hooks: - - id: markdownlint + - id: markdownlint + args: [--disable=MD033] From 42a493f80bdb5d5eea1d13b8cac493d746179fbb Mon Sep 17 00:00:00 2001 From: Brad Wu <26424577+wusatosi@users.noreply.github.com> Date: Wed, 2 Oct 2024 14:35:51 -0400 Subject: [PATCH 18/28] update markdown linter config --- .markdownlint.yaml | 8 ++++++++ .pre-commit-config.yaml | 1 - 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .markdownlint.yaml diff --git a/.markdownlint.yaml b/.markdownlint.yaml new file mode 100644 index 0000000..f1ce63d --- /dev/null +++ b/.markdownlint.yaml @@ -0,0 +1,8 @@ +# MD033/no-inline-html : Inline HTML : https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md033.md +# Disable inline html linter is needed for
+MD033: false + +# MD013/line-length : Line length : https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md013.md +# Conforms to .clang-format ColumnLimit +MD013: + line_length: 120 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 80692f3..638196c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -39,4 +39,3 @@ repos: rev: v0.42.0 hooks: - id: markdownlint - args: [--disable=MD033] From 1ca633837d4ecca08c58fb84c098cff4ed193fef Mon Sep 17 00:00:00 2001 From: Brad Wu <26424577+wusatosi@users.noreply.github.com> Date: Wed, 2 Oct 2024 14:36:50 -0400 Subject: [PATCH 19/28] format README --- README.md | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 1bdad83..443a64f 100644 --- a/README.md +++ b/README.md @@ -6,20 +6,22 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception ![Continuous Integration Tests](https://github.com/beman-project/exemplar/actions/workflows/ci_tests.yml/badge.svg) -`beman.exemplar` is a minimal C++ library conforming to [The Beman Standard](https://github.com/beman-project/beman/blob/main/docs/beman-standard.md). This can be used as a template for those intending to write Beman libraries. It may also find use as a minimal and modern C++ project structure. +`beman.exemplar` is a minimal C++ library conforming to [The Beman Standard](https://github.com/beman-project/beman/blob/main/docs/beman-standard.md). +This can be used as a template for those intending to write Beman libraries. +It may also find use as a minimal and modern C++ project structure. Implements: `std::identity` proposed in [Standard Library Concepts (P0898R3)](https://wg21.link/P0898R3). - ## Usage -`std::identity` is a function object type whose `operator()` returns its argument unchanged. `std::identity` serves as the default projection in constrained algorithms. Its direct usage is usually not needed. +`std::identity` is a function object type whose `operator()` returns its argument unchanged. +`std::identity` serves as the default projection in constrained algorithms. +Its direct usage is usually not needed. ### Usage: default projection in constrained algorithms The following code snippet illustrates how we can achieve a default projection using `beman::exemplar::identity`: - ```cpp #include @@ -131,7 +133,9 @@ apt-get install \ ### How to build beman.exemplar -This project strives to be as normal and simple a CMake project as possible. This build workflow in particular will work, producing a static `libbeman.exemplar.a` library, ready to package with its headers: +This project strives to be as normal and simple a CMake project as possible. +This build workflow in particular will work, +producing a static `libbeman.exemplar.a` library, ready to package with its headers: ```shell cmake -B build -S . -DCMAKE_CXX_STANDARD=20 @@ -231,7 +235,8 @@ $ tree /opt/beman.exemplar
Disable tests build -To build this project with tests disabled (and their dependencies), simply use `BUILD_TESTING=OFF` as documented in upstream [CMake documentation](https://cmake.org/cmake/help/latest/module/CTest.html): +To build this project with tests disabled (and their dependencies), +simply use `BUILD_TESTING=OFF` as documented in upstream [CMake documentation](https://cmake.org/cmake/help/latest/module/CTest.html): ```shell cmake -B build -S . -DBUILD_TESTING=OFF @@ -245,7 +250,8 @@ cmake -B build -S . -DBUILD_TESTING=OFF Use beman.exemplar directly from C++ -If you want to use `beman.exemplar` from your project, you can include `beman/exemplar/*.hpp` files from your C++ source files +If you want to use `beman.exemplar` from your project, +you can include `beman/exemplar/*.hpp` files from your C++ source files ```cpp #include @@ -273,7 +279,8 @@ For CMake based projects, you will need to use the `beman.exemplar` CMake module find_package(beman.exemplar REQUIRED) ``` -You will also need to add `beman::exemplar` to the link libraries of any libraries or executables that include `beman/exemplar/*.hpp` in their source or header file. +You will also need to add `beman::exemplar` +to the link libraries of any libraries or executables that include `beman/exemplar/*.hpp` in their source or header file. ```cmake target_link_libraries(yourlib PUBLIC beman::exemplar) @@ -286,7 +293,8 @@ target_link_libraries(yourlib PUBLIC beman::exemplar) -Build systems that support `pkg-config` by providing a `beman.exemplar.pc` file. Build systems that support interoperation via `pkg-config` should be able to detect `beman.exemplar` for you automatically. +Build systems that support `pkg-config` by providing a `beman.exemplar.pc` file. +Build systems that support interoperation via `pkg-config` should be able to detect `beman.exemplar` for you automatically.
From b2f109a20186a8271adce45f35e368639334c764 Mon Sep 17 00:00:00 2001 From: Brad Wu <26424577+wusatosi@users.noreply.github.com> Date: Wed, 2 Oct 2024 14:39:54 -0400 Subject: [PATCH 20/28] remove duplicative clang-format --- .pre-commit-config.yaml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 638196c..99b11d7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,17 +9,6 @@ repos: - id: check-yaml - id: check-added-large-files - - repo: local - hooks: - - id: clang-format-fix - name: clang-format-fix - entry: clang-format-18 - files: ^(src/|include/) - types_or: [c++, c] - language: system - args: ['-i'] - stages: [manual] - - repo: https://github.com/pocc/pre-commit-hooks rev: v1.3.5 hooks: From 92bc20c449756b2de2b060d2d4cedadcc51e9cb7 Mon Sep 17 00:00:00 2001 From: Brad Wu <26424577+wusatosi@users.noreply.github.com> Date: Wed, 2 Oct 2024 14:45:21 -0400 Subject: [PATCH 21/28] add more documentation --- .pre-commit-config.yaml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 99b11d7..96e03fb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,21 +9,29 @@ repos: - id: check-yaml - id: check-added-large-files + # Clang-format and Clang-tidy for C++ + # WARN: repo may not maintained anymore since 2021. - repo: https://github.com/pocc/pre-commit-hooks rev: v1.3.5 hooks: - id: clang-format - args: [-i] + args: [-i] # in-place formatting additional_dependencies: ['clang-format==18.1.8'] - id: clang-tidy + # Currently disabled, see: + # https://github.com/beman-project/exemplar/pull/34#discussion_r1784958937 stages: [manual] additional_dependencies: ['clang-tidy==18.1.8'] + # CMake linting and formatting - repo: https://github.com/BlankSpruce/gersemi rev: 0.15.1 hooks: - id: gersemi + name: CMake linting + # Markdown linting + # Config file: .markdownlint.yaml - repo: https://github.com/igorshubovych/markdownlint-cli rev: v0.42.0 hooks: From fc4d919a02a4f43b9e335ae623a80bb035c1f592 Mon Sep 17 00:00:00 2001 From: Brad Wu <26424577+wusatosi@users.noreply.github.com> Date: Wed, 2 Oct 2024 15:25:27 -0400 Subject: [PATCH 22/28] using more up-to-date clang-format config --- .pre-commit-config.yaml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 96e03fb..f6d09b0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,14 +9,20 @@ repos: - id: check-yaml - id: check-added-large-files - # Clang-format and Clang-tidy for C++ + # Clang-format for C++ + # This brings in a portable version of clang-format. + # See also: https://github.com/ssciwr/clang-format-wheel + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: v18.1.8 + hooks: + - id: clang-format + types_or: [c++, c] + + # Clang-tidy for C++ # WARN: repo may not maintained anymore since 2021. - repo: https://github.com/pocc/pre-commit-hooks rev: v1.3.5 hooks: - - id: clang-format - args: [-i] # in-place formatting - additional_dependencies: ['clang-format==18.1.8'] - id: clang-tidy # Currently disabled, see: # https://github.com/beman-project/exemplar/pull/34#discussion_r1784958937 From 381ddaab74299b93cca5ef8640414eb80738a477 Mon Sep 17 00:00:00 2001 From: River <26424577+wusatosi@users.noreply.github.com> Date: Tue, 8 Oct 2024 16:45:38 -0400 Subject: [PATCH 23/28] Update .pre-commit-config.yaml Co-authored-by: David Sankel --- .pre-commit-config.yaml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f6d09b0..049fccf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,17 +18,6 @@ repos: - id: clang-format types_or: [c++, c] - # Clang-tidy for C++ - # WARN: repo may not maintained anymore since 2021. - - repo: https://github.com/pocc/pre-commit-hooks - rev: v1.3.5 - hooks: - - id: clang-tidy - # Currently disabled, see: - # https://github.com/beman-project/exemplar/pull/34#discussion_r1784958937 - stages: [manual] - additional_dependencies: ['clang-tidy==18.1.8'] - # CMake linting and formatting - repo: https://github.com/BlankSpruce/gersemi rev: 0.15.1 From 28891547b9cbb865497324cc8c41afbd54747909 Mon Sep 17 00:00:00 2001 From: River <26424577+wusatosi@users.noreply.github.com> Date: Mon, 14 Oct 2024 16:21:47 -0400 Subject: [PATCH 24/28] update pre-commit version --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 049fccf..a26bab0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.2.0 + rev: v5.0.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer From fd520c46a3d02c721c0baa8a027a537b5ade7666 Mon Sep 17 00:00:00 2001 From: River <26424577+wusatosi@users.noreply.github.com> Date: Mon, 14 Oct 2024 16:29:36 -0400 Subject: [PATCH 25/28] update CI --- .github/workflows/pre-commit.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index e33f13a..b612eed 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -10,4 +10,15 @@ jobs: steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 - - uses: pre-commit/action@v3.0.1 + with: + python-version: '3.13' + + - name: Get Changed Files + id: changed-files + uses: tj-actions/changed-files@v45 + + # See: + # https://github.com/tj-actions/changed-files?tab=readme-ov-file#using-local-git-directory- + - uses: pre-commit/action@v3 + with: + extra_args: --files ${{ steps.changed-files.outputs.all_changed_files }} From 663e9e29061676b6bab929716782ea573914eb21 Mon Sep 17 00:00:00 2001 From: River <26424577+wusatosi@users.noreply.github.com> Date: Mon, 14 Oct 2024 16:52:17 -0400 Subject: [PATCH 26/28] revert breaking change in CI --- .github/workflows/pre-commit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index b612eed..57492d8 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -19,6 +19,6 @@ jobs: # See: # https://github.com/tj-actions/changed-files?tab=readme-ov-file#using-local-git-directory- - - uses: pre-commit/action@v3 + - uses: pre-commit/action@v3.0.1 with: extra_args: --files ${{ steps.changed-files.outputs.all_changed_files }} From 16db8111b28501873afac542fe29dba54576c2ea Mon Sep 17 00:00:00 2001 From: River <26424577+wusatosi@users.noreply.github.com> Date: Mon, 14 Oct 2024 20:02:17 -0400 Subject: [PATCH 27/28] reformat directory --- .github/workflows/ci_tests.yml | 8 ++++---- CMakeLists.txt | 27 ++++++++++++++------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index 84602e7..dfc7998 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -75,20 +75,20 @@ jobs: needs: [test] if: failure() && github.event_name == 'schedule' steps: - # See https://github.com/cli/cli/issues/5075 + # See https://github.com/cli/cli/issues/5075 - uses: actions/checkout@v4 - name: Create issue run: | issue_num=$(gh issue list -s open -S "[SCHEDULED-BUILD] Build & Test failure" -L 1 --json number | jq 'if length == 0 then -1 else .[0].number end') - + body="**Build-and-Test Failure Report** - **Time of Failure**: $(date -u '+%B %d, %Y, %H:%M %Z') - **Commit**: [${{ github.sha }}](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}) - **Action Run**: [View logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - + The scheduled build-and-test triggered by cron has failed. Please investigate the logs and recent changes associated with this commit or rerun the workflow if you believe this is an error." - + if [[ $issue_num -eq -1 ]]; then gh issue create --repo ${{ github.repository }} --title "[SCHEDULED-BUILD] Build & Test failure" --body "$body" else diff --git a/CMakeLists.txt b/CMakeLists.txt index df15799..546b1b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,20 +13,21 @@ include(CTest) include(FetchContent) if(BUILD_TESTING) - enable_testing() + enable_testing() - # Fetch GoogleTest - FetchContent_Declare( - googletest - GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG f8d7d77c06936315286eb55f8de22cd23c188571 # release-1.14.0 - EXCLUDE_FROM_ALL - ) - block() - set(INSTALL_GTEST OFF) # Disable GoogleTest installation - set(BUILD_TESTING OFF) # Disable GoogleTest tests - FetchContent_MakeAvailable(googletest) - endblock() + # Fetch GoogleTest + FetchContent_Declare( + googletest + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG + f8d7d77c06936315286eb55f8de22cd23c188571 # release-1.14.0 + EXCLUDE_FROM_ALL + ) + block() + set(INSTALL_GTEST OFF) # Disable GoogleTest installation + set(BUILD_TESTING OFF) # Disable GoogleTest tests + FetchContent_MakeAvailable(googletest) + endblock() endif() add_subdirectory(src/beman/exemplar) From d6ace405b74e40008b67f7c14ea2b07be49b8d04 Mon Sep 17 00:00:00 2001 From: River <26424577+wusatosi@users.noreply.github.com> Date: Mon, 14 Oct 2024 20:08:55 -0400 Subject: [PATCH 28/28] update doc on ColumnLimit --- .clang-format | 1 + .markdownlint.yaml | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.clang-format b/.clang-format index 01d5fac..05baf03 100644 --- a/.clang-format +++ b/.clang-format @@ -85,6 +85,7 @@ BreakBeforeTernaryOperators: true BreakConstructorInitializers: BeforeColon BreakInheritanceList: BeforeColon BreakStringLiterals: true +# Please update .markdownlint.yaml if this line is to be updated ColumnLimit: 119 CommentPragmas: '^ IWYU pragma:' CompactNamespaces: false diff --git a/.markdownlint.yaml b/.markdownlint.yaml index f1ce63d..81f5fcd 100644 --- a/.markdownlint.yaml +++ b/.markdownlint.yaml @@ -4,5 +4,6 @@ MD033: false # MD013/line-length : Line length : https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md013.md # Conforms to .clang-format ColumnLimit +# Update the comment in .clang-format if we no-longer tie these two column limits. MD013: - line_length: 120 + line_length: 119