Skip to content

CI

CI #3747

Workflow file for this run

name: CI
on:
pull_request:
push:
branches:
- main
- staging
- trying
schedule:
# TimescaleDB integration: 8am UTC, 3am Eastern, midnight Pacific
- cron: '0 8 * * 1-4'
# Testing on every platform: 6am UTC, 1am Eastern, 10pm Pacific
- cron: '0 6 * * 1-4'
workflow_dispatch:
inputs:
container-image:
description: 'Container image to pull from DockerHub'
required: false
tsdb-commit:
description: 'TimescaleDB commit to use'
default: ''
required: false
tsdb-repo:
description: 'TimescaleDB repo to use'
default: 'https://github.com/timescale/timescaledb.git'
required: false
all-platforms:
description: 'Test all platforms'
type: boolean
default: false
jobs:
testpostgres:
name: Test Postgres
runs-on: ubuntu-20.04
container:
image: ${{ inputs.container-image || 'timescaledev/toolkit-builder-test' }}:${{ matrix.container.image }}
strategy:
fail-fast: false
max-parallel: 12
matrix:
pgversion: [14, 15, 16, 17]
container:
- os: rockylinux
version: "9"
image: rockylinux-9-x86_64
# Building TSDB in CI is only supported on Debian/Ubuntu
skip: ${{ inputs.tsdb-commit != '' }}
schedule: ${{ !(github.event_name == 'schedule' && github.event.schedule == '0 8 * * 1-4') }}
- os: debian
version: "11"
image: debian-11-amd64
schedule: true
- os: debian
version: "10"
image: debian-10-amd64
schedule: ${{ inputs.all-platforms || ( github.event_name == 'schedule' && github.event.schedule == '0 6 * * 1-4' ) }}
- os: ubuntu
version: "20.04"
image: ubuntu-20.04-amd64
schedule: ${{ inputs.all-platforms || ( github.event_name == 'schedule' && github.event.schedule == '0 6 * * 1-4' ) }}
- os: ubuntu
version: "22.04"
image: ubuntu-22.04-amd64
schedule: ${{ inputs.all-platforms || ( github.event_name == 'schedule' && github.event.schedule == '0 6 * * 1-4' ) }}
exclude:
- container:
skip: true
- container:
schedule: false
include:
# TimescaleDB as of 2.12.0 no longer supports PostgreSQL 12.
# To allow us to do run CI against PostgreSQL 12, we therefore explicitly
# remove all CI's, except if we are run against the latest supported TimescaleDB
# version for PostgreSQL 12, which is 2.11.2
- pgversion: 12
container:
image: debian-11-amd64
os: debian
version: "11"
tsdb_commit: 2.11.2
# TimescaleDB as of 2.16.0 no longer supports PostgreSQL 13.
# To allow us to do run CI against PostgreSQL 13, we therefore explicitly
# remove all CI's, except if we are run against the latest supported TimescaleDB
# version for PostgreSQL 13, which is 2.15.3
- pgversion: 13
container:
image: debian-11-amd64
os: debian
version: "11"
tsdb_commit: 2.15.3
env:
# TODO Why? Cargo default is to pass `-C incremental` to rustc; why don't we want that?
# https://doc.rust-lang.org/rustc/codegen-options/index.html#incremental
# Well turning it off takes the extension target size down from 3G to 2G...
CARGO_INCREMENTAL: 0
# TODO Why? If we're concerned about trouble fetching crates, why not
# just fetch them once at the time we select a dependency?
# Errors fetching crates are probably rare enough that we don't see the
# need to bother, but then why not just let the build fail?
CARGO_NET_RETRY: 10
# TODO What reads this? It's not listed on
# https://doc.rust-lang.org/cargo/reference/environment-variables.html
CI: 1
RUST_BACKTRACE: short
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
# Github Actions provides a bind mounted working directory for us, where
# the above checkout happens, and where caches are read from and restored
# to, and it's all owned by 1001. Our container image is `USER root` so
# we have no problem writing anywhere, but we run some things as user
# 'postgres', which used to be user 1000 but is now 1001. Hoping in the
# future to make our container image `USER postgres` and further simplify
# this file and the packaging Actions file, but it's non-trivial.
- name: chown Repository
run: chown -R postgres .
- name: Build and install TimescaleDB
if: ${{ (github.event_name == 'schedule' && github.event.schedule == '0 8 * * 1-4') || inputs.tsdb-commit != '' }}
run: ./tools/install-timescaledb '${{ matrix.pgversion }}' '${{ inputs.tsdb-repo || 'https://github.com/timescale/timescaledb.git' }}' '${{ inputs.tsdb-commit == '' && 'main' || matrix.tsdb_commit || inputs.tsdb-commit }}'
# TODO After the container image contains a primed target dir, is this still worth it?
# Only possible advantage is this one is per-pg-version but what's the impact?
- name: Cache cargo target dir
uses: actions/cache@v3
if: ${{ matrix.container.image == 'debian-11-amd64' }}
with:
path: target
key: ${{ runner.os }}-test-pg${{ matrix.pgversion }}-target-${{ hashFiles('Cargo.lock', '.github/workflows/ci.yml') }}
restore-keys: ${{ runner.os }}-test-pg${{ matrix.pgversion }}-target-
- name: Run pgrx tests
run: |
if [ "${{ matrix.container.version }}" = 7 ]; then
# needed for pgrx to find clang
set +e # will succeed but have non-zero exit code
. scl_source enable llvm-toolset-7
set -e
fi
su postgres -c 'sh tools/build -pg${{ matrix.pgversion }} test-extension 2>&1'
- name: Run doc tests
# depends on TSDB, which requires PG >=13
if: ${{ matrix.pgversion >= 13 && (matrix.pgversion >= 13 && (matrix.pgversion <= 15 || ((github.event_name == 'schedule' && github.event.schedule == '0 8 * * 1-4') || inputs.tsdb-commit != ''))) }}
run: su postgres -c 'sh tools/build -pg${{ matrix.pgversion }} test-doc 2>&1'
- name: Run binary update tests (deb)
# depends on TSDB, which requires PG >=13
if: ${{ (matrix.container.os == 'debian' || matrix.container.os == 'ubuntu') && (matrix.pgversion >= 13 && (matrix.pgversion <= 16 || ((github.event_name == 'schedule' && github.event.schedule == '0 8 * * 1-4') || inputs.tsdb-commit != ''))) }}
run: |
su postgres -c 'OS_NAME=${{ matrix.container.os }} OS_VERSION=${{ matrix.container.version }} tools/testbin -version no -bindir / -pgversions ${{ matrix.pgversion }} ci 2>&1'
- name: Run binary update tests (EL)
if: ${{ (matrix.container.os == 'rockylinux') && matrix.container.version != '9' && (matrix.pgversion >= 13 && (matrix.pgversion <= 16 || ((github.event_name == 'schedule' && github.event.schedule == '0 8 * * 1-4') || inputs.tsdb-commit != ''))) }}
run: |
su postgres -c 'OS_NAME=${{ matrix.container.os }} OS_VERSION=${{ matrix.container.version }} tools/testbin -version no -bindir / -pgversions ${{ matrix.pgversion }} rpm_ci 2>&1'
testcrates:
name: Test Crates
runs-on: ubuntu-20.04
container:
image: ${{ inputs.container-image || 'timescaledev/toolkit-builder' }}:debian-11-amd64
env:
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
CI: 1
RUST_BACKTRACE: short
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: chown Repository
run: chown -R postgres .
- name: Cache cargo target dir
uses: actions/cache@v3
with:
path: target
key: ${{ runner.os }}-test-crates-target-${{ hashFiles('Cargo.lock', '.github/workflows/ci.yml') }}
restore-keys: ${{ runner.os }}-test-crates-target-
- name: Run Crates Tests
run: su postgres -c 'sh tools/build test-crates 2>&1'