Skip to content

Commit 6953a73

Browse files
authored
Initial commit
0 parents  commit 6953a73

22 files changed

+926
-0
lines changed

.editorconfig

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
duckdb/.editorconfig
+177
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
#
2+
# NOTE: this workflow is for testing the extension template itself,
3+
# this workflow will be removed when scripts/bootstrap-template.py is run
4+
#
5+
name: Extension Template
6+
on: [push, pull_request,repository_dispatch]
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || '' }}-${{ github.base_ref || '' }}-${{ github.ref != 'refs/heads/main' || github.sha }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
linux:
13+
name: Linux
14+
if: ${{ vars.RUN_RENAME_TEST == 'true' || github.repository == 'duckdb/extension-template' }}
15+
runs-on: ubuntu-latest
16+
container: ubuntu:18.04
17+
strategy:
18+
matrix:
19+
# Add commits/tags to build against other DuckDB versions
20+
duckdb_version: [ '<submodule_version>' ]
21+
env:
22+
VCPKG_TOOLCHAIN_PATH: ${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake
23+
VCPKG_TARGET_TRIPLET: 'x64-linux'
24+
GEN: ninja
25+
defaults:
26+
run:
27+
shell: bash
28+
29+
steps:
30+
- name: Install required ubuntu packages
31+
run: |
32+
apt-get update -y -qq
33+
apt-get install -y -qq software-properties-common
34+
add-apt-repository ppa:git-core/ppa
35+
apt-get update -y -qq
36+
apt-get install -y -qq ninja-build make gcc-multilib g++-multilib libssl-dev wget openjdk-8-jdk zip maven unixodbc-dev libc6-dev-i386 lib32readline6-dev libssl-dev libcurl4-gnutls-dev libexpat1-dev gettext unzip build-essential checkinstall libffi-dev curl libz-dev openssh-client
37+
38+
- name: Install Git 2.18.5
39+
run: |
40+
wget https://github.com/git/git/archive/refs/tags/v2.18.5.tar.gz
41+
tar xvf v2.18.5.tar.gz
42+
cd git-2.18.5
43+
make
44+
make prefix=/usr install
45+
git --version
46+
47+
- uses: actions/checkout@v3
48+
with:
49+
fetch-depth: 0
50+
submodules: 'true'
51+
52+
- name: Checkout DuckDB to version
53+
if: ${{ matrix.duckdb_version != '<submodule_version>'}}
54+
run: |
55+
cd duckdb
56+
git checkout ${{ matrix.duckdb_version }}
57+
58+
- uses: ./duckdb/.github/actions/ubuntu_18_setup
59+
60+
- name: Setup vcpkg
61+
uses: lukka/[email protected]
62+
with:
63+
vcpkgGitCommitId: a1a1cbc975abf909a6c8985a6a2b8fe20bbd9bd6
64+
65+
- name: Rename extension
66+
run: |
67+
python3 scripts/bootstrap-template.py ext_1_a_123b_b11
68+
69+
- name: Build
70+
run: |
71+
make
72+
73+
- name: Test
74+
run: |
75+
make test
76+
77+
macos:
78+
name: MacOS
79+
if: ${{ vars.RUN_RENAME_TEST == 'true' || github.repository == 'duckdb/extension-template' }}
80+
runs-on: macos-latest
81+
strategy:
82+
matrix:
83+
# Add commits/tags to build against other DuckDB versions
84+
duckdb_version: [ '<submodule_version>']
85+
env:
86+
VCPKG_TOOLCHAIN_PATH: ${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake
87+
VCPKG_TARGET_TRIPLET: 'x64-osx'
88+
OSX_BUILD_ARCH: 'x86_64'
89+
GEN: ninja
90+
defaults:
91+
run:
92+
shell: bash
93+
94+
steps:
95+
- uses: actions/checkout@v3
96+
with:
97+
fetch-depth: 0
98+
submodules: 'true'
99+
100+
- name: Install Ninja
101+
run: brew install ninja
102+
103+
- uses: actions/setup-python@v2
104+
with:
105+
python-version: '3.7'
106+
107+
- name: Checkout DuckDB to version
108+
if: ${{ matrix.duckdb_version != '<submodule_version>'}}
109+
run: |
110+
cd duckdb
111+
git checkout ${{ matrix.duckdb_version }}
112+
113+
- name: Setup vcpkg
114+
uses: lukka/[email protected]
115+
with:
116+
vcpkgGitCommitId: a1a1cbc975abf909a6c8985a6a2b8fe20bbd9bd6
117+
118+
- name: Rename extension
119+
run: |
120+
python scripts/bootstrap-template.py ext_1_a_123b_b11
121+
122+
- name: Build
123+
run: |
124+
make
125+
126+
- name: Test
127+
run: |
128+
make test
129+
130+
windows:
131+
name: Windows
132+
if: ${{ vars.RUN_RENAME_TEST == 'true' || github.repository == 'duckdb/extension-template' }}
133+
runs-on: windows-latest
134+
strategy:
135+
matrix:
136+
# Add commits/tags to build against other DuckDB versions
137+
duckdb_version: [ '<submodule_version>' ]
138+
env:
139+
VCPKG_TOOLCHAIN_PATH: ${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake
140+
VCPKG_TARGET_TRIPLET: 'x64-windows-static-md'
141+
defaults:
142+
run:
143+
shell: bash
144+
145+
steps:
146+
- uses: actions/checkout@v3
147+
with:
148+
fetch-depth: 0
149+
submodules: 'true'
150+
151+
- uses: actions/setup-python@v2
152+
with:
153+
python-version: '3.7'
154+
155+
- name: Checkout DuckDB to version
156+
# Add commits/tags to build against other DuckDB versions
157+
if: ${{ matrix.duckdb_version != '<submodule_version>'}}
158+
run: |
159+
cd duckdb
160+
git checkout ${{ matrix.duckdb_version }}
161+
162+
- name: Setup vcpkg
163+
uses: lukka/[email protected]
164+
with:
165+
vcpkgGitCommitId: a1a1cbc975abf909a6c8985a6a2b8fe20bbd9bd6
166+
167+
- name: Rename extension
168+
run: |
169+
python scripts/bootstrap-template.py ext_1_a_123b_b11
170+
171+
- name: Build
172+
run: |
173+
make
174+
175+
- name: Test extension
176+
run: |
177+
build/release/test/Release/unittest.exe
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#
2+
# This workflow calls the main distribution pipeline from DuckDB to build, test and (optionally) release the extension
3+
#
4+
name: Main Extension Distribution Pipeline
5+
on:
6+
push:
7+
pull_request:
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || '' }}-${{ github.base_ref || '' }}-${{ github.ref != 'refs/heads/main' || github.sha }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
duckdb-stable-build:
16+
name: Build extension binaries
17+
uses: duckdb/extension-ci-tools/.github/workflows/[email protected]
18+
with:
19+
duckdb_version: v0.10.1
20+
extension_name: quack
21+
22+
duckdb-stable-deploy:
23+
name: Deploy extension binaries
24+
needs: duckdb-stable-build
25+
uses: ./.github/workflows/_extension_deploy.yml
26+
secrets: inherit
27+
with:
28+
duckdb_version: v0.10.1
29+
extension_name: quack
30+
deploy_latest: ${{ startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' }}
+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
#
2+
# Reusable workflow that deploys the artifacts produced by github.com/duckdb/duckdb/.github/workflows/_extension_distribution.yml
3+
#
4+
# note: this workflow needs to be located in the extension repository, as it requires secrets to be passed to the
5+
# deploy script. However, it should generally not be necessary to modify this workflow in your extension repository, as
6+
# this workflow can be configured to use a custom deploy script.
7+
8+
9+
name: Extension Deployment
10+
on:
11+
workflow_call:
12+
inputs:
13+
# The name of the extension
14+
extension_name:
15+
required: true
16+
type: string
17+
# DuckDB version to build against
18+
duckdb_version:
19+
required: true
20+
type: string
21+
# ';' separated list of architectures to exclude, for example: 'linux_amd64;osx_arm64'
22+
exclude_archs:
23+
required: false
24+
type: string
25+
default: ""
26+
# Whether to upload this deployment as the latest. This may overwrite a previous deployment.
27+
deploy_latest:
28+
required: false
29+
type: boolean
30+
default: false
31+
# Whether to upload this deployment under a versioned path. These will not be deleted automatically
32+
deploy_versioned:
33+
required: false
34+
type: boolean
35+
default: false
36+
# Postfix added to artifact names. Can be used to guarantee unique names when this workflow is called multiple times
37+
artifact_postfix:
38+
required: false
39+
type: string
40+
default: ""
41+
# Override the default deploy script with a custom script
42+
deploy_script:
43+
required: false
44+
type: string
45+
default: "./scripts/extension-upload.sh"
46+
# Override the default matrix parse script with a custom script
47+
matrix_parse_script:
48+
required: false
49+
type: string
50+
default: "./duckdb/scripts/modify_distribution_matrix.py"
51+
52+
jobs:
53+
generate_matrix:
54+
name: Generate matrix
55+
runs-on: ubuntu-latest
56+
outputs:
57+
deploy_matrix: ${{ steps.parse-matrices.outputs.deploy_matrix }}
58+
steps:
59+
- uses: actions/checkout@v3
60+
with:
61+
fetch-depth: 0
62+
submodules: 'true'
63+
64+
- name: Checkout DuckDB to version
65+
run: |
66+
cd duckdb
67+
git checkout ${{ inputs.duckdb_version }}
68+
69+
- id: parse-matrices
70+
run: |
71+
python3 ${{ inputs.matrix_parse_script }} --input ./duckdb/.github/config/distribution_matrix.json --deploy_matrix --output deploy_matrix.json --exclude "${{ inputs.exclude_archs }}" --pretty
72+
deploy_matrix="`cat deploy_matrix.json`"
73+
echo deploy_matrix=$deploy_matrix >> $GITHUB_OUTPUT
74+
echo `cat $GITHUB_OUTPUT`
75+
76+
deploy:
77+
name: Deploy
78+
runs-on: ubuntu-latest
79+
needs: generate_matrix
80+
if: ${{ needs.generate_matrix.outputs.deploy_matrix != '{}' && needs.generate_matrix.outputs.deploy_matrix != '' }}
81+
strategy:
82+
matrix: ${{fromJson(needs.generate_matrix.outputs.deploy_matrix)}}
83+
84+
steps:
85+
- uses: actions/checkout@v3
86+
with:
87+
fetch-depth: 0
88+
submodules: 'true'
89+
90+
- name: Checkout DuckDB to version
91+
run: |
92+
cd duckdb
93+
git checkout ${{ inputs.duckdb_version }}
94+
95+
- uses: actions/download-artifact@v2
96+
with:
97+
name: ${{ inputs.extension_name }}-${{ inputs.duckdb_version }}-extension-${{matrix.duckdb_arch}}${{inputs.artifact_postfix}}${{startsWith(matrix.duckdb, 'wasm') && '.wasm' || ''}}
98+
path: |
99+
/tmp/extension
100+
101+
- name: Deploy
102+
shell: bash
103+
env:
104+
AWS_ACCESS_KEY_ID: ${{ secrets.S3_DUCKDB_ORG_DEPLOY_ID }}
105+
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_DUCKDB_ORG_DEPLOY_KEY }}
106+
AWS_DEFAULT_REGION: ${{ secrets.S3_DUCKDB_ORG_REGION }}
107+
BUCKET_NAME: ${{ secrets.S3_DUCKDB_ORG_BUCKET }}
108+
DUCKDB_EXTENSION_SIGNING_PK: ${{ secrets.S3_DUCKDB_ORG_EXTENSION_SIGNING_PK }}
109+
run: |
110+
pwd
111+
python3 -m pip install pip awscli
112+
git config --global --add safe.directory '*'
113+
cd duckdb
114+
git fetch --tags
115+
export DUCKDB_VERSION=`git tag --points-at HEAD`
116+
export DUCKDB_VERSION=${DUCKDB_VERSION:=`git log -1 --format=%h`}
117+
cd ..
118+
git fetch --tags
119+
export EXT_VERSION=`git tag --points-at HEAD`
120+
export EXT_VERSION=${EXT_VERSION:=`git log -1 --format=%h`}
121+
${{ inputs.deploy_script }} ${{ inputs.extension_name }} $EXT_VERSION $DUCKDB_VERSION ${{ matrix.duckdb_arch }} $BUCKET_NAME ${{inputs.deploy_latest || 'true' && 'false'}} ${{inputs.deploy_versioned || 'true' && 'false'}}

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
build
2+
.idea
3+
cmake-build-debug
4+
duckdb_unittest_tempdir/
5+
.DS_Store
6+
testext
7+
test/python/__pycache__/
8+
.Rhistory

.gitmodules

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[submodule "duckdb"]
2+
path = duckdb
3+
url = https://github.com/duckdb/duckdb
4+
branch = main
5+
[submodule "extension-ci-tools"]
6+
path = extension-ci-tools
7+
url = https://github.com/duckdb/extension-ci-tools
8+
branch = main

CMakeLists.txt

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
cmake_minimum_required(VERSION 2.8.12)
2+
3+
# Set extension name here
4+
set(TARGET_NAME quack)
5+
6+
# DuckDB's extension distribution supports vcpkg. As such, dependencies can be added in ./vcpkg.json and then
7+
# used in cmake with find_package. Feel free to remove or replace with other dependencies.
8+
# Note that it should also be removed from vcpkg.json to prevent needlessly installing it..
9+
find_package(OpenSSL REQUIRED)
10+
11+
set(EXTENSION_NAME ${TARGET_NAME}_extension)
12+
set(LOADABLE_EXTENSION_NAME ${TARGET_NAME}_loadable_extension)
13+
14+
project(${TARGET_NAME})
15+
include_directories(src/include)
16+
17+
set(EXTENSION_SOURCES src/quack_extension.cpp)
18+
19+
build_static_extension(${TARGET_NAME} ${EXTENSION_SOURCES})
20+
build_loadable_extension(${TARGET_NAME} " " ${EXTENSION_SOURCES})
21+
22+
# Link OpenSSL in both the static library as the loadable extension
23+
target_link_libraries(${EXTENSION_NAME} OpenSSL::SSL OpenSSL::Crypto)
24+
target_link_libraries(${LOADABLE_EXTENSION_NAME} OpenSSL::SSL OpenSSL::Crypto)
25+
26+
install(
27+
TARGETS ${EXTENSION_NAME}
28+
EXPORT "${DUCKDB_EXPORT_SET}"
29+
LIBRARY DESTINATION "${INSTALL_LIB_DIR}"
30+
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}")

LICENSE

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2018-2024 Stichting DuckDB Foundation
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 commit comments

Comments
 (0)