Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update linux-build-and-test #16

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
72 changes: 31 additions & 41 deletions .github/workflows/linux-build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,25 @@ jobs:
- name: Build matrix
id: set-matrix
run: python scripts/gh_matrix_builder.py ${{ github.event_name }}

install_postgresql:
uses: './.github/workflows/postgresql-build-and-cache.yaml'
needs: matrixbuilder
with:
os: ${{ matrix.os }}
pg: ${{ matrix.pg }}
c_compiler: ${{ matrix.cc }}
cxx_compiler: ${{ matrix.cxx }}
variant: ${{ matrix.build_type }}
snapshot: ${{ matrix.snapshot }}
llvm_config: $${ matrix.llvm_config }}
build_args: ${{ matrix.pg_build_args }}
extra_build_args: ${{ matrix.pg_extra_args }}
strategy:
matrix: ${{ fromJson(needs.matrixbuilder.outputs.matrix) }}
fail-fast: false
regress:
name: PG${{ matrix.pg }}${{ matrix.snapshot }} ${{ matrix.name }} ${{ matrix.os }}
needs: matrixbuilder
needs: install_postgresql
runs-on: ${{ matrix.os }}
strategy:
matrix: ${{ fromJson(needs.matrixbuilder.outputs.matrix) }}
Expand All @@ -35,6 +50,20 @@ jobs:
CXX: ${{ matrix.cxx }}

steps:
# on macOS the path used is depending on the runner version leading to cache failure
# when the runner version changes so we extract runner version from path and add it
# as cache suffix
- name: Cache suffix
if: runner.os == 'macOS'
run: echo "CACHE_SUFFIX=-${ImageVersion}" >> $GITHUB_ENV

- name: Get PostgreSQL ${{ github.event.inputs.pg }} from cache
id: cache-postgresql
uses: actions/cache@v2
with:
path: ~/${{ env.PG_SRC_DIR }}
key: ${{ matrix.os }}-postgresql-${{ matrix.pg }}-${{ matrix.cc }}-${{ matrix.build_type }}${{ env.CACHE_SUFFIX }}

- name: Install Linux Dependencies
if: runner.os == 'Linux'
run: |
Expand All @@ -51,45 +80,6 @@ jobs:
sudo perl -MCPAN -e "CPAN::Shell->notest('install', 'IPC::Run')"
sudo perl -MCPAN -e "CPAN::Shell->notest('install', 'Test::Most')"
# on macOS the path used is depending on the runner version leading to cache failure
# when the runner version changes so we extract runner version from path and add it
# as cache suffix
- name: Cache suffix
if: runner.os == 'macOS'
run: echo "CACHE_SUFFIX=-${ImageVersion}" >> $GITHUB_ENV

# we cache the build directory instead of the install directory here
# because extension installation will write files to install directory
# leading to a tainted cache
- name: Cache PostgreSQL ${{ matrix.pg }} ${{ matrix.build_type }}
id: cache-postgresql
if: matrix.snapshot != 'snapshot'
uses: actions/cache@v2
with:
path: ~/${{ env.PG_SRC_DIR }}
key: ${{ matrix.os }}-postgresql-${{ matrix.pg }}-${{ matrix.cc }}-${{ matrix.build_type }}${{ env.CACHE_SUFFIX }}

