Skip to content

Commit 2f83115

Browse files
authored
Initial commit
0 parents  commit 2f83115

23 files changed

+984
-0
lines changed

.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
duckdb/.editorconfig
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
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+
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
26+
defaults:
27+
run:
28+
shell: bash
29+
30+
steps:
31+
- name: Install required ubuntu packages
32+
run: |
33+
apt-get update -y -qq
34+
apt-get install -y -qq software-properties-common
35+
add-apt-repository ppa:git-core/ppa
36+
apt-get update -y -qq
37+
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
38+
39+
- name: Install Git 2.18.5
40+
run: |
41+
wget https://github.com/git/git/archive/refs/tags/v2.18.5.tar.gz
42+
tar xvf v2.18.5.tar.gz
43+
cd git-2.18.5
44+
make
45+
make prefix=/usr install
46+
git --version
47+
48+
- uses: actions/checkout@v3
49+
with:
50+
fetch-depth: 0
51+
submodules: 'true'
52+
53+
- name: Checkout DuckDB to version
54+
if: ${{ matrix.duckdb_version != '<submodule_version>'}}
55+
run: |
56+
cd duckdb
57+
git checkout ${{ matrix.duckdb_version }}
58+
59+
- uses: ./duckdb/.github/actions/ubuntu_18_setup
60+
61+
- name: Setup vcpkg
62+
uses: lukka/[email protected]
63+
with:
64+
vcpkgGitCommitId: a1a1cbc975abf909a6c8985a6a2b8fe20bbd9bd6
65+
66+
- name: Rename extension
67+
run: |
68+
python3 scripts/bootstrap-template.py ext_1_a_123b_b11
69+
70+
- name: Build
71+
run: |
72+
make
73+
74+
- name: Test
75+
run: |
76+
make test
77+
78+
macos:
79+
name: MacOS
80+
if: ${{ vars.RUN_RENAME_TEST == 'true' || github.repository == 'duckdb/extension-template' }}
81+
runs-on: macos-latest
82+
strategy:
83+
matrix:
84+
# Add commits/tags to build against other DuckDB versions
85+
duckdb_version: [ '<submodule_version>']
86+
env:
87+
VCPKG_TOOLCHAIN_PATH: ${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake
88+
VCPKG_TARGET_TRIPLET: 'x64-osx'
89+
OSX_BUILD_ARCH: 'x86_64'
90+
GEN: ninja
91+
defaults:
92+
run:
93+
shell: bash
94+
95+
steps:
96+
- uses: actions/checkout@v3
97+
with:
98+
fetch-depth: 0
99+
submodules: 'true'
100+
101+
- name: Install Ninja
102+
run: brew install ninja
103+
104+
- uses: actions/setup-python@v2
105+
with:
106+
python-version: '3.11'
107+
108+
- name: Checkout DuckDB to version
109+
if: ${{ matrix.duckdb_version != '<submodule_version>'}}
110+
run: |
111+
cd duckdb
112+
git checkout ${{ matrix.duckdb_version }}
113+
114+
- name: Setup vcpkg
115+
uses: lukka/[email protected]
116+
with:
117+
vcpkgGitCommitId: a1a1cbc975abf909a6c8985a6a2b8fe20bbd9bd6
118+
119+
- name: Rename extension
120+
run: |
121+
python scripts/bootstrap-template.py ext_1_a_123b_b11
122+
123+
- name: Build
124+
run: |
125+
make
126+
127+
- name: Test
128+
run: |
129+
make test
130+
131+
windows:
132+
name: Windows
133+
if: ${{ vars.RUN_RENAME_TEST == 'true' || github.repository == 'duckdb/extension-template' }}
134+
runs-on: windows-latest
135+
strategy:
136+
matrix:
137+
# Add commits/tags to build against other DuckDB versions
138+
duckdb_version: [ '<submodule_version>' ]
139+
env:
140+
VCPKG_TOOLCHAIN_PATH: ${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake
141+
VCPKG_TARGET_TRIPLET: 'x64-windows-static-md'
142+
defaults:
143+
run:
144+
shell: bash
145+
146+
steps:
147+
- uses: actions/checkout@v3
148+
with:
149+
fetch-depth: 0
150+
submodules: 'true'
151+
152+
- uses: actions/setup-python@v2
153+
with:
154+
python-version: '3.11'
155+
156+
- name: Checkout DuckDB to version
157+
# Add commits/tags to build against other DuckDB versions
158+
if: ${{ matrix.duckdb_version != '<submodule_version>'}}
159+
run: |
160+
cd duckdb
161+
git checkout ${{ matrix.duckdb_version }}
162+
163+
- name: Setup vcpkg
164+
uses: lukka/[email protected]
165+
with:
166+
vcpkgGitCommitId: a1a1cbc975abf909a6c8985a6a2b8fe20bbd9bd6
167+
168+
- name: Rename extension
169+
run: |
170+
python scripts/bootstrap-template.py ext_1_a_123b_b11
171+
172+
- name: Build
173+
run: |
174+
make
175+
176+
- name: Test extension
177+
run: |
178+
build/release/test/Release/unittest.exe
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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-next-build:
16+
name: Build extension binaries
17+
uses: duckdb/extension-ci-tools/.github/workflows/_extension_distribution.yml@main
18+
with:
19+
duckdb_version: main
20+
ci_tools_version: main
21+
extension_name: quack
22+
23+
duckdb-stable-build:
24+
name: Build extension binaries
25+
uses: duckdb/extension-ci-tools/.github/workflows/[email protected]
26+
with:
27+
duckdb_version: v1.1.3
28+
ci_tools_version: v1.1.3
29+
extension_name: quack
30+
31+
duckdb-stable-deploy:
32+
name: Deploy extension binaries
33+
needs: duckdb-stable-build
34+
uses: ./.github/workflows/_extension_deploy.yml
35+
secrets: inherit
36+
with:
37+
duckdb_version: v1.1.3
38+
extension_name: quack
39+
deploy_latest: ${{ startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' }}
Lines changed: 121 additions & 0 deletions
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@v3
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_DEPLOY_ID }}
105+
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_DEPLOY_KEY }}
106+
AWS_DEFAULT_REGION: ${{ secrets.S3_REGION }}
107+
BUCKET_NAME: ${{ secrets.S3_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

Lines changed: 8 additions & 0 deletions
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

Lines changed: 8 additions & 0 deletions
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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
cmake_minimum_required(VERSION 3.5)
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}")

0 commit comments

Comments
 (0)