This is an automated email from the ASF dual-hosted git repository.
lidavidm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-adbc.git
The following commit(s) were added to refs/heads/main by this push:
new 7afc45f docs: describe conventional commits format (#124)
7afc45f is described below
commit 7afc45fb40181dc53a73880f4b1f1ea650100928
Author: David Li <[email protected]>
AuthorDate: Fri Sep 16 12:36:08 2022 -0400
docs: describe conventional commits format (#124)
* docs: describe commit convention
* Update CONTRIBUTING.md
* Rename paths for consistency
* Add PR title checker
* Add Go example
---
.github/workflows/cpp.yml | 4 +-
.github/workflows/dev_pr.yml | 46 +++++++++++++
.github/workflows/dev_pr/title_check.js | 75 ++++++++++++++++++++++
.github/workflows/go.yml | 2 +-
CONTRIBUTING.md | 61 ++++++++++++++++--
c/{drivers => driver}/flight_sql/CMakeLists.txt | 0
c/{drivers => driver}/flight_sql/README.md | 0
c/{drivers => driver}/flight_sql/flight_sql.cc | 2 +-
.../flight_sql/flight_sql_test.cc | 2 +-
c/{drivers => driver}/postgres/CMakeLists.txt | 0
c/{drivers => driver}/postgres/README.md | 0
c/{drivers => driver}/postgres/connection.cc | 0
c/{drivers => driver}/postgres/connection.h | 0
c/{drivers => driver}/postgres/database.cc | 0
c/{drivers => driver}/postgres/database.h | 0
c/{drivers => driver}/postgres/postgres.cc | 0
c/{drivers => driver}/postgres/postgres_test.cc | 0
c/{drivers => driver}/postgres/statement.cc | 0
c/{drivers => driver}/postgres/statement.h | 0
c/{drivers => driver}/postgres/type.cc | 0
c/{drivers => driver}/postgres/type.h | 0
c/{drivers => driver}/postgres/util.h | 0
c/{drivers => driver}/sqlite/CMakeLists.txt | 0
c/{drivers => driver}/sqlite/README.md | 0
c/{drivers => driver}/sqlite/sqlite.cc | 2 +-
c/{drivers => driver}/sqlite/sqlite_test.cc | 2 +-
c/{drivers => driver}/test_util.h | 0
c/{drivers => driver}/util.h | 0
c/driver_manager/adbc_driver_manager_test.cc | 2 +-
python/adbc_driver_manager/README.md | 2 +-
python/adbc_driver_postgres/README.md | 2 +-
31 files changed, 188 insertions(+), 14 deletions(-)
diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml
index 41fbc40..5135a27 100644
--- a/.github/workflows/cpp.yml
+++ b/.github/workflows/cpp.yml
@@ -83,7 +83,7 @@ jobs:
run: |
mkdir -p build/driver_sqlite
pushd build/driver_sqlite
- cmake ../../c/drivers/sqlite \
+ cmake ../../c/driver/sqlite \
-DADBC_BUILD_SHARED=ON \
-DADBC_BUILD_STATIC=OFF \
-DADBC_BUILD_TESTS=ON \
@@ -136,7 +136,7 @@ jobs:
# Build a no-ASan version that Python can easily load
mkdir -p build/driver_sqlite_no_asan
pushd build/driver_sqlite_no_asan
- cmake ../../c/drivers/sqlite \
+ cmake ../../c/driver/sqlite \
-DADBC_BUILD_SHARED=ON \
-DADBC_BUILD_STATIC=OFF \
-DCMAKE_BUILD_TYPE=Debug \
diff --git a/.github/workflows/dev_pr.yml b/.github/workflows/dev_pr.yml
new file mode 100644
index 0000000..f7e0244
--- /dev/null
+++ b/.github/workflows/dev_pr.yml
@@ -0,0 +1,46 @@
+# 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: Dev PR
+
+on:
+ pull_request_target:
+ types:
+ - opened
+ - edited
+ - synchronize
+
+jobs:
+ process:
+ name: Process
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ with:
+ persist-credentials: false
+
+ - name: Check title for Conventional Commits format
+ if: |
+ github.event_name == 'pull_request_target' &&
+ (github.event.action == 'opened' ||
+ github.event.action == 'edited')
+ uses: actions/github-script@v3
+ with:
+ github-token: ${{ secrets.GITHUB_TOKEN }}
+ script: |
+ const script =
require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/dev_pr/title_check.js`);
+ script({github, context});
diff --git a/.github/workflows/dev_pr/title_check.js
b/.github/workflows/dev_pr/title_check.js
new file mode 100644
index 0000000..7dda0cf
--- /dev/null
+++ b/.github/workflows/dev_pr/title_check.js
@@ -0,0 +1,75 @@
+// 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.
+
+const COMMIT_TYPES = [
+ 'build',
+ 'chore',
+ 'ci',
+ 'docs',
+ 'feat',
+ 'fix',
+ 'perf',
+ 'refactor',
+ 'revert',
+ 'style',
+ 'test',
+];
+
+const COMMENT_BODY = ":warning: Please follow the [Conventional Commits format
in
CONTRIBUTING.md](https://github.com/apache/arrow-adbc/blob/main/CONTRIBUTING.md)
for PR titles.";
+
+function matchesCommitFormat(title) {
+ const commitType = `(${COMMIT_TYPES.join('|')})`;
+ const scope = "\([a-z/]+\)?";
+ const delimiter = "!?:";
+ const subject = " .+";
+ const regexp = new RegExp(`^${commitType}${scope}${delimiter}${subject}$`);
+ return title.match(regexp) != null;
+}
+
+async function commitCommitFormat(github, context, pullRequestNumber) {
+ const {data: comments} = await github.issues.listComments({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ issue_number: pullRequestNumber,
+ per_page: 100,
+ });
+
+ let found = false;
+ for (const comment of comments) {
+ if (comment.body.includes("Conventional Commits format in
CONTRIBUTING.md")) {
+ found = true;
+ break;
+ }
+ }
+
+ if (!found) {
+ await github.issues.createComment({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ issue_number: pullRequestNumber,
+ body: COMMENT_BODY,
+ });
+ }
+}
+
+module.exports = async ({github, context}) => {
+ const pullRequestNumber = context.payload.number;
+ const title = context.payload.pull_request.title;
+ if (!matchesCommitFormat(title)) {
+ await commentCommitFormat(github, context, pullRequestNumber);
+ }
+};
diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml
index 1cdadb3..303b6b7 100644
--- a/.github/workflows/go.yml
+++ b/.github/workflows/go.yml
@@ -123,7 +123,7 @@ jobs:
run: |
mkdir -p build/driver_sqlite
pushd build/driver_sqlite
- cmake ../../c/drivers/sqlite \
+ cmake ../../c/driver/sqlite \
-DADBC_BUILD_SHARED=ON \
-DADBC_BUILD_STATIC=OFF \
-DADBC_BUILD_TESTS=OFF \
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 9c05ade..62d608a 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -26,9 +26,6 @@ https://github.com/apache/arrow-adbc/issues
## Building
-In general: static checks, such as linting and formatting, are
-enforced via [pre-commit](https://pre-commit.com/).
-
### C/C++
The libraries here are all **individual** CMake projects.
@@ -75,7 +72,7 @@ For example, to build and run tests for the SQLite3 driver:
$ mkdir -p build/sqlite
$ cd build/sqlite
# You may need to set -DCMAKE_PREFIX_PATH such that googletest can be found
-$ cmake ../../c/drivers/sqlite -DADBC_BUILD_TESTS=ON
+$ cmake ../../c/driver/sqlite -DADBC_BUILD_TESTS=ON
$ make -j
$ ctest
```
@@ -175,3 +172,59 @@ $ pytest -vvx
### Ruby
The Ruby libraries are bindings around the GLib libraries.
+
+## Opening a Pull Request
+
+Before opening a pull request, please run the static checks, which are
+enforced via [`pre-commit`](https://pre-commit.com/). This will run
+linters, formatters, and other analysis. For example:
+
+```shell
+$ pip install pre-commit
+# Set up hooks
+$ pre-commit install
+# Run manually
+$ pre-commit run
+Check Xml............................................(no files to check)Skipped
+Check Yaml...........................................(no files to check)Skipped
+Fix End of Files.....................................(no files to check)Skipped
+Trim Trailing Whitespace.............................(no files to check)Skipped
+clang-format.........................................(no files to check)Skipped
+cmake-format.........................................(no files to check)Skipped
+cpplint..............................................(no files to check)Skipped
+Google Java Formatter................................(no files to check)Skipped
+black................................................(no files to check)Skipped
+flake8...............................................(no files to check)Skipped
+isort................................................(no files to check)Skipped
+# Hooks automatically run on commit
+$ git commit
+```
+
+When committing, please follow [Conventional
+Commits][conventional-commits]. This helps maintain semantic
+versioning of components.
+
+Please use the following commit types: `build`, `chore`, `ci`, `docs`,
+`feat`, `fix`, `perf`, `refactor`, `revert`, `style`, `test`.
+
+Please use the following scopes:
+
+- `c/driver/postgres`, `java/driver-manager`, …: for a component and
+ all its bindings. For example, `c/driver-manager` covers the C/C++
+ driver manager and its GLib and Python bindings, while
+ `java/driver/flight-sql` covers only the Flight SQL driver for Java.
+ (The scope names are derived from the filesystem paths.)
+- `c/format`, `go/format`, `java/format`: for the core API definitions
+ (adbc.h for C/C++, adbc.go for Go, adbc-core for Java).
+
+For example:
+
+```
+feat(c/driver/postgres): implement prepared statements
+
+ci(go/adbc/drivermgr): pass through DYLD_LIBRARY_PATH in tests
+
+fix(java/driver/jdbc): adjust SQL type mapping for JDBC driver
+```
+
+[conventional-commits]: https://www.conventionalcommits.org/en/v1.0.0/
diff --git a/c/drivers/flight_sql/CMakeLists.txt
b/c/driver/flight_sql/CMakeLists.txt
similarity index 100%
rename from c/drivers/flight_sql/CMakeLists.txt
rename to c/driver/flight_sql/CMakeLists.txt
diff --git a/c/drivers/flight_sql/README.md b/c/driver/flight_sql/README.md
similarity index 100%
rename from c/drivers/flight_sql/README.md
rename to c/driver/flight_sql/README.md
diff --git a/c/drivers/flight_sql/flight_sql.cc
b/c/driver/flight_sql/flight_sql.cc
similarity index 99%
rename from c/drivers/flight_sql/flight_sql.cc
rename to c/driver/flight_sql/flight_sql.cc
index 3b56ac9..56c78d1 100644
--- a/c/drivers/flight_sql/flight_sql.cc
+++ b/c/driver/flight_sql/flight_sql.cc
@@ -29,7 +29,7 @@
#include <arrow/util/string_builder.h>
#include <arrow/util/string_view.h>
#include "adbc.h"
-#include "drivers/util.h"
+#include "driver/util.h"
namespace flight = arrow::flight;
namespace flightsql = arrow::flight::sql;
diff --git a/c/drivers/flight_sql/flight_sql_test.cc
b/c/driver/flight_sql/flight_sql_test.cc
similarity index 99%
rename from c/drivers/flight_sql/flight_sql_test.cc
rename to c/driver/flight_sql/flight_sql_test.cc
index 358339f..e1c6ce6 100644
--- a/c/drivers/flight_sql/flight_sql_test.cc
+++ b/c/driver/flight_sql/flight_sql_test.cc
@@ -25,7 +25,7 @@
#include <arrow/util/logging.h>
#include "adbc.h"
-#include "drivers/test_util.h"
+#include "driver/test_util.h"
namespace adbc {
diff --git a/c/drivers/postgres/CMakeLists.txt
b/c/driver/postgres/CMakeLists.txt
similarity index 100%
rename from c/drivers/postgres/CMakeLists.txt
rename to c/driver/postgres/CMakeLists.txt
diff --git a/c/drivers/postgres/README.md b/c/driver/postgres/README.md
similarity index 100%
rename from c/drivers/postgres/README.md
rename to c/driver/postgres/README.md
diff --git a/c/drivers/postgres/connection.cc b/c/driver/postgres/connection.cc
similarity index 100%
rename from c/drivers/postgres/connection.cc
rename to c/driver/postgres/connection.cc
diff --git a/c/drivers/postgres/connection.h b/c/driver/postgres/connection.h
similarity index 100%
rename from c/drivers/postgres/connection.h
rename to c/driver/postgres/connection.h
diff --git a/c/drivers/postgres/database.cc b/c/driver/postgres/database.cc
similarity index 100%
rename from c/drivers/postgres/database.cc
rename to c/driver/postgres/database.cc
diff --git a/c/drivers/postgres/database.h b/c/driver/postgres/database.h
similarity index 100%
rename from c/drivers/postgres/database.h
rename to c/driver/postgres/database.h
diff --git a/c/drivers/postgres/postgres.cc b/c/driver/postgres/postgres.cc
similarity index 100%
rename from c/drivers/postgres/postgres.cc
rename to c/driver/postgres/postgres.cc
diff --git a/c/drivers/postgres/postgres_test.cc
b/c/driver/postgres/postgres_test.cc
similarity index 100%
rename from c/drivers/postgres/postgres_test.cc
rename to c/driver/postgres/postgres_test.cc
diff --git a/c/drivers/postgres/statement.cc b/c/driver/postgres/statement.cc
similarity index 100%
rename from c/drivers/postgres/statement.cc
rename to c/driver/postgres/statement.cc
diff --git a/c/drivers/postgres/statement.h b/c/driver/postgres/statement.h
similarity index 100%
rename from c/drivers/postgres/statement.h
rename to c/driver/postgres/statement.h
diff --git a/c/drivers/postgres/type.cc b/c/driver/postgres/type.cc
similarity index 100%
rename from c/drivers/postgres/type.cc
rename to c/driver/postgres/type.cc
diff --git a/c/drivers/postgres/type.h b/c/driver/postgres/type.h
similarity index 100%
rename from c/drivers/postgres/type.h
rename to c/driver/postgres/type.h
diff --git a/c/drivers/postgres/util.h b/c/driver/postgres/util.h
similarity index 100%
rename from c/drivers/postgres/util.h
rename to c/driver/postgres/util.h
diff --git a/c/drivers/sqlite/CMakeLists.txt b/c/driver/sqlite/CMakeLists.txt
similarity index 100%
rename from c/drivers/sqlite/CMakeLists.txt
rename to c/driver/sqlite/CMakeLists.txt
diff --git a/c/drivers/sqlite/README.md b/c/driver/sqlite/README.md
similarity index 100%
rename from c/drivers/sqlite/README.md
rename to c/driver/sqlite/README.md
diff --git a/c/drivers/sqlite/sqlite.cc b/c/driver/sqlite/sqlite.cc
similarity index 99%
rename from c/drivers/sqlite/sqlite.cc
rename to c/driver/sqlite/sqlite.cc
index 06765dd..fac667c 100644
--- a/c/drivers/sqlite/sqlite.cc
+++ b/c/driver/sqlite/sqlite.cc
@@ -36,7 +36,7 @@
#include "adbc.h"
#include "arrow/type_fwd.h"
-#include "drivers/util.h"
+#include "driver/util.h"
namespace {
diff --git a/c/drivers/sqlite/sqlite_test.cc b/c/driver/sqlite/sqlite_test.cc
similarity index 99%
rename from c/drivers/sqlite/sqlite_test.cc
rename to c/driver/sqlite/sqlite_test.cc
index 7bdb731..ce97e6b 100644
--- a/c/drivers/sqlite/sqlite_test.cc
+++ b/c/driver/sqlite/sqlite_test.cc
@@ -27,7 +27,7 @@
#include <arrow/testing/matchers.h>
#include "adbc.h"
-#include "drivers/test_util.h"
+#include "driver/test_util.h"
#include "validation/adbc_validation.h"
// Tests of the SQLite example driver
diff --git a/c/drivers/test_util.h b/c/driver/test_util.h
similarity index 100%
rename from c/drivers/test_util.h
rename to c/driver/test_util.h
diff --git a/c/drivers/util.h b/c/driver/util.h
similarity index 100%
rename from c/drivers/util.h
rename to c/driver/util.h
diff --git a/c/driver_manager/adbc_driver_manager_test.cc
b/c/driver_manager/adbc_driver_manager_test.cc
index 23e549d..121c376 100644
--- a/c/driver_manager/adbc_driver_manager_test.cc
+++ b/c/driver_manager/adbc_driver_manager_test.cc
@@ -29,7 +29,7 @@
#include "adbc.h"
#include "adbc_driver_manager.h"
-#include "drivers/test_util.h"
+#include "driver/test_util.h"
#include "validation/adbc_validation.h"
// Tests of the SQLite example driver, except using the driver manager
diff --git a/python/adbc_driver_manager/README.md
b/python/adbc_driver_manager/README.md
index 10de050..c1465f1 100644
--- a/python/adbc_driver_manager/README.md
+++ b/python/adbc_driver_manager/README.md
@@ -39,7 +39,7 @@ See [CONTRIBUTING.md](../../CONTRIBUTING.md) for details.
## Testing
-The [SQLite driver](../../c/drivers/sqlite/README.md) must be loadable
+The [SQLite driver](../../c/driver/sqlite/README.md) must be loadable
at runtime (e.g. it must be on `LD_LIBRARY_PATH`, `DYLD_LIBRARY_PATH`,
or `PATH`).
diff --git a/python/adbc_driver_postgres/README.md
b/python/adbc_driver_postgres/README.md
index 17d6b4b..89ced0f 100644
--- a/python/adbc_driver_postgres/README.md
+++ b/python/adbc_driver_postgres/README.md
@@ -20,7 +20,7 @@
# ADBC libpq Driver for Python
This package contains bindings for the [libpq
-driver](../../c/drivers/postgres/README.md), using the [driver
+driver](../../c/driver/postgres/README.md), using the [driver
manager](../adbc_driver_manager/README.md) to provide a [DBAPI 2.0/PEP
249-compatible][dbapi] interface on top.