Skip to content

Commit

Permalink
Add basic buildfarm setup in Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfgangwalther committed Mar 22, 2024
1 parent af5f7c2 commit 5f99c5d
Show file tree
Hide file tree
Showing 11 changed files with 248 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
root = true

[*.conf]
indent_style = tab
indent_size = tab
tab_width = 4
29 changes: 29 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Lint

on:
pull_request:
push:
branches:
- main

jobs:
actionlint:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: raven-actions/[email protected]


hadolint:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: hadolint/[email protected]
with:
dockerfile: Dockerfile

shellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: ludeeus/[email protected]
52 changes: 52 additions & 0 deletions .github/workflows/run.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Run

on:
schedule:
# The docs suggest not to schedule this on the full hour:
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
- cron: '42 0,6,12,18 * * *'

jobs:
run:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
branch:
- REL_12
- REL_13
- REL_14
- REL_15
- REL_16
- HEAD
name: ${{ matrix.branch }}
steps:
- uses: actions/[email protected]
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Build Dockerfile
uses: docker/[email protected]
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: .
load: true
push: false
tags: buildfarm-client:alpine
- uses: actions/[email protected]
with:
path: buildroot
key: run-alpine-autoconf-${{ matrix.branch }}
- name: Run buildfarm client
run: |
mkdir -p buildroot
docker run --rm \
-v ./buildroot:/home/alpine \
-u "$(id -u):$(id -g)" \
buildfarm-client:alpine \
--test \
--config autoconf.conf \
--delay-check \
${{ matrix.branch }}
# TODO: Remove --delay-check once this is fixed:
# https://www.postgresql.org/message-id/flat/fddd1cd6-dc16-40a2-9eb5-d7fef2101488%40technowledgy.de
41 changes: 41 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Test

on:
pull_request:
push:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest
name: Test autoconf
steps:
- uses: actions/[email protected]
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Build Dockerfile
uses: docker/[email protected]
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: .
load: true
push: false
tags: buildfarm-client:alpine
- uses: actions/[email protected]
with:
path: buildroot
key: test-alpine-autoconf
- name: Test autoconf.conf
run: |
mkdir -p buildroot
docker run --rm \
-v ./buildroot:/home/alpine \
-u "$(id -u):$(id -g)" \
buildfarm-client:alpine \
--test \
--config autoconf.conf \
--delay-check
# TODO: Remove --delay-check once this is fixed:
# https://www.postgresql.org/message-id/flat/fddd1cd6-dc16-40a2-9eb5-d7fef2101488%40technowledgy.de
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
buildroot
5 changes: 5 additions & 0 deletions .hadolint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
failure-threshold: style
ignored:
# repository pinning is better than package pinning for apk
# https://stschindler.medium.com/the-problem-with-docker-and-alpines-package-pinning-18346593e891
- DL3018
43 changes: 43 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM library/alpine:3.19.1@sha256:c5b1261d6d3e43071626931fc004f70149baeba2c8ec672bd4f27761f8e1ad6b

SHELL ["/bin/sh", "-eux", "-c"]

RUN apk add \
--no-cache \
bison \
build-base \
ccache \
flex \
git \
krb5-dev \
# TODO: Make meson find this instead of readline \
#libedit-dev \
libxml2-dev \
libxslt-dev \
linux-headers \
nss_wrapper \
openldap-dev \
openssl-dev \
perl \
perl-dev \
perl-lwp-protocol-https \
perl-mozilla-ca \
python3-dev \
readline-dev \
tcl-dev \
zlib-dev

ARG BUILDFARM_CLIENT_VERSION=REL_17

RUN git clone --depth 1 --branch ${BUILDFARM_CLIENT_VERSION} https://github.com/PGBuildFarm/client-code /usr/src

COPY docker-entrypoint.sh /
COPY *.conf /usr/src

WORKDIR /buildroot
VOLUME /buildroot

ENTRYPOINT ["/docker-entrypoint.sh"]
# TODO: Remove --delay-check once this is fixed:
# https://www.postgresql.org/message-id/flat/fddd1cd6-dc16-40a2-9eb5-d7fef2101488%40technowledgy.de
CMD ["--test", "--config", "autoconf.conf", "--delay-check"]
19 changes: 19 additions & 0 deletions autoconf.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require 'shared.conf';

@PGBuild::conf{animal} = $ENV{AUTOCONF_ANIMAL} // @PGBuild::conf{animal};
@PGBuild::conf{secret} = $ENV{AUTOCONF_SECRET} // @PGBuild::conf{secret};

@PGBuild::conf{make_jobs} = 2;

# TODO: Building with --enable-nls currently fails with:
# ld: ../../src/port/libpgport.a(strerror.o): in function `pg_strerror_r':
# src/port/strerror.c:72:(.text+0x260): undefined reference to `libintl_gettext'
# ld: src/port/strerror.c:72:(.text+0x2d8): undefined reference to `libintl_gettext'
push(@{@PGBuild::conf{config_opts}}, "--disable-nls");

# TODO: Currently failing two tests:
# initdb/001_initdb
# icu / icu/010_database
push(@{@PGBuild::conf{config_opts}}, "--without-icu");

1;
21 changes: 21 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env sh
set -eu

# This script fakes passwd/group files via nss_wrapper to satisfy
# initdb's requirement of having a user with a name. We do this,
# because the uid/gid passed from outside are not known in advance.
# Thus we can't create the corresponding users/groups beforehand.

LD_PRELOAD="/usr/lib/libnss_wrapper.so"
NSS_WRAPPER_PASSWD="$(mktemp)"
NSS_WRAPPER_GROUP="$(mktemp)"

uid="$(id -u)"
gid="$(id -g)"

printf 'postgres:x:%s:%s::/buildroot:/bin/false\n' "$uid" "$gid" > "$NSS_WRAPPER_PASSWD"
printf 'postgres:x:%s:\n' "$gid" > "$NSS_WRAPPER_GROUP"

export LD_PRELOAD NSS_WRAPPER_PASSWD NSS_WRAPPER_GROUP

exec /usr/src/run_build.pl "$@"
13 changes: 13 additions & 0 deletions shared.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require 'build-farm.conf.sample';

@PGBuild::conf{build_root} = '/home/alpine';

@PGBuild::conf{alerts} = {
HEAD => { alert_after => 9, alert_every => 24 }
};

@PGBuild::conf{mail_eventsalerts} = {
all => [$ENV{BUILDFARM_EMAIL_ALL}]
};

1;
18 changes: 18 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env sh
set -eu

# Run this script to test the Dockerfile locally.

docker build .

mkdir -p buildroot
docker run --rm \
-v ./buildroot:/home/alpine \
-u "$(id -u):$(id -g)" \
"$(docker build -q .)" \
--test \
--config autoconf.conf \
--delay-check \
"$@"
# TODO: Remove --delay-check once this is fixed:
# https://www.postgresql.org/message-id/flat/fddd1cd6-dc16-40a2-9eb5-d7fef2101488%40technowledgy.de

0 comments on commit 5f99c5d

Please sign in to comment.