Skip to content

Commit dc0957a

Browse files
authored
Merge pull request #281 from Maxxen/modernize
Simplify build, move to new extension template, fixup CI, apply patches
2 parents 03eaed7 + 1b025aa commit dc0957a

11 files changed

+154
-196
lines changed

.github/workflows/Linux.yml

+25-58
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Linux
1+
name: Integration Tests
22
on: [push, pull_request,repository_dispatch]
33
concurrency:
44
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || '' }}-${{ github.base_ref || '' }}-${{ github.ref != 'refs/heads/main' || github.sha }}
@@ -11,44 +11,42 @@ jobs:
1111
linux-tests-postgres:
1212
name: Run tests on Linux
1313
runs-on: ubuntu-latest
14-
container: ${{ matrix.container }}
1514
strategy:
1615
matrix:
1716
# Add commits/tags to build against other DuckDB versions
1817
duckdb_version: [ '<submodule_version>' ]
19-
arch: ['linux_amd64_gcc4']
18+
arch: ['linux_amd64']
2019
vcpkg_version: [ '2023.04.15' ]
2120
include:
22-
- arch: 'linux_amd64_gcc4'
23-
container: 'quay.io/pypa/manylinux2014_x86_64'
21+
- arch: 'linux_amd64'
2422
vcpkg_triplet: 'x64-linux'
2523