- name: Build PostgreSQL ${{ matrix.pg }}${{ matrix.snapshot }} ${{ matrix.build_type }}
if: steps.cache-postgresql.outputs.cache-hit != 'true'
run: |
if [ "${{ matrix.snapshot }}" = "snapshot" ]; then
wget -q -O postgresql.tar.bz2 https://ftp.postgresql.org/pub/snapshot/${{ matrix.pg }}/postgresql-${{ matrix.pg }}-snapshot.tar.bz2
else
wget -q -O postgresql.tar.bz2 https://ftp.postgresql.org/pub/source/v${{ matrix.pg }}/postgresql-${{ matrix.pg }}.tar.bz2
fi
mkdir -p ~/$PG_SRC_DIR
tar --extract --file postgresql.tar.bz2 --directory ~/$PG_SRC_DIR --strip-components 1
cd ~/$PG_SRC_DIR
if [[ "${{ runner.os }}" == "Linux" ]]; then
./configure --prefix=$HOME/$PG_INSTALL_DIR ${{ matrix.pg_build_args }} --with-llvm LLVM_CONFIG=${{ matrix.llvm_config }} --with-openssl --without-readline --without-zlib --without-libxml ${{ matrix.pg_extra_args }}
else
# the current github macos image has a buggy llvm installation so we build without llvm on mac
./configure --prefix=$HOME/$PG_INSTALL_DIR ${{ matrix.pg_build_args }} --with-openssl --without-readline --without-zlib --without-libxml ${{ matrix.pg_extra_args }}
fi
make -j $MAKE_JOBS
make -j $MAKE_JOBS -C src/test/isolation
make -j $MAKE_JOBS -C contrib/postgres_fdw
- name: Install PostgreSQL ${{ matrix.pg }} ${{ matrix.build_type }}
run: |
make -C ~/$PG_SRC_DIR install
Expand Down
154 changes: 154 additions & 0 deletions .github/workflows/postgresql-build-and-cache.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
# A reusable workflow to build and cache PostgreSQL. Avoids having to
# include the same PostgreSQL build and cache job in multiple
# workflows that need a specific PostgreSQL build.
#
# The workflow should not be invoked by itself, but instead called
# from other workflows as follows:
#
# jobs:
# install_postgresql:
# uses: './.github/workflows/postgresql-build-and-cache.yaml'
# with:
# os: 'ubuntu-20.4'
# pg: '14.3'
# compiler: 'gcc'
# job_using_postgresl:
# name: Test something using PostgreSQL
# runs-on: ubuntu-20.4
# needs: install_postgresql
#

name: Build and cache PostgreSQL
on:
workflow_call:
inputs:
pg:
description: 'The PostgreSQL version to build'
required: false
type: string
default: '14.2'
c_compiler:
description: 'The C compiler to use'
required: false
type: string
default: 'gcc'
cxx_compiler:
description: 'The C++ compiler to use'
required: false
type: string
default: 'g++'
os:
description: 'Operating system to build for'
required: false
type: string
default: 'ubuntu-20.4'
snapshot:
description: 'Build a snapshot version of PostgreSQL'
required: false
type: string
default: ''
extra_install_packages:
description: 'Extra build packages to install (OS dependent)'
required: false
type: string
default: 'clang-9 llvm-9 llvm-9-dev llvm-9-tools'
clang:
description: 'Clang binary to use'
required: false
type: string
default: 'clang-9'
llvm_config:
description: 'LLVM config to use'
required: false
type: string
default: 'llvm-config-9'
build_args:
description: 'PostgreSQL build arguments'
required: false
type: string
default: '--enable-debug --enable-cassert'
extra_build_args:
description: 'PostgreSQL extra build arguments'
required: false
type: string
default: ''
variant:
description: 'Cache the build using this unique variant key'
required: false
type: string
default: 'Debug'
jobs:
build_postgresql:
name: Build PG${{ inputs.pg }}${{ inputs.snapshot }} ${{ inputs.variant }} ${{ inputs.os }}
runs-on: ${{ inputs.os }}
env:
PG_SRC_DIR: pgbuild
PG_INSTALL_DIR: postgresql
MAKE_JOBS: 6
CC: ${{ inputs.c_compiler }}
CXX: ${{ inputs.cxx_compiler }}
CLANG: ${{ inputs.clang }}
LLVM_CONFIG: ${{ inputs.llvm_config }}
outputs:
pg_src_dir: ${ steps.pg_src_dir.outputs.pg_src_dir }}
pg_install_dir: ${ steps.pg_install_dir.outputs.pg_install_dir }}
steps:
- id: pg_src_dir
run: echo "::set-output name=pg_src_dir::$PG_SRC_DIR"
- id: pg_install_dir
run: echo "::set-output name=pg_install_dir::$PG_INSTALL_DIR"

# on macOS the path used is depending on the runner version leading to cache failure
# when the runner version changes so we extract runner version from path and add it
# as cache suffix
- name: Cache suffix
if: runner.os == 'macOS'
run: echo "CACHE_SUFFIX=-${ImageVersion}" >> $GITHUB_ENV

