Skip to content

Commit 016539b

Browse files
Michael Harrisclaude
andcommitted
fix(build): rename HttpMethod::DELETE to DEL for Windows compat
Windows headers define DELETE as a macro, causing MSVC build failures. Also update development docs with repo layout, testing guide, and CI pipeline overview. Add CLAUDE.md for quick reference. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent f011682 commit 016539b

5 files changed

Lines changed: 117 additions & 28 deletions

File tree

CLAUDE.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# CLAUDE.md
2+
3+
DuckDB extension for reading and writing Google Sheets.
4+
5+
## Quick Reference
6+
7+
- **Build:** `GEN=ninja make`
8+
- **Unit tests:** `make test_unit`
9+
- **SQL tests:** `TOKEN=your-token make test` or `./scripts/test_sql.sh path/to/keyfile.json`
10+
- **Format:** `make format`
11+
12+
## Architecture
13+
14+
The extension has three layers: **Transport** (HTTP client abstraction), **Auth** (bearer token, OAuth, service account), and **Service** (Google Sheets API client with spreadsheet/values resources). See `src/include/sheets/` for the interfaces.
15+
16+
## Contributing
17+
18+
See [docs/pages/development.md](docs/pages/development.md) for build setup, testing, repo layout, and CI pipeline details.

docs/pages/development.md

Lines changed: 96 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,118 @@
11
# Development
22

