diff --git a/.asf.yaml b/.asf.yaml index d4892f834..66a492ebc 100644 --- a/.asf.yaml +++ b/.asf.yaml @@ -45,4 +45,4 @@ notifications: commits: commits@iceberg.apache.org issues: issues@iceberg.apache.org pullrequests: issues@iceberg.apache.org - jira_options: link label link label \ No newline at end of file + jira_options: link label link label diff --git a/.github/.licenserc.yaml b/.github/.licenserc.yaml index fb6f014aa..75545a5a0 100644 --- a/.github/.licenserc.yaml +++ b/.github/.licenserc.yaml @@ -12,4 +12,4 @@ header: - 'LICENSE' - 'NOTICE' - comment: on-failure \ No newline at end of file + comment: on-failure diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 74dc5aa5e..2cc471df7 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -23,4 +23,3 @@ updates: schedule: interval: "daily" open-pull-requests-limit: 10 - diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 000000000..f640e4fc2 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,33 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +name: pre-commit + +on: + pull_request: + push: + branches: + - '**' + - '!dependabot/**' + +jobs: + pre-commit: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v3 + - uses: pre-commit/action@v3.0.1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..94e2fa268 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,40 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# To use this, install the python package `pre-commit` and +# run once `pre-commit install`. This will setup a git pre-commit-hook +# that is executed on each commit and will report the linting problems. +# To run all hooks on all files use `pre-commit run -a` + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: v19.1.5 + hooks: + - id: clang-format + + - repo: https://github.com/cheshirekow/cmake-format-precommit + rev: v0.6.10 + hooks: + - id: cmake-format diff --git a/LICENSE b/LICENSE index f49a4e16e..261eeb9e9 100644 --- a/LICENSE +++ b/LICENSE @@ -198,4 +198,4 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and - limitations under the License. \ No newline at end of file + limitations under the License. diff --git a/README.md b/README.md index 81966cac7..56cedaf73 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,17 @@ Apache Iceberg is an active open-source project, governed under the Apache Softw The Apache Iceberg community is built on the principles described in the [Apache Way](https://www.apache.org/theapacheway/index.html) and all who engage with the community are expected to be respectful, open, come with the best interests of the community in mind, and abide by the Apache Foundation [Code of Conduct](https://www.apache.org/foundation/policies/conduct.html). +### Linting + +Install the python package `pre-commit` and run once `pre-commit install`. + +``` +pip install pre-commit +pre-commit install +``` + +This will setup a git pre-commit-hook that is executed on each commit and will report the linting problems. To run all hooks on all files use `pre-commit run -a`. + ## License Licensed under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) diff --git a/api/iceberg/puffin.h b/api/iceberg/puffin.h index b9b5f193e..b3dc8f7d4 100644 --- a/api/iceberg/puffin.h +++ b/api/iceberg/puffin.h @@ -25,10 +25,10 @@ namespace iceberg { class Puffin { -public: + public: virtual ~Puffin() = default; virtual std::string_view print() const = 0; static std::unique_ptr create(); }; -} // namespace iceberg +} // namespace iceberg diff --git a/api/iceberg/table.h b/api/iceberg/table.h index 93f6a0f95..f06e336b5 100644 --- a/api/iceberg/table.h +++ b/api/iceberg/table.h @@ -25,10 +25,10 @@ namespace iceberg { class Table { -public: + public: virtual ~Table() = default; virtual std::string_view print() const = 0; static std::unique_ptr create(); }; -} // namespace iceberg +} // namespace iceberg diff --git a/cmake_modules/BuildUtils.cmake b/cmake_modules/BuildUtils.cmake index 416f59ceb..4d6bf1db0 100644 --- a/cmake_modules/BuildUtils.cmake +++ b/cmake_modules/BuildUtils.cmake @@ -22,7 +22,8 @@ function(iceberg_install_cmake_package PACKAGE_NAME EXPORT_NAME) set(CONFIG_CMAKE "${PACKAGE_NAME}Config.cmake") set(BUILT_CONFIG_CMAKE "${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_CMAKE}") configure_package_config_file("${CONFIG_CMAKE}.in" "${BUILT_CONFIG_CMAKE}" - INSTALL_DESTINATION "${ICEBERG_INSTALL_CMAKEDIR}/${PACKAGE_NAME}") + INSTALL_DESTINATION "${ICEBERG_INSTALL_CMAKEDIR}/${PACKAGE_NAME}" + ) set(CONFIG_VERSION_CMAKE "${PACKAGE_NAME}ConfigVersion.cmake") set(BUILT_CONFIG_VERSION_CMAKE "${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_VERSION_CMAKE}") write_basic_package_version_file("${BUILT_CONFIG_VERSION_CMAKE}" @@ -137,8 +138,8 @@ function(ADD_ICEBERG_LIB LIB_NAME) endif() set_target_properties(${LIB_NAME}_shared - PROPERTIES LINK_FLAGS "${ARG_SHARED_LINK_FLAGS}" - OUTPUT_NAME ${LIB_NAME}) + PROPERTIES LINK_FLAGS "${ARG_SHARED_LINK_FLAGS}" OUTPUT_NAME + ${LIB_NAME}) target_link_libraries(${LIB_NAME}_shared PUBLIC "$" @@ -187,12 +188,12 @@ function(ADD_ICEBERG_LIB LIB_NAME) set(LIB_NAME_STATIC ${LIB_NAME}) endif() - set_target_properties(${LIB_NAME}_static - PROPERTIES OUTPUT_NAME ${LIB_NAME_STATIC}) + set_target_properties(${LIB_NAME}_static PROPERTIES OUTPUT_NAME ${LIB_NAME_STATIC}) if(ARG_STATIC_INSTALL_INTERFACE_LIBS) target_link_libraries(${LIB_NAME}_static - INTERFACE "$") + INTERFACE "$" + ) endif() if(ARG_STATIC_LINK_LIBS) diff --git a/example/demo_example.cc b/example/demo_example.cc index 4f35bd30a..99d4bcf47 100644 --- a/example/demo_example.cc +++ b/example/demo_example.cc @@ -17,11 +17,11 @@ * under the License. */ +#include + #include "iceberg/puffin.h" #include "iceberg/table.h" -#include - int main() { std::cout << iceberg::Table::create()->print() << std::endl; std::cout << iceberg::Puffin::create()->print() << std::endl; diff --git a/src/core/demo_table.cc b/src/core/demo_table.cc index 628ee2560..5c9d52141 100644 --- a/src/core/demo_table.cc +++ b/src/core/demo_table.cc @@ -25,4 +25,4 @@ std::string_view DemoTable::print() const { return "DemoTable"; } std::unique_ptr
Table::create() { return std::make_unique(); } -} // namespace iceberg +} // namespace iceberg diff --git a/src/core/demo_table.h b/src/core/demo_table.h index f68f9ac1d..3a8604cf8 100644 --- a/src/core/demo_table.h +++ b/src/core/demo_table.h @@ -24,11 +24,11 @@ namespace iceberg { class DemoTable : public Table { -public: + public: DemoTable() = default; ~DemoTable() override = default; std::string_view print() const override; }; -} // namespace iceberg +} // namespace iceberg diff --git a/src/puffin/demo_puffin.cc b/src/puffin/demo_puffin.cc index 12e8ddf35..a4fe7a0d4 100644 --- a/src/puffin/demo_puffin.cc +++ b/src/puffin/demo_puffin.cc @@ -23,8 +23,6 @@ namespace iceberg { std::string_view DemoPuffin::print() const { return "DemoPuffin"; } -std::unique_ptr Puffin::create() { - return std::make_unique(); -} +std::unique_ptr Puffin::create() { return std::make_unique(); } -} // namespace iceberg +} // namespace iceberg diff --git a/src/puffin/demo_puffin.h b/src/puffin/demo_puffin.h index b5cfffcf9..a03649b60 100644 --- a/src/puffin/demo_puffin.h +++ b/src/puffin/demo_puffin.h @@ -24,11 +24,11 @@ namespace iceberg { class DemoPuffin : public Puffin { -public: + public: DemoPuffin() = default; ~DemoPuffin() override = default; std::string_view print() const override; }; -} // namespace iceberg +} // namespace iceberg