# we cache the build directory instead of the install directory here
# because extension installation will write files to install directory
# leading to a tainted cache
- name: Cache PostgreSQL ${{ inputs.pg }} ${{ inputs.build_type }}
id: cache-postgresql
if: inputs.snapshot != 'snapshot'
uses: actions/cache@v2
with:
path: ~/${{ env.PG_SRC_DIR }}
key: ${{ inputs.os }}-postgresql-${{ inputs.pg }}-${{ inputs.c_compiler }}-${{ inputs.variant }}${{ env.CACHE_SUFFIX }}

- name: Install Linux Dependencies
if: runner.os == 'Linux' && steps.cache-postgresql.outputs.cache-hit != 'true'
run: |
sudo apt-get update
sudo apt-get install flex bison lcov systemd-coredump gdb libipc-run-perl libtest-most-perl ${{ inputs.extra_install_packages }}

- name: Install macOS Dependencies
if: runner.os == 'macOS' && steps.cache-postgresql.outputs.cache-hit != 'true'
run: |
# This is needed because GitHub image macos-10.15 version
# 20210927.1 did not install OpenSSL so we install openssl
# explicitly.
brew install openssl
sudo perl -MCPAN -e "CPAN::Shell->notest('install', 'IPC::Run')"
sudo perl -MCPAN -e "CPAN::Shell->notest('install', 'Test::Most')"

