Skip to content

Add pre-commit config #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .asf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
jira_options: link label link label
2 changes: 1 addition & 1 deletion .github/.licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ header:
- 'LICENSE'
- 'NOTICE'

comment: on-failure
comment: on-failure
1 change: 0 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@ updates:
schedule:
interval: "daily"
open-pull-requests-limit: 10

33 changes: 33 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -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
40 changes: 40 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -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.
limitations under the License.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 2 additions & 2 deletions api/iceberg/puffin.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
namespace iceberg {

class Puffin {
public:
public:
virtual ~Puffin() = default;
virtual std::string_view print() const = 0;
static std::unique_ptr<Puffin> create();
};

} // namespace iceberg
} // namespace iceberg
4 changes: 2 additions & 2 deletions api/iceberg/table.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
namespace iceberg {

class Table {
public:
public:
virtual ~Table() = default;
virtual std::string_view print() const = 0;
static std::unique_ptr<Table> create();
};

} // namespace iceberg
} // namespace iceberg
13 changes: 7 additions & 6 deletions cmake_modules/BuildUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -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 "$<BUILD_INTERFACE:${ARG_SHARED_LINK_LIBS}>"
Expand Down Expand Up @@ -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 "$<INSTALL_INTERFACE:${ARG_STATIC_INSTALL_INTERFACE_LIBS}>")
INTERFACE "$<INSTALL_INTERFACE:${ARG_STATIC_INSTALL_INTERFACE_LIBS}>"
)
endif()

if(ARG_STATIC_LINK_LIBS)
Expand Down
4 changes: 2 additions & 2 deletions example/demo_example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
* under the License.
*/

#include <iostream>

#include "iceberg/puffin.h"
#include "iceberg/table.h"

#include <iostream>

int main() {
std::cout << iceberg::Table::create()->print() << std::endl;
std::cout << iceberg::Puffin::create()->print() << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion src/core/demo_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ std::string_view DemoTable::print() const { return "DemoTable"; }

std::unique_ptr<Table> Table::create() { return std::make_unique<DemoTable>(); }

} // namespace iceberg
} // namespace iceberg
4 changes: 2 additions & 2 deletions src/core/demo_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 2 additions & 4 deletions src/puffin/demo_puffin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ namespace iceberg {

std::string_view DemoPuffin::print() const { return "DemoPuffin"; }

std::unique_ptr<Puffin> Puffin::create() {
return std::make_unique<DemoPuffin>();
}
std::unique_ptr<Puffin> Puffin::create() { return std::make_unique<DemoPuffin>(); }

} // namespace iceberg
} // namespace iceberg
4 changes: 2 additions & 2 deletions src/puffin/demo_puffin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading