This is an automated email from the ASF dual-hosted git repository. kou pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/arrow-flight-sql-postgresql.git
The following commit(s) were added to refs/heads/main by this push: new 0196e6c Add format lint CI (#45) 0196e6c is described below commit 0196e6cf22a9ad48188331e1c03e775cbb70bc43 Author: Sutou Kouhei <k...@clear-code.com> AuthorDate: Mon Aug 7 16:56:45 2023 +0900 Add format lint CI (#45) Closes GH-44 --- .cmake-format.yaml => .cmake-format.py | 4 ++-- .github/workflows/lint.yaml | 13 +++++++++++++ .cmake-format.yaml => .pre-commit-config.yaml | 11 +++++++++-- CMakeLists.txt | 19 ------------------- benchmark/integer/select.c | 16 ++++++++-------- src/afs.cc | 9 ++++++--- 6 files changed, 38 insertions(+), 34 deletions(-) diff --git a/.cmake-format.yaml b/.cmake-format.py similarity index 93% copy from .cmake-format.yaml copy to .cmake-format.py index f9d5551..7b0413c 100644 --- a/.cmake-format.yaml +++ b/.cmake-format.py @@ -15,5 +15,5 @@ # specific language governing permissions and limitations # under the License. -markup: - first_comment_is_literal: true +with section("markup"): + first_comment_is_literal = True diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 48f6b0e..57eede9 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -38,3 +38,16 @@ jobs: python-version: '3.x' - name: Run Release audit tool (Rat) run: dev/release/run_rat.sh . + + format: + name: Format + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: '3.x' + - name: Run pre-commit + run: | + python -m pip install pre-commit + pre-commit run --show-diff-on-failure --color=always --all-files diff --git a/.cmake-format.yaml b/.pre-commit-config.yaml similarity index 76% rename from .cmake-format.yaml rename to .pre-commit-config.yaml index f9d5551..8f98c48 100644 --- a/.cmake-format.yaml +++ b/.pre-commit-config.yaml @@ -15,5 +15,12 @@ # specific language governing permissions and limitations # under the License. -markup: - first_comment_is_literal: true +repos: + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: "v15.0.7" + hooks: + - id: clang-format + - repo: https://github.com/cheshirekow/cmake-format-precommit + rev: v0.6.13 + hooks: + - id: cmake-format diff --git a/CMakeLists.txt b/CMakeLists.txt index 665651e..9baee7c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,25 +29,6 @@ include(GNUInstallDirs) set(AFS_SOURCES src/afs.cc) -add_custom_target(format) -# Ubuntu 20.04 ships clang-format-12. -find_program(CLANG_FORMAT clang-format-12) -if(CLANG_FORMAT) - add_custom_target( - format-source - ${CLANG_FORMAT} -i ${AFS_SOURCES} - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) - add_dependencies(format format-source) -endif() -find_program(CMAKE_FORMAT cmake-format) -if(CMAKE_FORMAT) - add_custom_target( - format-cmake - ${CMAKE_FORMAT} --in-place CMakeLists.txt - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) - add_dependencies(format format-cmake) -endif() - set(AFS_POSTGRESQL_DIR "${CMAKE_INSTALL_PREFIX}" CACHE PATH "PostgreSQL binary directory") diff --git a/benchmark/integer/select.c b/benchmark/integer/select.c index 6d42494..4cca75d 100644 --- a/benchmark/integer/select.c +++ b/benchmark/integer/select.c @@ -24,10 +24,10 @@ #include <libpq-fe.h> int -main(int argc, char **argv) +main(int argc, char** argv) { - PGconn *connection = PQconnectdb("dbname=afs_benchmark"); - PGresult *result; + PGconn* connection = PQconnectdb("dbname=afs_benchmark"); + PGresult* result; struct timeval before; struct timeval after; int nFields; @@ -35,11 +35,11 @@ main(int argc, char **argv) int nTuples; int iTuple; - if (PQstatus(connection) != CONNECTION_OK) - { + if (PQstatus(connection) != CONNECTION_OK) + { fprintf(stderr, "failed to connect: %s", PQerrorMessage(connection)); PQfinish(connection); - return EXIT_FAILURE; + return EXIT_FAILURE; } gettimeofday(&before, NULL); @@ -49,7 +49,7 @@ main(int argc, char **argv) fprintf(stderr, "failed to select: %s", PQerrorMessage(connection)); PQclear(result); PQfinish(connection); - return EXIT_FAILURE; + return EXIT_FAILURE; } nTuples = PQntuples(result); @@ -64,7 +64,7 @@ main(int argc, char **argv) gettimeofday(&after, NULL); printf("%.3fsec\n", (after.tv_sec + (after.tv_usec / 1000000.0)) - - (before.tv_sec + (before.tv_usec / 1000000.0))); + (before.tv_sec + (before.tv_usec / 1000000.0))); PQclear(result); return EXIT_SUCCESS; diff --git a/src/afs.cc b/src/afs.cc index ffefc46..603eba0 100644 --- a/src/afs.cc +++ b/src/afs.cc @@ -96,7 +96,8 @@ static const int MaxNRowsPerRecordBatchDefault = 1 * 1024 * 1024; static int MaxNRowsPerRecordBatch; static volatile sig_atomic_t GotSIGTERM = false; -void afs_sigterm(SIGNAL_ARGS) +void +afs_sigterm(SIGNAL_ARGS) { auto errnoSaved = errno; GotSIGTERM = true; @@ -105,7 +106,8 @@ void afs_sigterm(SIGNAL_ARGS) } static volatile sig_atomic_t GotSIGHUP = false; -void afs_sighup(SIGNAL_ARGS) +void +afs_sighup(SIGNAL_ARGS) { auto errnoSaved = errno; GotSIGHUP = true; @@ -114,7 +116,8 @@ void afs_sighup(SIGNAL_ARGS) } static volatile sig_atomic_t GotSIGUSR1 = false; -void afs_sigusr1(SIGNAL_ARGS) +void +afs_sigusr1(SIGNAL_ARGS) { procsignal_sigusr1_handler(postgres_signal_arg); auto errnoSaved = errno;