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

Run formatters for all the files in the repo #870

Draft
wants to merge 1 commit into
base: develop
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
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A set of scripts that generate a set of Dockerfiles that generate a set of Docke

## Prerequisites

Building on all these platforms brings some complexity, so be sure you’ve got the prerequisites set up. Packages build using `docker`, so you’ll need that. In addition, you’ll need to generate a GitHub personal access token to allow scripts to call GitHub APIs on your behalf.
Building on all these platforms brings some complexity, so be sure you’ve got the prerequisites set up. Packages build using `docker` , so you’ll need that. In addition, you’ll need to generate a GitHub personal access token to allow scripts to call GitHub APIs on your behalf.

### Docker

Expand All @@ -18,7 +18,7 @@ If you’re on OS X, this dependency presently means you also need `docker-machi
2. Install VirtualBox from [here](https://www.virtualbox.org/wiki/Downloads)
3. `docker-machine create --driver virtualbox default`

After this, `docker` commands will work so long as you’ve run `eval "$(docker-machine env default)"` in the window you’re using. The [Docker Mac beta](https://blog.docker.com/2016/03/docker-for-mac-windows-beta/) will simplify this _greatly_ (no explicit need for `docker-machine`, no need for VirtualBox).
After this, `docker` commands will work so long as you’ve run `eval "$(docker-machine env default)"` in the window you’re using. The [Docker Mac beta](https://blog.docker.com/2016/03/docker-for-mac-windows-beta/) will simplify this _greatly_ (no explicit need for `docker-machine` , no need for VirtualBox).

### GitHub Authentication

Expand All @@ -36,19 +36,19 @@ Unless you have a reason to change the Dockerfiles, just use the images hosted o

To build all packages, run the `build_packages` script from the project root. Output will be put in OS/release-specific subdirectories of a `packages` directory in the project root. `build_packages` expects two arguments: a project name and build type.

The project name must be one of: `citus`, `enterprise`, or `rebalancer`
The project name must be one of: `citus` , `enterprise` , or `rebalancer`

The build type can be `release`, `nightly`, or any valid git reference. `release` builds the latest release tag (which must be signed by a key known to GitHub). `nightly` builds the latest commit from the “main” branch for the specified project. Any other value is interpreted by what it means to git… tags, branches, and commit identifiers are all accepted.
The build type can be `release` , `nightly` , or any valid git reference. `release` builds the latest release tag (which must be signed by a key known to GitHub). `nightly` builds the latest commit from the “main” branch for the specified project. Any other value is interpreted by what it means to git… tags, branches, and commit identifiers are all accepted.

By default, `build_packages` builds on _all_ supported operating systems. Edit `os-list.csv` if you wish to build for fewer.

### Updating Dockerfiles

`update_dockerfiles` generates a new set of Dockerfiles. This repository has automated builds configured, so if you need to change the Docker images, run `update_dockerfiles`, commit the resulting Dockerfile changes, and push.
`update_dockerfiles` generates a new set of Dockerfiles. This repository has automated builds configured, so if you need to change the Docker images, run `update_dockerfiles` , commit the resulting Dockerfile changes, and push.

### Updating Docker Images

Before building the packages yourself you should run `./pull_images`, so that you
Before building the packages yourself you should run `./pull_images` , so that you
get the current upstream layers. This can save some time when building the
packages.
`update_images` will build Docker images for all operating systems specified in `os-list.csv` using the files in the `dockerfiles` directory. This is handy for testing changes to our Docker images.
Expand Down
8 changes: 4 additions & 4 deletions build_packages
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
set -euo pipefail
IFS=$'\n\t'

topdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
topdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
packagesdir=${topdir}/packages
buildfilesdir=${topdir}/buildfiles
badusage=64
Expand Down Expand Up @@ -34,7 +34,7 @@ nprocs="${3:-1}"
declare args

while read -r line; do
IFS=',' read -r os release <<< "$line"
IFS=',' read -r os release <<<"$line"

if [ -z "${release}" ]; then
outputdir="${packagesdir}/${os}"
Expand Down Expand Up @@ -69,8 +69,8 @@ while read -r line; do
# redhat variants need to build each PostgreSQL version separately
IFS=','
for pgversion in ${pgversions}; do
if { [[ "${os}" = 'centos' ]] || [[ "${os}" = 'oraclelinux' ]]; } && \
[[ "${release}" = '6' ]] && [[ "${pgversion}" = '13' ]]; then
if { [[ "${os}" = 'centos' ]] || [[ "${os}" = 'oraclelinux' ]]; } &&
[[ "${release}" = '6' ]] && [[ "${pgversion}" = '13' ]]; then
# CentOS and OracleLinux 6 doesn't have pg13 packages yet
# so we dont't have package builder docker images yet.
# So skip building distro packages for them.
Expand Down
14 changes: 6 additions & 8 deletions ci/push_images
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@ set -euo pipefail
IFS=$'\n\t'

pgversions='10 11 12 13 14'
topdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/.."
topdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.."
dockerfiles_dir="${topdir}/dockerfiles"

badusage=64

nprocs="${1:-1}"

if [[ ${CURRENT_BRANCH} != "develop" ]] ; then
if [[ ${CURRENT_BRANCH} != "develop" ]]; then
echo "PR is not merged to develop, not pushing to DockerHub"
exit 0;
exit 0
fi

echo "${DOCKERHUB_PASSWORD}" | docker login -u "${DOCKERHUB_USER_NAME}" --password-stdin

declare args

while read -r line; do
IFS=',' read -r os release <<< "$line"
IFS=',' read -r os release <<<"$line"

if [[ "${os}" = 'debian' ]] || [[ "${os}" = 'ubuntu' ]]; then
tag="${os}-${release}-all"
Expand All @@ -31,8 +31,8 @@ while read -r line; do
# redhat variants need an image for each PostgreSQL version
IFS=' '
for pgversion in ${pgversions}; do
if { [[ "${os}" = 'centos' ]] || [[ "${os}" = 'oraclelinux' ]]; } && \
[[ "${release}" = '6' ]] && [[ "${pgversion}" = '13' ]]; then
if { [[ "${os}" = 'centos' ]] || [[ "${os}" = 'oraclelinux' ]]; } &&
[[ "${release}" = '6' ]] && [[ "${pgversion}" = '13' ]]; then
# CentOS and OracleLinux 6 doesn't have pg13 packages yet.
# So skip building docker images for them.
continue
Expand All @@ -51,5 +51,3 @@ while read -r line; do
done <"${topdir}/os-list.csv"

echo -e "${args}" | xargs -t -L1 -P "${nprocs}" docker


2 changes: 1 addition & 1 deletion dockerfiles/centos-7-pg10/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ RUN yum -y update
RUN ( yum install -y yum-plugin-ovl || yum install -y yum-plugin-ovl || touch /var/lib/rpm/* ) \
&& yum clean all

# Enable some other repos for some dependencies in OL/7
# Enable some other repos for some dependencies in OL/7
# see https://yum.oracle.com/getting-started.html#installing-from-oracle-linux-yum-server
RUN [[ centos != oraclelinux ]] || [[ 7 != 7 ]] || ( \
yum install -y oraclelinux-release-el7 oracle-softwarecollection-release-el7 oracle-epel-release-el7 oraclelinux-developer-release-el7 \
Expand Down
172 changes: 86 additions & 86 deletions dockerfiles/centos-7-pg10/scripts/fetch_and_build_rpm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ builddir=$(pwd)

# outputs usage message on specified device before exiting with provided status
usage() {
cat << 'E_O_USAGE' >&"$1"
cat <<'E_O_USAGE' >&"$1"
usage: fetch_and_build_rpm build_type build_directory

build_type: 'release', 'nightly', or a valid git reference
Expand All @@ -28,7 +28,7 @@ the latest 'master' commit, and any other type is interpreted as a git ref to
facilitate building one-off packages for customers.
E_O_USAGE

exit "${2}";
exit "${2}"
}

# sets the next version variable used during non-release builds
Expand Down Expand Up @@ -64,7 +64,7 @@ if [ -z "${pkglatest}" ]; then
exit $noinput
fi

echo "header=\"Authorization: token ${GITHUB_TOKEN}\"" > ~/.curlrc
echo "header=\"Authorization: token ${GITHUB_TOKEN}\"" >~/.curlrc

name=$(determine_name)
email=$(determine_email)
Expand All @@ -74,62 +74,62 @@ cp "/buildfiles/${pkgname}.spec" /buildfiles/rpmlintrc "${builddir}"
repopath="citusdata/${hubproj}"

case "${1}" in
release)
packageversion=${pkglatest%-*}
releasetag="v${packageversion%.citus}"

packagerelease=$(echo "${pkglatest#*-}" | sed -E 's/^[0-9.]+//')
if [ -n "${packagerelease}" ]; then
releasetag="v${packageversion}-${packagerelease}"
fi

conf_extra_version="%{nil}"

gitsha=$(curl -s "https://api.github.com/repos/${repopath}/git/refs/tags/${releasetag}" | \
jq -r '.object.sha')
if [ "${gitsha}" == 'null' ]; then
echo "$0: could not determine commit for git tag ${releasetag}" >&2
exit $failure
fi

verified=$(curl -sH 'Accept:application/vnd.github.cryptographer-preview+sha' \
"https://api.github.com/repos/${repopath}/git/tags/${gitsha}" | \
jq -r '.verification.verified')
if [ "${verified}" != 'true' ]; then
echo "$0: could not verify signature for git tag ${releasetag}" >&2
exit $failure
fi
;;
*)
if [ "${1}" == 'nightly' ]; then
ref=${nightlyref}
infix='git'
else
ref=${1}
infix='pre'
fi

setnextversion "${pkglatest}"

set +e
gitsha=$(curl -sfH 'Accept:application/vnd.github.v3.sha' \
"https://api.github.com/repos/${repopath}/commits/${ref}")
if [ "${?}" -ne 0 ]; then
echo "$0: could not determine commit for git ref ${ref}" >&2
exit $failure
fi
set -e

packageversion="${nextversion}.citus"
timestamp=$(date +'%Y%m%d')
packagesuffix="${infix}.${timestamp}.${gitsha:0:7}"
packagerelease="0.0.${packagesuffix}"
conf_extra_version="+${packagesuffix}"

sed -i -E -e "/^Version:/s/[^ \\t]*$/${packageversion}/" \
-e "/^Release:/s/[^ \\t]*$/${packagerelease}%{dist}/" \
"${builddir}/${pkgname}.spec"
;;
release)
packageversion=${pkglatest%-*}
releasetag="v${packageversion%.citus}"

packagerelease=$(echo "${pkglatest#*-}" | sed -E 's/^[0-9.]+//')
if [ -n "${packagerelease}" ]; then
releasetag="v${packageversion}-${packagerelease}"
fi

conf_extra_version="%{nil}"

gitsha=$(curl -s "https://api.github.com/repos/${repopath}/git/refs/tags/${releasetag}" |
jq -r '.object.sha')
if [ "${gitsha}" == 'null' ]; then
echo "$0: could not determine commit for git tag ${releasetag}" >&2
exit $failure
fi

verified=$(curl -sH 'Accept:application/vnd.github.cryptographer-preview+sha' \
"https://api.github.com/repos/${repopath}/git/tags/${gitsha}" |
jq -r '.verification.verified')
if [ "${verified}" != 'true' ]; then
echo "$0: could not verify signature for git tag ${releasetag}" >&2
exit $failure
fi
;;
*)
if [ "${1}" == 'nightly' ]; then
ref=${nightlyref}
infix='git'
else
ref=${1}
infix='pre'
fi

setnextversion "${pkglatest}"

set +e
gitsha=$(curl -sfH 'Accept:application/vnd.github.v3.sha' \
"https://api.github.com/repos/${repopath}/commits/${ref}")
if [ "${?}" -ne 0 ]; then
echo "$0: could not determine commit for git ref ${ref}" >&2
exit $failure
fi
set -e

packageversion="${nextversion}.citus"
timestamp=$(date +'%Y%m%d')
packagesuffix="${infix}.${timestamp}.${gitsha:0:7}"
packagerelease="0.0.${packagesuffix}"
conf_extra_version="+${packagesuffix}"

sed -i -E -e "/^Version:/s/[^ \\t]*$/${packageversion}/" \
-e "/^Release:/s/[^ \\t]*$/${packagerelease}%{dist}/" \
"${builddir}/${pkgname}.spec"
;;
esac

# this should all take place in a package-build directory
Expand All @@ -149,8 +149,8 @@ tar czf "${tarballpath}" "${pkgsrcdir}"

# force our URL and expanded folder names into spec
sed -i -E -e "\\|^Source0:|s|https:.*|${tarballurl}|" \
-e "/^%global pgmajorversion/s/[0-9]+$/${PGVERSION//'.'/}/" \
-e "/^%global pgpackageversion/s/[0-9.]+$/${PGVERSION}/" \
-e "/^%global pgmajorversion/s/[0-9]+$/${PGVERSION//'.'/}/" \
-e "/^%global pgpackageversion/s/[0-9.]+$/${PGVERSION}/" \
"${builddir}/${pkgname}.spec"

osname=$(awk '{print $1}' /etc/system-release)
Expand All @@ -163,25 +163,25 @@ else
fi

case "${1}" in
release)
# add minor/major version to package name if using fancy versioning
if [ "${versioning}" == 'fancy' ]; then
infix=$(echo "${packageversion}" | grep -oE '^[0-9]+\.[0-9]+' | tr -d '.')
sed -i -E "1i %global pkginfix ${infix}" "${builddir}/${pkgname}.spec"
fi
;;
nightly)
msg="Nightly package. Built from ${nightlyref} "
msg+=$(date +'on %l:%M %p (%Z) on %A, %B %Y' | tr -s ' ')
LC_ALL=${locale} rpmdev-bumpspec -c "${msg}" "${builddir}/${pkgname}.spec"
sed -i -E 's/0.1.git/0.0.git/' "${builddir}/${pkgname}.spec"
;;
*)
msg="Custom package. Built from ${gitsha:0:7} "
msg+=$(date +'on %l:%M %p (%Z) on %A, %B %Y' | tr -s ' ')
LC_ALL=${locale} rpmdev-bumpspec -c "${msg}" "${builddir}/${pkgname}.spec"
sed -i -E 's/0.1.pre/0.0.pre/' "${builddir}/${pkgname}.spec"
;;
release)
# add minor/major version to package name if using fancy versioning
if [ "${versioning}" == 'fancy' ]; then
infix=$(echo "${packageversion}" | grep -oE '^[0-9]+\.[0-9]+' | tr -d '.')
sed -i -E "1i %global pkginfix ${infix}" "${builddir}/${pkgname}.spec"
fi
;;
nightly)
msg="Nightly package. Built from ${nightlyref} "
msg+=$(date +'on %l:%M %p (%Z) on %A, %B %Y' | tr -s ' ')
LC_ALL=${locale} rpmdev-bumpspec -c "${msg}" "${builddir}/${pkgname}.spec"
sed -i -E 's/0.1.git/0.0.git/' "${builddir}/${pkgname}.spec"
;;
*)
msg="Custom package. Built from ${gitsha:0:7} "
msg+=$(date +'on %l:%M %p (%Z) on %A, %B %Y' | tr -s ' ')
LC_ALL=${locale} rpmdev-bumpspec -c "${msg}" "${builddir}/${pkgname}.spec"
sed -i -E 's/0.1.pre/0.0.pre/' "${builddir}/${pkgname}.spec"
;;
esac

# Enable gcc8 on distros that have it
Expand All @@ -193,11 +193,11 @@ if [ -f /opt/rh/devtoolset-8/enable ]; then
fi

rpmbuild --define "_sourcedir ${rpmbuilddir}" \
--define "_specdir ${rpmbuilddir}" \
--define "_builddir ${rpmbuilddir}" \
--define "_srcrpmdir ${rpmbuilddir}" \
--define "_rpmdir ${rpmbuilddir}" \
--define "conf_extra_version ${conf_extra_version}" \
-bb "${builddir}/${pkgname}.spec"
--define "_specdir ${rpmbuilddir}" \
--define "_builddir ${rpmbuilddir}" \
--define "_srcrpmdir ${rpmbuilddir}" \
--define "_rpmdir ${rpmbuilddir}" \
--define "conf_extra_version ${conf_extra_version}" \
-bb "${builddir}/${pkgname}.spec"

cp /citus-rpm-build/x86_64/*.rpm /packages
2 changes: 1 addition & 1 deletion dockerfiles/centos-7-pg11/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ RUN yum -y update
RUN ( yum install -y yum-plugin-ovl || yum install -y yum-plugin-ovl || touch /var/lib/rpm/* ) \
&& yum clean all

# Enable some other repos for some dependencies in OL/7
# Enable some other repos for some dependencies in OL/7
# see https://yum.oracle.com/getting-started.html#installing-from-oracle-linux-yum-server
RUN [[ centos != oraclelinux ]] || [[ 7 != 7 ]] || ( \
yum install -y oraclelinux-release-el7 oracle-softwarecollection-release-el7 oracle-epel-release-el7 oraclelinux-developer-release-el7 \
Expand Down
Loading