Skip to content

Commit

Permalink
Remove the need to update anything but versions.yaml
Browse files Browse the repository at this point in the history
No need to update the Makefile, Dockerfile, or workflow files
for most standard extension version changes. Timescaledb, toolkit,
and promscale versions are all taken from versions.yaml unless
overridden by the environment variables.

This also adds `all` and `latest` as version specifications as well
when they're the only item in the `*_VERSIONS` environment variables.
These expand to all available, or the latest available versions from
`versions.yaml`.
  • Loading branch information
graveland committed Feb 6, 2023
1 parent 59f1b67 commit 3f3b40d
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 40 deletions.
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -289,13 +289,13 @@ RUN set -ex; \
/build/scripts/install_extensions timescaledb

# install all rust packages in the same step to allow it to optimize for cargo-pgx installs
ARG TIMESCALE_PROMSCALE_EXTENSIONS
ARG TIMESCALEDB_TOOLKIT_EXTENSIONS
ARG PROMSCALE_VERSIONS
ARG TOOLKIT_VERSIONS
RUN set -ex; \
OSS_ONLY="${OSS_ONLY}" \
RUST_RELEASE="${RUST_RELEASE}" \
PROMSCALE_VERSIONS="${TIMESCALE_PROMSCALE_EXTENSIONS}" \
TOOLKIT_VERSIONS="${TIMESCALEDB_TOOLKIT_EXTENSIONS}" \
PROMSCALE_VERSIONS="${PROMSCALE_VERSIONS}" \
TOOLKIT_VERSIONS="${TOOLKIT_VERSIONS}" \
/build/scripts/install_extensions rust

USER root
Expand Down Expand Up @@ -380,8 +380,8 @@ ARG RELEASE_URL
RUN echo "TIMESCALEDB_VERSIONS=\"${TIMESCALEDB_VERSIONS}\"" > /.image_config; \
echo "OSS_ONLY=\"$OSS_ONLY\"" >> /.image_config; \
echo "TIMESCALE_DCS_FAILSAFE=\"${TIMESCALE_DCS_FAILSAFE}\"" >> /.image_config; \
echo "PROMSCALE_VERSIONS=\"${TIMESCALE_PROMSCALE_EXTENSIONS}\"" >> /.image_config; \
echo "TOOLKIT_VERSIONS=\"${TIMESCALEDB_TOOLKIT_EXTENSIONS}\"" >> /.image_config; \
echo "PROMSCALE_VERSIONS=\"${PROMSCALE_VERSIONS}\"" >> /.image_config; \
echo "TOOLKIT_VERSIONS=\"${TOOLKIT_VERSIONS}\"" >> /.image_config; \
echo "PG_LOGERRORS=\"${PG_LOGERRORS}\"" >> /.image_config; \
echo "PG_STAT_MONITOR=\"${PG_STAT_MONITOR}\"" >> /.image_config; \
echo "POSTGIS_VERSIONS=\"${POSTGIS_VERSIONS}\"" >> /.image_config; \
Expand Down
23 changes: 15 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ POSTGIS_VERSIONS?=3
PG_AUTH_MON?=v1.0
PG_STAT_MONITOR?=1.1.1
PG_LOGERRORS?=3c55887b
TIMESCALEDB_VERSIONS?=1.7.5 2.1.0 2.1.1 2.2.0 2.2.1 2.3.0 2.3.1 2.4.0 2.4.1 2.4.2 2.5.0 2.5.1 2.5.2 2.6.0 2.6.1 2.7.0 2.7.1 2.7.2 2.8.0 2.8.1 2.9.0 2.9.1 2.9.2
TIMESCALE_PROMSCALE_EXTENSIONS?=0.5.0 0.5.1 0.5.2 0.5.4 0.6.0 0.7.0 0.8.0
TIMESCALEDB_TOOLKIT_EXTENSIONS?=1.6.0 1.7.0 1.8.0 1.10.1 1.11.0 1.12.0 1.12.1 1.13.0 1.13.1
TIMESCALEDB_VERSIONS?=all
PROMSCALE_VERSIONS?=all
TOOLKIT_VERSIONS?=all
TIMESCALE_DCS_FAILSAFE?=true

