Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions .github/ubuntu/ch-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#!/usr/bin/perl

=head1 Name

ch-version

=head1 Synopsis

❯ .github/ubuntu/ch-versions --lts --latest-stable --earliest 24
25.9.3.48-stable
25.8.10.7-lts
25.3.6.56-lts
24.8.14.39-lts
24.3.18.7-lts

=head1 Description

Download and sort the complete list of ClickHouse versions and print only the
latest version of each major release (X.Y), in reverse version order. Each
prints to a single line.

=head2 Options

=head3 C<--lts>

.github/ubuntu/ch-versions --lts

Print only latest L<LTS|https://clickhouse.com/docs/faq/operations/production>
(long-term support) releases.

=head3 C<--latest-stable>

.github/ubuntu/ch-versions --lts --latest-stable

Print the latest stable version even with C<--lts>, if there is a stable
version since the latest lts release.

=head3 C<--earliest>

.github/ubuntu/ch-versions --earliest 21.3

Print no releases prior to this major version.

=head3 C<--prefix>

.github/ubuntu/ch-versions --prefix '* '

Print this prefix before each release.

=cut

use strict;
use warnings;
use v5.32;
use Getopt::Long;

my %opt = (
lts => 0, # Only LTS release
latest_stable => 0, # but include latest stable if newer than latest LTS
earliest => 0, # Omit earlier than this version.
prefix => '', # Prefix each version with this string
);

GetOptions(
'latest-stable' => \$opt{latest_stable},
'lts!' => \$opt{lts},
'earliest=s' => \$opt{earliest},
'prefix=s' => \$opt{prefix},
);

my $tsv_url = 'https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/utils/list-versions/version_date.tsv';

# Fetch the versions and parse them into sortable strings.
my %table;
for (qx/curl -sL "$tsv_url"/) {
my ($release, $date) = split /\t/;
$release =~ s/^v//;
my ($version, $pkg) = split /-/ => $release;

my @v = split /\./ => $version;
my $string = join '.', map { sprintf "%03d", $_ } @v;
$table{$string} = ["$v[0].$v[1]", $version, $pkg];
}

my %seen;
for my $string (reverse sort keys %table) {
my ($maj, $version, $pkg) = @{ $table{$string} };

# Stop after earliest.
last if $maj < $opt{earliest};

if ($opt{lts}) {
# Only print latest stable if it's wanted.
next if $pkg eq 'stable' && (!$opt{latest_stable} || %seen);
}

next if $seen{$maj}++;
say "$opt{prefix}$version-$pkg";
}
49 changes: 34 additions & 15 deletions .github/ubuntu/clickhouse.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,43 @@
#!/bin/bash

# This script installs and starts a specific version of ClickHouse server.
# Set CH_RELEASE to the desired release. Examples:
#
# CH_RELEASE=25.9.3.48-stable
# CH_RELEASE=25.8.10.7-lts

set -e

# Fetch latest version if not specified.
# https://clickhouse.com/docs/install
export DEBIAN_FRONTEND=noninteractive
apt-get update -qq
apt-get install -y apt-transport-https ca-certificates curl gnupg

