diff --git a/.bazelversion b/.bazelversion index 21c8c7b..a8a1887 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -7.1.1 +7.1.2 diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..9b1aeae --- /dev/null +++ b/.editorconfig @@ -0,0 +1,6 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true + diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1a281a5..9da7aac 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,23 +4,31 @@ name: main on: - push: - branches: - - "**" + pull_request: + merge_group: jobs: + typos-check: + name: Typos Check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: crate-ci/typos@v1.19.0 + formatting-check: name: Formatting Check runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: jidicula/clang-format-action@v4.9.0 - with: { clang-format-version: "16" } + - uses: greut/eclint-action@v0 + - uses: jidicula/clang-format-action@v4.11.0 + with: { clang-format-version: "18" } test-windows: + if: github.event_name == 'merge_group' runs-on: windows-latest steps: - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: | /Users/runneradmin/AppData/Local/bazelisk @@ -33,9 +41,10 @@ jobs: working-directory: test test-linux: + if: github.event_name == 'merge_group' runs-on: ubuntu-latest steps: - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: | ~/.cache/bazelisk diff --git a/CHANGELOG.md b/CHANGELOG.md index b884e81..2cc915b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -100,4 +100,4 @@ All notable changes to this project will be documented in this file. See [conven - - - -Changelog generated by [cocogitto](https://github.com/cocogitto/cocogitto). \ No newline at end of file +Changelog generated by [cocogitto](https://github.com/cocogitto/cocogitto). diff --git a/bazel/common.bazelrc b/bazel/common.bazelrc index 50ddd64..2de0b25 100644 --- a/bazel/common.bazelrc +++ b/bazel/common.bazelrc @@ -10,9 +10,6 @@ build --enable_runfiles build --noincompatible_remove_rule_name_parameter query --noincompatible_remove_rule_name_parameter -# Temporary until https://github.com/grailbio/bazel-toolchain/pull/198 is merged -build:linux --extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux - common:ci --announce_rc common:ci --verbose_failures common:ci --keep_going diff --git a/cog.toml b/cog.toml index 9cbba6c..c7d273c 100644 --- a/cog.toml +++ b/cog.toml @@ -1,6 +1,7 @@ pre_bump_hooks = [ # Ecsact pre 1.0.0 the 0.X.0 is our 'major' version "buildozer 'set version {{version}}' 'set compatibility_level {{version.minor}}' //MODULE.bazel:%module", + "bazel mod tidy", ] post_bump_hooks = [ diff --git a/ecsact/interpret/detail/file_eval_error.hh b/ecsact/interpret/detail/file_eval_error.hh index 7d63abb..56b1e62 100644 --- a/ecsact/interpret/detail/file_eval_error.hh +++ b/ecsact/interpret/detail/file_eval_error.hh @@ -8,7 +8,7 @@ namespace ecsact::detail { void check_file_eval_error( - ecsact_eval_error& inout_error, + ecsact_eval_error& in_out_error, ecsact_package_id package_id, ecsact_parse_status status, const ecsact_statement& statement, diff --git a/ecsact/interpret/eval.cc b/ecsact/interpret/eval.cc index 907df95..27beffe 100644 --- a/ecsact/interpret/eval.cc +++ b/ecsact/interpret/eval.cc @@ -89,11 +89,13 @@ static auto statement_param( // template<> auto statement_param( // const ecsact_statement& statement, - std::string_view param_name + std::string_view in_param_name ) -> std::optional { auto result = std::optional{}; for(auto& param : view_statement_params(statement)) { - if(std::string_view{param.name.data, static_cast(param.name.length)} != param_name) { + auto param_name = + std::string_view{param.name.data, static_cast(param.name.length)}; + if(param_name != in_param_name) { continue; } @@ -114,7 +116,10 @@ auto statement_param( // ) -> std::optional { auto result = std::optional{}; for(auto& param : view_statement_params(statement)) { - if(std::string_view{param.name.data, static_cast(param.name.length)} != param_name) { + if(std::string_view{ + param.name.data, + static_cast(param.name.length) + } != param_name) { continue; } @@ -727,7 +732,11 @@ static ecsact_eval_error eval_system_statement( return err; } - if(auto err = allow_statement_params(statement, context, std::array{"lazy"sv, "parallel"sv})) { + if(auto err = allow_statement_params( + statement, + context, + std::array{"lazy"sv, "parallel"sv} + )) { return *err; } @@ -802,7 +811,8 @@ static ecsact_eval_error eval_action_statement( return err; } - if(auto err = allow_statement_params(statement, context, std::array{"parallel"sv})) { + if(auto err = + allow_statement_params(statement, context, std::array{"parallel"sv})) { return *err; } @@ -1757,13 +1767,13 @@ void ecsact_eval_reset() { } void ecsact::detail::check_file_eval_error( - ecsact_eval_error& inout_error, + ecsact_eval_error& in_out_error, ecsact_package_id package_id, ecsact_parse_status status, const ecsact_statement& statement, const std::string& source ) { - assert(inout_error.code == ECSACT_EVAL_OK); + assert(in_out_error.code == ECSACT_EVAL_OK); if(status.code == ECSACT_PARSE_STATUS_BLOCK_END) { if(statement.type == ECSACT_STATEMENT_ACTION) { @@ -1776,8 +1786,8 @@ void ecsact::detail::check_file_eval_error( auto caps = ecsact::meta::system_capabilities(*act_id); if(caps.empty()) { - inout_error.code = ECSACT_EVAL_ERR_NO_CAPABILITIES; - inout_error.relevant_content = { + in_out_error.code = ECSACT_EVAL_ERR_NO_CAPABILITIES; + in_out_error.relevant_content = { .data = source.c_str(), .length = static_cast(source.size()), }; diff --git a/renovate.json b/renovate.json index fa1abeb..25b1be3 100644 --- a/renovate.json +++ b/renovate.json @@ -3,4 +3,4 @@ "extends": [ "github>ecsact-dev/renovate-config" ] -} \ No newline at end of file +} diff --git a/test/comment_before_package.cc b/test/comment_before_package.cc index 6b9ceae..ef91cce 100644 --- a/test/comment_before_package.cc +++ b/test/comment_before_package.cc @@ -1,11 +1,11 @@ - -#include "gtest/gtest.h" -#include "ecsact/interpret/eval.h" - -#include "test_lib.hh" - -TEST(NoPackageStatementFirst, NoPackageStatementFirst) { - auto errs = ecsact_interpret_test_files({"comment_before_package.ecsact"}); - ASSERT_EQ(errs.size(), 0) // - << "Expected no errors. Instead got: " << errs[0].error_message << "\n"; -} + +#include "gtest/gtest.h" +#include "ecsact/interpret/eval.h" + +#include "test_lib.hh" + +TEST(NoPackageStatementFirst, NoPackageStatementFirst) { + auto errs = ecsact_interpret_test_files({"comment_before_package.ecsact"}); + ASSERT_EQ(errs.size(), 0) // + << "Expected no errors. Instead got: " << errs[0].error_message << "\n"; +} diff --git a/test/comment_before_package.ecsact b/test/comment_before_package.ecsact index 7bb5776..b890b13 100644 --- a/test/comment_before_package.ecsact +++ b/test/comment_before_package.ecsact @@ -1,4 +1,4 @@ -// Comments are allowed before the package statement - -package test.comment_before_package; - +// Comments are allowed before the package statement + +package test.comment_before_package; + diff --git a/test/errors/no_package_statement_first.cc b/test/errors/no_package_statement_first.cc index 26c02c1..1941f3b 100644 --- a/test/errors/no_package_statement_first.cc +++ b/test/errors/no_package_statement_first.cc @@ -1,11 +1,11 @@ -#include "gtest/gtest.h" -#include "ecsact/interpret/eval.h" - -#include "test_lib.hh" - -TEST(NoPackageStatementFirst, NoPackageStatementFirst) { - auto errs = - ecsact_interpret_test_files({"errors/no_package_statement_first.ecsact"}); - ASSERT_EQ(errs.size(), 1); - ASSERT_EQ(errs[0].eval_error, ECSACT_EVAL_ERR_EXPECTED_PACKAGE_STATEMENT); -} +#include "gtest/gtest.h" +#include "ecsact/interpret/eval.h" + +#include "test_lib.hh" + +TEST(NoPackageStatementFirst, NoPackageStatementFirst) { + auto errs = + ecsact_interpret_test_files({"errors/no_package_statement_first.ecsact"}); + ASSERT_EQ(errs.size(), 1); + ASSERT_EQ(errs[0].eval_error, ECSACT_EVAL_ERR_EXPECTED_PACKAGE_STATEMENT); +} diff --git a/test/errors/no_package_statement_first.ecsact b/test/errors/no_package_statement_first.ecsact index 26b59ed..cae86e1 100644 --- a/test/errors/no_package_statement_first.ecsact +++ b/test/errors/no_package_statement_first.ecsact @@ -1,7 +1,7 @@ -component ExampleComponent { - f32 num; -} - -// Package statement must be first -package errors.no_pkg_statement_first; - +component ExampleComponent { + f32 num; +} + +// Package statement must be first +package errors.no_pkg_statement_first; + diff --git a/test/errors/unknown_association_field.cc b/test/errors/unknown_association_field.cc index 73f40e3..79484ed 100644 --- a/test/errors/unknown_association_field.cc +++ b/test/errors/unknown_association_field.cc @@ -1,11 +1,11 @@ -#include "gtest/gtest.h" -#include "ecsact/interpret/eval.h" - -#include "test_lib.hh" - -TEST(InterpretError, UnknownAssociationField) { - auto errs = - ecsact_interpret_test_files({"errors/unknown_association_field.ecsact"}); - ASSERT_EQ(errs.size(), 1); - ASSERT_EQ(errs[0].eval_error, ECSACT_EVAL_ERR_FIELD_NAME_ALREADY_EXISTS); -} +#include "gtest/gtest.h" +#include "ecsact/interpret/eval.h" + +#include "test_lib.hh" + +TEST(InterpretError, UnknownAssociationField) { + auto errs = + ecsact_interpret_test_files({"errors/unknown_association_field.ecsact"}); + ASSERT_EQ(errs.size(), 1); + ASSERT_EQ(errs[0].eval_error, ECSACT_EVAL_ERR_FIELD_NAME_ALREADY_EXISTS); +} diff --git a/test/errors/unknown_association_field.ecsact b/test/errors/unknown_association_field.ecsact index aac3e52..ce063eb 100644 --- a/test/errors/unknown_association_field.ecsact +++ b/test/errors/unknown_association_field.ecsact @@ -1,12 +1,12 @@ -package unknown_association_field; - -component ComponentWithAssoc { - entity foo; -} - -system MySystem { - readwrite ComponentWithAssoc with bar { - readwrite ComponentWithAssoc; - } -} - +package unknown_association_field; + +component ComponentWithAssoc { + entity foo; +} + +system MySystem { + readwrite ComponentWithAssoc with bar { + readwrite ComponentWithAssoc; + } +} + diff --git a/test/extra/extra.cc b/test/extra/extra.cc index fa82ba3..da9bada 100644 --- a/test/extra/extra.cc +++ b/test/extra/extra.cc @@ -1,29 +1,29 @@ -#include "gtest/gtest.h" -#include "ecsact/interpret/eval.h" -#include "ecsact/runtime/meta.hh" - -#include "test_lib.hh" - -TEST(MultiPkgTest, NoErrors) { - auto errs = ecsact_interpret_test_files({ - "extra/imported_pkg.ecsact", - "extra/runtime_test.ecsact", - }); - EXPECT_EQ(errs.size(), 0) // - << "Expected no errors. Instead got: " << errs[0].error_message << "\n"; - - EXPECT_EQ(ecsact_meta_count_packages(), 2); - - auto pkg_ids = ecsact::meta::get_package_ids(); - for(auto pkg_id : pkg_ids) { - auto pkg_name = ecsact::meta::package_name(pkg_id); - - if(pkg_name == "runtime_test") { - EXPECT_EQ(ecsact_meta_count_dependencies(pkg_id), 1) // - << "Expected main package to have 3 dependencies. One for each import"; - } else if(pkg_name == "imported.test_pkg") { - } else { - EXPECT_TRUE(false) << "No tests for package: " << pkg_name; - } - } -} +#include "gtest/gtest.h" +#include "ecsact/interpret/eval.h" +#include "ecsact/runtime/meta.hh" + +#include "test_lib.hh" + +TEST(MultiPkgTest, NoErrors) { + auto errs = ecsact_interpret_test_files({ + "extra/imported_pkg.ecsact", + "extra/runtime_test.ecsact", + }); + EXPECT_EQ(errs.size(), 0) // + << "Expected no errors. Instead got: " << errs[0].error_message << "\n"; + + EXPECT_EQ(ecsact_meta_count_packages(), 2); + + auto pkg_ids = ecsact::meta::get_package_ids(); + for(auto pkg_id : pkg_ids) { + auto pkg_name = ecsact::meta::package_name(pkg_id); + + if(pkg_name == "runtime_test") { + EXPECT_EQ(ecsact_meta_count_dependencies(pkg_id), 1) // + << "Expected main package to have 3 dependencies. One for each import"; + } else if(pkg_name == "imported.test_pkg") { + } else { + EXPECT_TRUE(false) << "No tests for package: " << pkg_name; + } + } +} diff --git a/test/extra/imported_pkg.ecsact b/test/extra/imported_pkg.ecsact index 6edc7f3..51b97d5 100644 --- a/test/extra/imported_pkg.ecsact +++ b/test/extra/imported_pkg.ecsact @@ -1,6 +1,6 @@ -package imported.test_pkg; - -component ImportedComponent { - i32 num; -} - +package imported.test_pkg; + +component ImportedComponent { + i32 num; +} + diff --git a/test/multi_pkg.cc b/test/multi_pkg.cc index 002ad97..79d8e94 100644 --- a/test/multi_pkg.cc +++ b/test/multi_pkg.cc @@ -1,36 +1,36 @@ -#include "gtest/gtest.h" -#include "ecsact/interpret/eval.h" -#include "ecsact/runtime/meta.hh" - -#include "test_lib.hh" - -TEST(MultiPkgTest, NoErrors) { - auto errs = ecsact_interpret_test_files({ - "multi_pkg_main.ecsact", - "multi_pkg_a.ecsact", - "multi_pkg_b.ecsact", - "multi_pkg_c.ecsact", - }); - EXPECT_EQ(errs.size(), 0) // - << "Expected no errors. Instead got: " << errs[0].error_message << "\n"; - - EXPECT_EQ(ecsact_meta_count_packages(), 4); - - auto pkg_ids = ecsact::meta::get_package_ids(); - for(auto pkg_id : pkg_ids) { - auto pkg_name = ecsact::meta::package_name(pkg_id); - - if(pkg_name == "example.multipkg") { - EXPECT_EQ(ecsact_meta_count_dependencies(pkg_id), 3) // - << "Expected main package to have 3 dependencies. One for each import"; - } else if(pkg_name == "multi.pkg.a") { - EXPECT_EQ(ecsact_meta_count_components(pkg_id), 1); - } else if(pkg_name == "multi.pkg.b") { - EXPECT_EQ(ecsact_meta_count_components(pkg_id), 1); - } else if(pkg_name == "multi.pkg.c") { - EXPECT_EQ(ecsact_meta_count_components(pkg_id), 1); - } else { - EXPECT_TRUE(false) << "No tests for package: " << pkg_name; - } - } -} +#include "gtest/gtest.h" +#include "ecsact/interpret/eval.h" +#include "ecsact/runtime/meta.hh" + +#include "test_lib.hh" + +TEST(MultiPkgTest, NoErrors) { + auto errs = ecsact_interpret_test_files({ + "multi_pkg_main.ecsact", + "multi_pkg_a.ecsact", + "multi_pkg_b.ecsact", + "multi_pkg_c.ecsact", + }); + EXPECT_EQ(errs.size(), 0) // + << "Expected no errors. Instead got: " << errs[0].error_message << "\n"; + + EXPECT_EQ(ecsact_meta_count_packages(), 4); + + auto pkg_ids = ecsact::meta::get_package_ids(); + for(auto pkg_id : pkg_ids) { + auto pkg_name = ecsact::meta::package_name(pkg_id); + + if(pkg_name == "example.multipkg") { + EXPECT_EQ(ecsact_meta_count_dependencies(pkg_id), 3) // + << "Expected main package to have 3 dependencies. One for each import"; + } else if(pkg_name == "multi.pkg.a") { + EXPECT_EQ(ecsact_meta_count_components(pkg_id), 1); + } else if(pkg_name == "multi.pkg.b") { + EXPECT_EQ(ecsact_meta_count_components(pkg_id), 1); + } else if(pkg_name == "multi.pkg.c") { + EXPECT_EQ(ecsact_meta_count_components(pkg_id), 1); + } else { + EXPECT_TRUE(false) << "No tests for package: " << pkg_name; + } + } +} diff --git a/test/multi_pkg_a.ecsact b/test/multi_pkg_a.ecsact index 0a7da0a..51c291f 100644 --- a/test/multi_pkg_a.ecsact +++ b/test/multi_pkg_a.ecsact @@ -1,6 +1,6 @@ -package multi.pkg.a; - -component FromA { - i32 a; -} - +package multi.pkg.a; + +component FromA { + i32 a; +} + diff --git a/test/multi_pkg_b.ecsact b/test/multi_pkg_b.ecsact index a4b240c..bea3285 100644 --- a/test/multi_pkg_b.ecsact +++ b/test/multi_pkg_b.ecsact @@ -1,3 +1,3 @@ -package multi.pkg.b; - -component FromB; +package multi.pkg.b; + +component FromB; diff --git a/test/multi_pkg_c.ecsact b/test/multi_pkg_c.ecsact index 8f7f589..d8bcdfe 100644 --- a/test/multi_pkg_c.ecsact +++ b/test/multi_pkg_c.ecsact @@ -1,4 +1,4 @@ -package multi.pkg.c; - -component FromC; - +package multi.pkg.c; + +component FromC; + diff --git a/test/multi_pkg_main.ecsact b/test/multi_pkg_main.ecsact index 59fe113..dc79871 100644 --- a/test/multi_pkg_main.ecsact +++ b/test/multi_pkg_main.ecsact @@ -1,21 +1,21 @@ -main package example.multipkg; - -import multi.pkg.a; -import multi.pkg.b; -import multi.pkg.c; - -component FromMain { - i32 m; -} - -system OnlyOne { - readwrite multi.pkg.a.FromA; -} - -system FullyQualifiedFromMain { - include FromMain; - include multi.pkg.a.FromA; - include multi.pkg.b.FromB; - include multi.pkg.c.FromC; -} - +main package example.multipkg; + +import multi.pkg.a; +import multi.pkg.b; +import multi.pkg.c; + +component FromMain { + i32 m; +} + +system OnlyOne { + readwrite multi.pkg.a.FromA; +} + +system FullyQualifiedFromMain { + include FromMain; + include multi.pkg.a.FromA; + include multi.pkg.b.FromB; + include multi.pkg.c.FromC; +} + diff --git a/typos.toml b/typos.toml new file mode 100644 index 0000000..3ffc3da --- /dev/null +++ b/typos.toml @@ -0,0 +1,5 @@ +[files] +extend-exclude = ["CHANGELOG.md"] + +[default] +extend-ignore-re = ["(?Rm)^.*(#|//)\\s*typos:disable-line$"]