2624
env:
2725
VCPKG_TARGET_TRIPLET: ${{ matrix.vcpkg_triplet }}
2826
GEN: Ninja
2927
VCPKG_TOOLCHAIN_PATH: ${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake
30-
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
3128

3229
steps:
3330
- name: Install required ubuntu packages
34-
if: ${{ matrix.arch == 'linux_amd64' || matrix.arch == 'linux_arm64' }}
3531
run: |
36-
apt-get update -y -qq
37-
apt-get install -y -qq software-properties-common
38-
add-apt-repository ppa:git-core/ppa
39-
apt-get update -y -qq
40-
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
41-
apt-get install -y -qq tar pkg-config
32+
sudo apt-get update -y -qq
33+
sudo apt-get install -y -qq build-essential cmake ninja-build ccache python3
4234
43-
- name: Install Git 2.18.5
44-
if: ${{ matrix.arch == 'linux_amd64' || matrix.arch == 'linux_arm64' }}
35+
- name: Setup PostgreSQL for Linux/macOS/Windows
36+
uses: ikalnytskyi/action-setup-postgres@v7
37+
with:
38+
postgres-version: '15'
39+
username: 'postgres'
40+
password: 'postgres'
41+
database: 'postgres'
42+
port: '5432'
43+
ssl: true
44+
45+
- name: Test Postgres Setup
4546
run: |
46-
wget https://github.com/git/git/archive/refs/tags/v2.18.5.tar.gz
47-
tar xvf v2.18.5.tar.gz
48-
cd git-2.18.5
49-
make
50-
make prefix=/usr install
51-
git --version
47+
psql -c "SELECT 42"
48+
env:
49+
PGSERVICE: postgres
5250

5351
- uses: actions/checkout@v3
5452
with:
@@ -61,60 +59,29 @@ jobs:
6159
cd duckdb
6260
git checkout ${{ matrix.duckdb_version }}
6361
64-
- name: Setup ManyLinux2014
65-
if: ${{ matrix.arch == 'linux_amd64_gcc4' }}
66-
run: |
67-
./duckdb/scripts/setup_manylinux2014.sh general aws-cli ccache ssh openssl python_alias
68-
69-
- name: Setup Ubuntu
70-
if: ${{ matrix.arch == 'linux_amd64' || matrix.arch == 'linux_arm64' }}
71-
uses: ./duckdb/.github/actions/ubuntu_18_setup
62+
- name: Setup Ccache
63+
uses: hendrikmuhs/ccache-action@main
7264
with:
73-
aarch64_cross_compile: 1
65+
key: ${{ github.job }}
66+
save: ${{ github.ref == 'refs/heads/main' || github.repository != 'duckdb/duckdb-postgres' }}
7467

7568
- name: Setup vcpkg
7669
uses: lukka/[email protected]
7770
with:
7871
vcpkgGitCommitId: a42af01b72c28a8e1d7b48107b33e4f286a55ef6
7972

80-
- name: Install postgres (amd64_gcc4)
81-
if: ${{ matrix.arch == 'linux_amd64_gcc4' }}
82-
run: |
83-
yum install -y sudo
84-
yum install -y postgresql-server
85-
86-
- name: Setup Postgres
87-
if: ${{ matrix.arch == 'linux_amd64_gcc4' }}
88-
run: |
89-
mkdir pgdata
90-
chown postgres pgdata
91-
sudo -u postgres initdb -D pgdata
92-
sudo -u postgres pg_ctl -D pgdata start
93-
sleep 5
94-
sudo -u postgres createuser root -s
95-
createdb
96-
psql -c "SELECT 42"
97-
9873
- name: Build extension
9974
env:
10075
GEN: ninja
10176
STATIC_LIBCPP: 1
102-
CC: ${{ matrix.arch == 'linux_arm64' && 'aarch64-linux-gnu-gcc' || '' }}
103-
CXX: ${{ matrix.arch == 'linux_arm64' && 'aarch64-linux-gnu-g++' || '' }}
10477
run: |
10578
make release
10679
10780
- name: Test extension
108-
if: ${{ matrix.arch == 'linux_amd64_gcc4' }}
10981
env:
11082
POSTGRES_TEST_DATABASE_AVAILABLE: 1
83+
PGSERVICE: postgres
11184
run: |
11285
psql -c "SELECT 43"
11386
source ./create-postgres-tables.sh
114-
make test_release
115-
116-
- uses: actions/upload-artifact@v3
117-
with:
118-
name: ${{matrix.arch}}-extensions
119-
path: |
120-
build/release/extension/postgres_scanner/postgres_scanner.duckdb_extension
87+
make test_release

.github/workflows/MainDistributionPipeline.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ jobs:
1717
uses: duckdb/extension-ci-tools/.github/workflows/_extension_distribution.yml@main
1818
with:
1919
duckdb_version: main
20+
ci_tools_version: main
2021
extension_name: postgres_scanner
21-
exclude_archs: 'wasm_mvp;wasm_eh;wasm_threads;windows_amd64_rtools'
22+
exclude_archs: 'wasm_mvp;wasm_eh;wasm_threads;windows_amd64_mingw'
2223

2324
duckdb-stable-deploy:
2425
name: Deploy extension binaries
@@ -27,6 +28,7 @@ jobs:
2728
secrets: inherit
2829
with:
2930
duckdb_version: main
31+
ci_tools_version: main
3032
extension_name: postgres_scanner
31-
exclude_archs: 'wasm_mvp;wasm_eh;wasm_threads;windows_amd64_rtools'
33+
exclude_archs: 'wasm_mvp;wasm_eh;wasm_threads;windows_amd64_mingw'
3234
deploy_latest: ${{ startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' }}

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "duckdb"]
22
path = duckdb
33
url = https://github.com/duckdb/duckdb.git
4+
[submodule "extension-ci-tools"]
5+
path = extension-ci-tools
6+
url = https://github.com/duckdb/extension-ci-tools.git

CMakeLists.txt

+81-9
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,88 @@ add_subdirectory(src)
114114

115115
prepend(LIBPG_SOURCES_FULLPATH ${CMAKE_CURRENT_SOURCE_DIR} ${LIBPG_SOURCES})
116116

117-
if(EXISTS "postgres")
118-
119-
else()
120-
execute_process(COMMAND sh pgconfigure ${LIBPG_SOURCES_FULLPATH}
121-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
117+
if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/postgres)
118+
119+
# Download the PostgreSQL source code
120+
message(STATUS "Downloading PostgreSQL source code")
121+
file(DOWNLOAD
122+
"https://github.com/postgres/postgres/archive/refs/tags/REL_15_2.tar.gz"
123+
${CMAKE_CURRENT_SOURCE_DIR}/pg.tar.gz
124+
SHOW_PROGRESS
125+
EXPECTED_MD5 615ef3fa75d19c46d2dafd6c66ddb5f6
126+
STATUS PG_DOWNLOAD_RESULT)
127+
128+
if(NOT PG_DOWNLOAD_RESULT EQUAL 0)
129+
file(REMOVE pg.tar.gz)
130+
message(FATAL_ERROR "Failed to download PostgreSQL source code")
131+
endif()
132+
133+
# Extract the PostgreSQL source code
134+
message(STATUS "Extracting PostgreSQL source code")
135+
file(ARCHIVE_EXTRACT INPUT ${CMAKE_CURRENT_SOURCE_DIR}/pg.tar.gz
136+
DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/postgres_tmp)
137+
138+
# Move out of root directory
139+
file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/postgres_tmp/postgres-REL_15_2
140+
${CMAKE_CURRENT_SOURCE_DIR}/postgres
141+
)
142+
143+
# Remove the tmp directory
144+
file(REMOVE_RECURSE ${CMAKE_CURRENT_SOURCE_DIR}/postgres_tmp)
145+
146+
# Remove the downloaded tarball
147+
file(REMOVE ${CMAKE_CURRENT_SOURCE_DIR}/pg.tar.gz)
148+
149+
# Configure the PostgreSQL source code
150+
message(STATUS "Configuring PostgreSQL source code")
151+
if(WIN32)
152+
# On windows, use the mkvcbuild.pl script to configure the source code
153+
execute_process(
154+
COMMAND perl mkvcbuild.pl
155+
RESULT_VARIABLE PG_MKVCBUILD_RESULT
156+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/postgres/src/tools/msvc)
157+
158+
# Check if configuration was successful
159+
if(NOT PG_MKVCBUILD_RESULT EQUAL 0)
160+
file(REMOVE_RECURSE postgres)
161+
message(FATAL_ERROR "Failed to configure PostgreSQL source code for windows")
162+
endif()
163+
else()
164+
# On other platforms, use the configure script to configure the source code
165+
set(ENV{CC} gcc)
166+
set(ENV{CXX} g++)
167+
execute_process(
168+
COMMAND ./configure
169+
--without-llvm
170+
--without-icu
171+
--without-tcl
172+
--without-perl
173+
--without-python
174+
--without-gssapi
175+
--without-pam
176+
--without-bsd-auth
177+
--without-ldap
178+
--without-bonjour
179+
--without-selinux
180+
--without-systemd
181+
--without-readline
182+
--without-libxml
183+
--without-libxslt
184+
--without-zlib
185+
--without-lz4
186+
--without-openssl
187+
RESULT_VARIABLE PG_CONFIGURE_RESULT
188+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/postgres
189+
)
190+
# Check if configuration was successful
191+
if(NOT PG_CONFIGURE_RESULT EQUAL 0)
192+
file(REMOVE_RECURSE postgres)
193+
message(FATAL_ERROR "Failed to configure PostgreSQL source code")
194+
endif ()
195+
endif()
196+
message(STATUS "Finished setting up PostgreSQL source code!")
122197
endif()
123-
add_custom_command(
124-
OUTPUT ${LIBPG_SOURCES_FULLPATH}
125-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
126-
COMMAND sh pgconfigure)
198+
127199

128200
set(PARAMETERS "-no-warnings")
129201
build_loadable_extension(${TARGET_NAME} ${PARAMETERS} ${ALL_OBJECT_FILES}

Makefile

+6-84
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,8 @@
1-
.PHONY: all clean format debug release duckdb_debug duckdb_release pull update
1+
PROJ_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
22

3-
all: release
3+
# Configuration of extension
4+
EXT_NAME=postgres_scanner
5+
EXT_CONFIG=${PROJ_DIR}extension_config.cmake
46

5-
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
6-
PROJ_DIR := $(dir $(MKFILE_PATH))
7-
8-
ifeq ($(OS),Windows_NT)
9-
TEST_PATH="/test/Release/unittest.exe"
10-
else
11-
TEST_PATH="/test/unittest"
12-
endif
13-
14-
#### OSX config
15-
OSX_BUILD_FLAG=
16-
ifneq (${OSX_BUILD_ARCH}, "")
17-
OSX_BUILD_FLAG=-DOSX_BUILD_ARCH=${OSX_BUILD_ARCH}
18-
endif
19-
20-
#### VCPKG config
21-
VCPKG_TOOLCHAIN_PATH?=
22-
ifneq ("${VCPKG_TOOLCHAIN_PATH}", "")
23-
TOOLCHAIN_FLAGS:=${TOOLCHAIN_FLAGS} -DVCPKG_MANIFEST_DIR='${PROJ_DIR}' -DVCPKG_BUILD=1 -DCMAKE_TOOLCHAIN_FILE='${VCPKG_TOOLCHAIN_PATH}'
24-
endif
25-
ifneq ("${VCPKG_TARGET_TRIPLET}", "")
26-
TOOLCHAIN_FLAGS:=${TOOLCHAIN_FLAGS} -DVCPKG_TARGET_TRIPLET='${VCPKG_TARGET_TRIPLET}'
27-
endif
28-
29-
#### Enable Ninja as generator
30-
ifeq ($(GEN),ninja)
31-
GENERATOR=-G "Ninja" -DFORCE_COLORED_OUTPUT=1
32-
endif
33-
34-
#### Configuration for this extension
35-
EXTENSION_NAME=POSTGRES_SCANNER
36-
EXTENSION_FLAGS=\
37-
-DDUCKDB_EXTENSION_NAMES="postgres_scanner" \
38-
-DDUCKDB_EXTENSION_${EXTENSION_NAME}_PATH="$(PROJ_DIR)" \
39-
-DDUCKDB_EXTENSION_${EXTENSION_NAME}_SHOULD_LINK=0 \
40-
-DDUCKDB_EXTENSION_${EXTENSION_NAME}_LOAD_TESTS=1 \
41-
-DDUCKDB_EXTENSION_${EXTENSION_NAME}_TEST_PATH="$(PROJ_DIR)test/sql"
42-
43-
EXTRA_EXTENSIONS_FLAG=-DBUILD_EXTENSIONS="json;tpch;tpcds"
44-
45-
BUILD_FLAGS=-DEXTENSION_STATIC_BUILD=1 $(EXTENSION_FLAGS) ${EXTRA_EXTENSIONS_FLAG} $(OSX_BUILD_FLAG) $(TOOLCHAIN_FLAGS) -DDUCKDB_EXPLICIT_PLATFORM='${DUCKDB_PLATFORM}'
46-
47-
48-
pull:
49-
git submodule init
50-
git submodule update --recursive --remote
51-
52-
clean:
53-
rm -rf build
54-
rm -rf testext
55-
cd duckdb && make clean
56-
57-
# Main build
58-
debug:
59-
mkdir -p build/debug && \
60-
cmake $(GENERATOR) $(BUILD_FLAGS) -DCMAKE_BUILD_TYPE=Debug -S ./duckdb/ -B build/debug && \
61-
cmake --build build/debug --config Debug
62-
63-
reldebug:
64-
mkdir -p build/reldebug && \
65-
cmake $(GENERATOR) $(BUILD_FLAGS) -DCMAKE_BUILD_TYPE=RelWithDebInfo -S ./duckdb/ -B build/reldebug && \
66-
cmake --build build/reldebug --config RelWithDebInfo
67-
68-
release:
69-
mkdir -p build/release && \
70-
cmake $(GENERATOR) $(BUILD_FLAGS) -DCMAKE_BUILD_TYPE=Release -S ./duckdb/ -B build/release && \
71-
cmake --build build/release --config Release
72-
73-
test: test_release
74-
test_release: release
75-
./build/release/$(TEST_PATH) --test-dir "$(PROJ_DIR)" "test/*"
76-
test_debug: debug
77-
./build/debug/$(TEST_PATH) --test-dir "$(PROJ_DIR)" "test/*"
78-
79-
format:
80-
cp duckdb/.clang-format .
81-
find src/ -iname "*.hpp" -o -iname "*.cpp" | xargs clang-format --sort-includes=0 -style=file -i
82-
cmake-format -i CMakeLists.txt
83-
rm .clang-format
84-
85-
update:
86-
git submodule update --remote --merge
7+
# Include the Makefile from extension-ci-tools
8+
include extension-ci-tools/makefiles/duckdb_extension.Makefile

duckdb

Submodule duckdb updated 3241 files

extension-ci-tools

Submodule extension-ci-tools added at f473553

extension_config.cmake

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# This file is included by DuckDB's build system. It specifies which extension to load
2+
3+
# Extension from this repo
4+
duckdb_extension_load(postgres_scanner
5+
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}
6+
DONT_LINK
7+
LOAD_TESTS
8+
)
9+
10+
duckdb_extension_load(tpch)
11+
duckdb_extension_load(tpcds)
12+
duckdb_extension_load(json)
13+
14+
# Any extra extensions that should be built
15+
# e.g.: duckdb_extension_load(json)

0 commit comments

Comments
 (0)