# Download the ClickHouse GPG key and store it in the keyring
curl -fsSL 'https://packages.clickhouse.com/rpm/lts/repodata/repomd.xml.key' \
| gpg --dearmor -o /usr/share/keyrings/clickhouse-keyring.gpg
if [ -z "$CH_RELEASE" ]; then
tsv_url=https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/utils/list-versions/version_date.tsv
CH_RELEASE=$(curl -sL "$tsv_url" | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+-(stable|lts)' | sort -V -r | head -n 1)
# List versions: curl -sL "$tsv_url" | grep -E 'stable|lts'
fi

# Get the system architecture
CH_VERSION="${CH_RELEASE%-*}"
ARCH=$(dpkg --print-architecture)
base_url="https://github.com/ClickHouse/ClickHouse/releases/download/v${CH_RELEASE}"

printf "==== ClickHouse %s for %s =====\n\n" "$CH_VERSION" "$ARCH"
cd "${TMPDIR-/tmp}"

# Prevent prompt for password.
export DEBIAN_FRONTEND=noninteractive

# Add the ClickHouse repository to apt sources
echo "deb [signed-by=/usr/share/keyrings/clickhouse-keyring.gpg arch=${ARCH}] https://packages.clickhouse.com/deb stable main" \
| tee /etc/apt/sources.list.d/clickhouse.list
# Install the packages.
for pkg in clickhouse-common-static clickhouse-server; do
printf "~~~~ Installing %s ~~~~\n\n" "$pkg"
if [ "$pkg" == 'clickhouse-server' ] && [ "${CH_VERSION%%.*}" -lt 22 ]; then
# Prior to v22, the server package supported all architectures.
ARCH=all
fi
echo "${base_url}/${pkg}_${CH_VERSION}_${ARCH}.deb"
curl -sLo "${pkg}.deb" "${base_url}/${pkg}_${CH_VERSION}_${ARCH}.deb"
dpkg -i "${pkg}.deb"
rm "${pkg}.deb"
done

# Update apt package lists
apt-get update -qq
apt-get install -y clickhouse-server
service clickhouse-server start
printf "~~~~ Starting ClickHouse %s ~~~~\n" "$CH_VERSION"
/etc/init.d/clickhouse-server start
41 changes: 41 additions & 0 deletions .github/workflows/clickhouse.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: 🏠 ClickHouse CI
on:
push:
pull_request:
schedule:
- cron: '0 13 10 * *' # Monthly at 13:00 on the tenth
jobs:
build:
strategy:
matrix:
# Test latest version and all LTS releases.
# .github/ubuntu/ch-versions --lts --latest-stable --earliest 22 --prefix ' - ' | pbcopy
ch:
- 25.9.3.48-stable
- 25.8.10.7-lts
- 25.3.6.56-lts
- 24.8.14.39-lts
- 24.3.18.7-lts
- 23.8.16.40-lts
- 23.3.22.3-lts
- 22.8.21.38-lts
- 22.3.20.29-lts
name: 🏠 ClickHouse ${{ matrix.ch }}
runs-on: ubuntu-latest
container: pgxn/pgxn-tools
steps:
- name: Start Postgres
run: pg-start 18 libcurl4-openssl-dev uuid-dev
- name: Checkout the Repository
uses: actions/checkout@v4
with: { submodules: true }
- name: Start ClickHouse
env: { CH_RELEASE: "${{ matrix.ch }}" }
run: .github/ubuntu/clickhouse.sh
- name: Test DSO
run: pg-build-test
- name: Clean
run: make clean
- name: Test Static
run: pg-build-test
env: { CH_BUILD: static }
9 changes: 6 additions & 3 deletions .github/workflows/ci.yml → .github/workflows/postgres.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI
name: 🐘 Postgres CI
on:
push:
pull_request:
Expand All @@ -9,8 +9,11 @@ jobs:
strategy:
matrix:
pg: [18, 17, 16, 15, 14, 13]
name: 🐘 PostgreSQL ${{ matrix.pg }}
runs-on: ubuntu-latest
os:
- { icon: 🐧, arch: amd64, on: ubuntu-latest }
# - { icon: 🐧, arch: arm64, on: ubuntu-24.04-arm } # XXX
name: 🐘 PostgreSQL ${{ matrix.pg }} ${{ matrix.os.icon }} ${{ matrix.os.arch }}
runs-on: ${{ matrix.os.on }}
container: pgxn/pgxn-tools
steps:
- name: Start Postgres ${{ matrix.pg }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ clickhouse_fdw Postgres Extension
[![Build Status](https://github.com/clickhouse/clickhouse_fdw/actions/workflows/ci.yml/badge.svg)](https://github.com/clickhouse/clickhouse_fdw/actions/workflows/ci.yml)

This library contains the PostgreSQL extension `clickhouse_fdw` a foreign data
wrapper for ClickHouse databases.
wrapper for ClickHouse databases. It supports ClickHouse v22 and later.

## Installation

Expand Down
Loading