- name: Build PostgreSQL ${{ inputs.pg }}${{ inputs.snapshot }} ${{ inputs.variant }}
if: steps.cache-postgresql.outputs.cache-hit != 'true'
run: |
if [ "${{ inputs.snapshot }}" = "snapshot" ]; then
wget -q -O postgresql.tar.bz2 https://ftp.postgresql.org/pub/snapshot/${{ inputs.pg }}/postgresql-${{ inputs.pg }}-snapshot.tar.bz2
else
wget -q -O postgresql.tar.bz2 https://ftp.postgresql.org/pub/source/v${{ inputs.pg }}/postgresql-${{ inputs.pg }}.tar.bz2
fi
mkdir -p ~/$PG_SRC_DIR
tar --extract --file postgresql.tar.bz2 --directory ~/$PG_SRC_DIR --strip-components 1
cd ~/$PG_SRC_DIR
if [[ "${{ runner.os }}" == "Linux" ]]; then
./configure --prefix=$HOME/$PG_INSTALL_DIR ${{ inputs.build_args }} --with-llvm LLVM_CONFIG=${{ inputs.llvm_config }} --with-openssl --without-readline --without-zlib --without-libxml ${{ inputs.extra_build_args }}
else
# the current github macos image has a buggy llvm installation so we build without llvm on mac
./configure --prefix=$HOME/$PG_INSTALL_DIR ${{ inputs.build_args }} --with-openssl --without-readline --without-zlib --without-libxml ${{ inputs.extra_build_args }}
fi
make -j $MAKE_JOBS
make -j $MAKE_JOBS -C src/test/isolation
make -j $MAKE_JOBS -C contrib/postgres_fdw
99 changes: 76 additions & 23 deletions .github/workflows/sqlsmith.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,90 @@ on:
# run daily 20:00 on main branch
- cron: '0 2 * * *'
workflow_dispatch:
inputs:
seed:
description: 'SQLsmith seed'
default: '$((16#$(openssl rand -hex 3)))'
type: string
required: true
os:
description: 'The OS to run on'
required: true
default: 'ubuntu-20.04'
type: choice
options:
- 'ubuntu-20.04'
- 'ubuntu-latest'
build_type:
description: 'Build type'
required: true
type: choice
default: 'Debug'
options:
- 'Debug'
- 'Release'
pg:
description: 'PostgreSQL version'
required: true
type: string
default: '14.2'
tsdb_build_args:
description: 'Extra CMake build arguments for TimescaleDB'
required: false
type: string
default: ''
number_of_runs:
description: 'Number of SQLsmith runs'
type: number
default: 10
required: true
max_queries:
description: 'Max number of SQLsmith queries'
type: number
default: 10000
required: true
push:
branches:
- sqlsmith
jobs:
install_postgresql:
uses: './.github/workflows/postgresql-build-and-cache.yaml'
with:
os: ${{ github.event.inputs.os }}
pg: ${{ github.event.inputs.pg }}
variant: ${{ github.event.inputs.build_type }}
regress:
name: SQLsmith PG${{ matrix.pg }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-20.04"]
pg: ["14.2"]
cc: ["gcc"]
build_type: ["Debug"]
fail-fast: false
name: SQLsmith PG${{ github.event.inputs.pg }}
runs-on: ${{ github.event.inputs.os }}
needs: install_postgresql
env:
PG_SRC_DIR: pgbuild
PG_INSTALL_DIR: postgresql

steps:
- name: Install Linux Dependencies
- name: Show environment
run: |
sudo apt-get update
sudo apt-get install flex bison systemd-coredump gdb clang-9 llvm-9 llvm-9-dev llvm-9-tools build-essential autoconf autoconf-archive libpqxx-dev libboost-regex-dev libsqlite3-dev

# this workflow depends on the cached postgres build from the main regression
# workflow since that workflow runs daily there should always be a cache hit
- name: Cache PostgreSQL ${{ matrix.pg }}
echo "PG_SRC_DIR=$PG_SRC_DIR PG_INSTALL_DIR=$PG_INSTALL_DIR"

# this workflow depends on the cached postgres build from the install_postgresql job
- name: Get PostgreSQL ${{ github.event.inputs.pg }} from cache
id: cache-postgresql
uses: actions/cache@v2
with:
path: ~/${{ env.PG_SRC_DIR }}
key: ${{ matrix.os }}-postgresql-${{ matrix.pg }}-${{ matrix.cc }}-${{ matrix.build_type }}
key: ${{ github.event.inputs.os }}-postgresql-${{ github.event.inputs.pg }}-gcc-${{ github.event.inputs.build_type }}

# we abort on cache miss otherwise we would have to reproduce most variables
# of the main regression build matrix in this workflow
- name: Abort on cache miss
if: steps.cache-postgresql.outputs.cache-hit != 'true'
run: false

- name: Install PostgreSQL ${{ matrix.pg }} ${{ matrix.build_type }}
- name: Install Linux Dependencies
run: |
sudo apt-get update
sudo apt-get install flex bison systemd-coredump gdb clang-9 llvm-9 llvm-9-dev llvm-9-tools build-essential autoconf autoconf-archive libpqxx-dev libboost-regex-dev libsqlite3-dev

- name: Install PostgreSQL ${{ github.event.inputs.pg }} ${{ github.event.inputs.build_type }}
run: |
make -C ~/$PG_SRC_DIR install
make -C ~/$PG_SRC_DIR/contrib/postgres_fdw install
Expand All @@ -53,7 +97,7 @@ jobs:

- name: Build TimescaleDB
run: |
./bootstrap -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DPG_SOURCE_DIR=~/$PG_SRC_DIR -DPG_PATH=~/$PG_INSTALL_DIR ${{ matrix.tsdb_build_args }}
./bootstrap -DCMAKE_BUILD_TYPE=${{ github.event.inputs.build_type }} -DPG_SOURCE_DIR=~/$PG_SRC_DIR -DPG_PATH=~/$PG_INSTALL_DIR ${{ github.event.inputs.tsdb_build_args }}
make -C build
make -C build install

Expand Down Expand Up @@ -85,7 +129,9 @@ jobs:
- name: Run SQLsmith
run: |
cd sqlsmith
for i in `seq 1 10`; do ./sqlsmith --seed=$((16#$(openssl rand -hex 3))) --exclude-catalog --target="host=/tmp dbname=smith" --max-queries=10000; done
for i in `seq 1 ${{ github.event.inputs.number_of_runs }}`; do
./sqlsmith --seed=${{ github.event.inputs.seed}} --exclude-catalog --target="host=/tmp dbname=smith" --max-queries=${{ github.event.inputs.max_queries }} --dump-all-queries > queries-$i-${{ github.event.inputs.seed }}.log; \
done

- name: Check for coredumps
if: always()
Expand All @@ -107,7 +153,14 @@ jobs:

- name: Upload Coredumps
if: always() && steps.collectlogs.outputs.coredumps == 'true'
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: Coredumps sqlsmith ${{ matrix.os }} PG${{ matrix.pg }}
name: Coredumps sqlsmith ${{ github.event.inputs.os }} PG${{ github.event.inputs.pg }}
path: coredumps

- name: Upload query logs
if: always()
uses: actions/upload-artifact@v3
with:
name: SQL query logs ${{ github.event.inputs.os }} PG${{ github.event.inputs.pg }}
path: sqlsmith/queries-*.log