# This is used to build the docker --platform, so pick amd64 or arm64
Expand Down Expand Up @@ -117,8 +117,8 @@ DOCKER_BUILD_COMMAND=docker build \
--build-arg POSTGIS_VERSIONS=$(POSTGIS_VERSIONS) \
--build-arg OSS_ONLY="$(OSS_ONLY)" \
--build-arg TIMESCALEDB_VERSIONS="$(TIMESCALEDB_VERSIONS)" \
--build-arg TIMESCALE_PROMSCALE_EXTENSIONS="$(TIMESCALE_PROMSCALE_EXTENSIONS)" \
--build-arg TIMESCALEDB_TOOLKIT_EXTENSIONS="$(TIMESCALEDB_TOOLKIT_EXTENSIONS)" \
--build-arg PROMSCALE_VERSIONS="$(PROMSCALE_VERSIONS)" \
--build-arg TOOLKIT_VERSIONS="$(TOOLKIT_VERSIONS)" \
--build-arg TIMESCALE_DCS_FAILSAFE="$(TIMESCALE_DCS_FAILSAFE)" \
--build-arg RELEASE_URL="$(DOCKER_RELEASE_URL)" \
--build-arg BUILDER_URL="$(DOCKER_BUILDER_URL)" \
Expand All @@ -135,15 +135,22 @@ DOCKER_BUILD_COMMAND=docker build \
# This is basically useful for developers of this repository, to allow fast feedback cycles.
.PHONY: fast
fast: DOCKER_EXTRA_BUILDARGS= --build-arg GITHUB_TAG=master
fast: ALL_VERSIONS=false
fast: PG_AUTH_MON=
fast: PG_LOGERRORS=
fast: PG_VERSIONS=15
fast: POSTGIS_VERSIONS=
fast: TIMESCALEDB_TOOLKIT_EXTENSIONS=
fast: TIMESCALE_PROMSCALE_EXTENSION=
fast: ALLOW_ADDING_EXTENSIONS=true
fast: TOOLKIT_VERSIONS=
fast: PROMSCALE_VERSIONS=
fast: build

.PHONY: latest
latest: ALL_VERSIONS=false
latest: TIMESCALEDB_VERSIONS=latest
latest: TOOLKIT_VERSIONS=latest
latest: PROMSCALE_VERSIONS=latest
latest: build

prune: # docker system prune -af
docker system prune -af

Expand Down
3 changes: 1 addition & 2 deletions build_scripts/install_extensions
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ timescaledb | all)
for ver in $TIMESCALEDB_VERSIONS; do
install_timescaledb "$ver"
done
timescaledb_post_install

if [ "$DRYRUN" != true ]; then timescaledb_post_install; fi
;;& # fallthrough to get rust as well if we're called with 'all'
rust | all) install_rust_extensions;;
Expand Down
26 changes: 23 additions & 3 deletions build_scripts/shared.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ set -e -o pipefail

ORIGINAL_PATH="$PATH"

ARCH="$(arch)"
# standardize architecture names
if [ "$ARCH" = arm64 ]; then
ARCH=aarch64
elif [ "$ARCH" = x86_64 ]; then
ARCH=amd64
fi

require_supported_arch() {
if [[ "$ARCH" != amd64 && "$ARCH" != aarch64 ]]; then
echo "unsupported architecture: $ARCH" >&2
exit 1
fi
}

log() {
echo "$ARCH: $*" >&2
}
Expand Down Expand Up @@ -109,7 +124,12 @@ require_cargo_pgx_version() {
}

available_pg_versions() {
(cd /usr/lib/postgresql && ls)
# this allows running out-of-container with dry-run to test script logic
if [[ "$DRYRUN" = true && ! -d /usr/lib/postgresql ]]; then
echo 12 13 14 15
else
(cd /usr/lib/postgresql && ls)
fi
}