3+
## Repository Layout
4+
5+
```
6+
duckdb_gsheets/
7+
├── src/ # Extension source code
8+
│ ├── include/ # Headers
9+
│ │ ├── sheets/ # Google Sheets client library
10+
│ │ │ ├── auth/ # Auth providers (bearer, OAuth, service account)
11+
│ │ │ ├── resources/ # API resources (spreadsheets, values)
12+
│ │ │ ├── transport/ # HTTP client abstraction
13+
│ │ │ └── util/ # Encoding, range parsing
14+
│ │ └── utils/ # Extension utilities (secrets, version)
15+
│ ├── sheets/ # Client library implementation
16+
│ └── *.cpp # Extension entry points (read, copy, auth)
17+
├── test/
18+
│ ├── sql/ # SQL logic tests (integration, requires credentials)
19+
│ └── unit/ # C++ unit tests (standalone, no credentials needed)
20+
├── scripts/ # Dev scripts (test runners, token generation)
21+
├── docs/ # Documentation site
22+
├── .github/workflows/ # CI pipelines
23+
├── duckdb/ # DuckDB submodule
24+
└── extension-ci-tools/ # DuckDB CI tooling submodule
25+
```
26+
327
## Building
28+
429
### Managing dependencies
5-
DuckDB extensions uses VCPKG for dependency management. Enabling VCPKG is very simple: follow the [installation instructions](https://vcpkg.io/en/getting-started) or just run the following:
30+
31+
DuckDB extensions use VCPKG for dependency management. Follow the [installation instructions](https://vcpkg.io/en/getting-started) or run:
32+
633
```shell
734
git clone https://github.com/Microsoft/vcpkg.git
835
./vcpkg/bootstrap-vcpkg.sh
936
export VCPKG_TOOLCHAIN_PATH=`pwd`/vcpkg/scripts/buildsystems/vcpkg.cmake
1037
```
11-
Note: VCPKG is only required for extensions that want to rely on it for dependency management. If you want to develop an extension without dependencies, or want to do your own dependency management, just skip this step. Note that the example extension uses VCPKG to build with a dependency for instructive purposes, so when skipping this step the build may not work without removing the dependency.
1238

1339
### Build steps
14-
Now to build the extension, run:
40+
41+
To build the extension:
42+
1543
```sh
1644
GEN=ninja make
1745
```
46+
1847
The main binaries that will be built are:
48+
49+
- `./build/release/duckdb` — DuckDB shell with the extension auto-loaded
50+
- `./build/release/test/unittest` — SQL test runner with the extension linked in
51+
- `./build/release/extension/gsheets/gsheets.duckdb_extension` — loadable extension binary
52+
53+
## Running the extension
54+
55+
Start the shell with `./build/release/duckdb` and use the extension features directly.
56+
57+
## Testing
58+
59+
### Unit tests
60+
61+
Unit tests are standalone C++ tests that use a mock HTTP client — no credentials or network access needed:
62+
1963
```sh
20-
./build/release/duckdb
21-
./build/release/test/unittest
22-
./build/release/extension/gsheets/gsheets.duckdb_extension
64+
make test_unit
2365
```
24-
- `duckdb` is the binary for the duckdb shell with the extension code automatically loaded.
25-
- `unittest` is the test runner of duckdb. Again, the extension is already linked into the binary.
26-
- `gsheets.duckdb_extension` is the loadable binary as it would be distributed.
2766

28-
## Running the extension
29-
To run the extension code, simply start the shell with `./build/release/duckdb`.
67+
### SQL tests
3068

31-
Now we can use the features from the extension directly in DuckDB.
69+
SQL tests run against the real Google Sheets API and require credentials. There are two ways to run them:
3270

33-
## Running the tests\
34-
To run the test suite, you need to generate a token for the Google Sheets API, follow the instructions in the README file to get one.
71+
**Option 1: With an access token**
72+
73+
If you already have a Google Sheets API access token:
3574

36-
Different tests can be created for DuckDB extensions. The primary way of testing DuckDB extensions should be the SQL tests in `./test/sql`. These SQL tests can be run using:
3775
```sh
38-
TOKEN=your-token-here GEN=ninja make test
76+
TOKEN=your-token-here make test
77+
```
78+
79+
**Option 2: With a service account key file**
80+
81+
If you have a service account JSON key file, the test script will generate a token and set up both `TOKEN` and `KEY_FILE_PATH` for you:
82+
83+
```sh
84+
./scripts/test_sql.sh path/to/keyfile.json
85+
```
86+
87+
This script will:
88+
1. Set up a Python venv and install dependencies
89+
2. Generate an access token from the key file
90+
3. Set `TOKEN` and `KEY_FILE_PATH` environment variables
91+
4. Run `make test` (builds DuckDB + extension, then runs SQL logic tests)
92+
93+
To obtain a key file, create a Google Cloud service account with access to the test spreadsheets and download its JSON key. See [Google's documentation](https://cloud.google.com/iam/docs/keys-create-delete) for details.
94+
95+
## CI Pipeline
96+
97+
The CI pipeline gates builds behind tests:
98+
99+
```mermaid
100+
graph LR
101+
A[push / pull_request] --> B[Unit Tests]
102+
B --> C[SQL Tests]
103+
C --> D[Build next]
104+
C --> E[Build stable]
39105
```
40106

41-
### Installing the deployed binaries
42-
To install your extension binaries from S3, you will need to do two things. Firstly, DuckDB should be launched with the
43-
`allow_unsigned_extensions` option set to true. How to set this will depend on the client you're using. Some examples:
107+
- **Unit tests** — always run, no credentials needed
108+
- **SQL tests** — require `GSHEETS_KEY_FILE_JSON` repo secret; skip gracefully on fork PRs without credentials
109+
- **Distribution builds** — only start after both test stages pass
110+
111+
For fork PRs, maintainers can manually trigger SQL tests via **Actions → SQL Tests → Run workflow**.
112+
113+
## Installing deployed binaries
114+
115+
DuckDB must be launched with `allow_unsigned_extensions` set to true:
44116

45117
CLI:
46118
```shell
@@ -57,15 +129,14 @@ NodeJS:
57129
db = new duckdb.Database(':memory:', {"allow_unsigned_extensions": "true"});
58130
```
59131

60-
Secondly, you will need to set the repository endpoint in DuckDB to the HTTP url of your bucket + version of the extension
61-
you want to install. To do this run the following SQL query in DuckDB:
132+
Set the repository endpoint to your bucket:
133+
62134
```sql
63135
SET custom_extension_repository='bucket.s3.eu-west-1.amazonaws.com/<your_extension_name>/latest';
64136
```
65-
Note that the `/latest` path will allow you to install the latest extension version available for your current version of
66-
DuckDB. To specify a specific version, you can pass the version instead.
67137

68-
After running these steps, you can install and load your extension using the regular INSTALL/LOAD commands in DuckDB:
138+
Then install and load:
139+
69140
```sql
70141
INSTALL gsheets
71142
LOAD gsheets
@@ -88,4 +159,4 @@ $ cmake-format --version
88159

89160
```sh
90161
make format
91-
```
162+
```

src/include/sheets/transport/http_type.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace duckdb {
77
namespace sheets {
88

9-
enum class HttpMethod { GET, POST, PUT, DELETE };
9+
enum class HttpMethod { GET, POST, PUT, DEL };
1010

1111
using HttpHeaders = std::map<std::string, std::string>;
1212

src/sheets/transport/http_client.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ HttpResponse IHttpClient::Put(const std::string &url, const HttpHeaders &headers
2626
}
2727

2828
HttpResponse IHttpClient::Delete(const std::string &url, const HttpHeaders &headers) {
29-
return Execute(BuildRequest(HttpMethod::DELETE, url, headers));
29+
return Execute(BuildRequest(HttpMethod::DEL, url, headers));
3030
}
3131
} // namespace sheets
3232
} // namespace duckdb

src/sheets/transport/httplib_client.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ HttpResponse HttpLibClient::Execute(const HttpRequest &request) {
5757
case HttpMethod::PUT:
5858
result = client.Put(path, headers, request.body, contentType);
5959
break;
60-
case HttpMethod::DELETE:
60+
case HttpMethod::DEL:
6161
result = client.Delete(path, headers);
6262
break;
6363
}

0 commit comments

Comments
 (0)