cargo_pgx_init() {
Expand Down Expand Up @@ -179,9 +199,9 @@ install_deb() {
}

# This is where we set arch/pg/extension version support checks, used by install and cicd
. "$SCRIPT_DIR"/shared_versions.sh
[ -s "$SCRIPT_DIR/shared_versions.sh" ] && . "$SCRIPT_DIR"/shared_versions.sh

# This is where the actual installation functions are
. "$SCRIPT_DIR"/shared_install.sh
[ -s "$SCRIPT_DIR/shared_install.sh" ] && . "$SCRIPT_DIR"/shared_install.sh

require_supported_arch
47 changes: 32 additions & 15 deletions build_scripts/shared_versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,6 @@ WANTED_PACKAGES="patroni pgbackrest timescaledb-tools"
# otherwise it returns a reason string. Both the cicd/install_checks, and the install_extensions scripts use
# this to decide what should be built/included.

ARCH="$(arch)"
# standardize architecture names
if [ "$ARCH" = arm64 ]; then
ARCH=aarch64
elif [ "$ARCH" = x86_64 ]; then
ARCH=amd64
fi

require_supported_arch() {
if [[ "$ARCH" != amd64 && "$ARCH" != aarch64 ]]; then
echo "unsupported architecture: $ARCH" >&2
exit 1
fi
}

if [ -s /build/scripts/versions.yaml ]; then
VERSION_DATA="$(< /build/scripts/versions.yaml)"
elif [ -s /cicd/scripts/versions.yaml ]; then
Expand All @@ -42,6 +27,34 @@ DEFAULT_PG_MAX="$(yq .default-pg-max <<< "$VERSION_DATA")"
DEFAULT_CARGO_PGX="$(yq .default-cargo-pgx <<< "$VERSION_DATA")"
[ -z "$DEFAULT_CARGO_PGX" ] && { error "default-cargo-pgx required in versions.yaml"; exit 1; }

pkg_versions() {
local pkg="$1"
yq ".$pkg | keys | .[]" <<<"$VERSION_DATA" | xargs
}

# expand the list of requested package versions (usage: $1=pkg $2=single argument with the contents of the environment
# variable containing the requested versions)
requested_pkg_versions() {
local pkg="$1" envvar="$2"
local -a versions
readarray -t versions <<< "$envvar"
case "${#versions[@]}" in
0) return;;
1) case "${versions[0]}" in
all) pkg_versions "$pkg"; return;;
latest) latest_pkg_version "$pkg"; return;;
esac;;
esac
echo "$envvar"
}

latest_pkg_version() {
local pkg="$1"
local -a versions
readarray -t versions <<< "$(yq ".$pkg | keys | .[]" <<<"$VERSION_DATA")"
echo "${versions[-1]}"
}

# locate the cargo-pgx key from versions.yaml
pkg_cargo_pgx_version() {
local pkg="$1" ver="$2" cargopgx
Expand Down Expand Up @@ -153,3 +166,7 @@ supported_promscale() {

version_is_supported promscale "$pg" "$ver"
}

TIMESCALEDB_VERSIONS="$(requested_pkg_versions timescaledb "$TIMESCALEDB_VERSIONS")"
TOOLKIT_VERSIONS="$(requested_pkg_versions toolkit "$TOOLKIT_VERSIONS")"
PROMSCALE_VERSIONS="$(requested_pkg_versions promscale "$PROMSCALE_VERSIONS")"
2 changes: 0 additions & 2 deletions build_scripts/versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ promscale:
pg-max: 14
cargo-pgx: 0.4.5
0.8.0:
master:

toolkit:
1.6.0:
Expand All @@ -114,4 +113,3 @@ toolkit:
1.13.0:
pg-max: 14
1.13.1:
main:
6 changes: 2 additions & 4 deletions cicd/shared.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ else
exit 1
fi

require_supported_arch

VERBOSE=""
EXIT_STATUS=0

Expand Down Expand Up @@ -130,7 +128,7 @@ check_oss_extensions() {
}

check_promscale() {
if [ -z "$PROMSCALE_VERSIONS" ]; then return 0; fi
if [ -z "$PROMSCALE_VERSIONS" ]; then return; fi
local pg="$1" lib="$2" ver found=false

if [ "$OSS_ONLY" = true ]; then
Expand Down Expand Up @@ -164,7 +162,7 @@ check_promscale() {
}

check_toolkit() {
if [ -z "$TOOLKIT_VERSIONS" ]; then return 0; fi
if [ -z "$TOOLKIT_VERSIONS" ]; then return; fi
local pg="$1" lib="$2" found=false

if [ "$OSS_ONLY" = true ]; then
Expand Down

0 comments on commit 3f3b40d

Please sign in to comment.