Skip to content
Open
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
16 changes: 9 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ permissions:

jobs:
package-build:

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
distro: [focal]
steps:
- uses: actions/checkout@v6
- name: Run package build focal
run: script/cibuild-create-packages-focal
- name: Run package build ${{ matrix.distro }}
run: script/cibuild-create-packages ${{ matrix.distro }}
- name: Tar files
run: tar -cvf glb-director.tar $GITHUB_WORKSPACE/tmp/build
run: tar -cvf glb-director-${{ matrix.distro }}.tar $GITHUB_WORKSPACE/tmp/build
- name: Upload Artifact
uses: actions/upload-artifact@v7
with:
name: glb-director
path: glb-director.tar
name: glb-director-${{ matrix.distro }}
path: glb-director-${{ matrix.distro }}.tar
72 changes: 72 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Tests

on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master

permissions:
contents: read

jobs:
build-images:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
distro: [focal]
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build image
run: |
docker build --file script/Dockerfile.${{ matrix.distro }} --tag glb-director-build-${{ matrix.distro }}:latest .
docker save glb-director-build-${{ matrix.distro }}:latest --output glb-director-build-${{ matrix.distro }}.tar

- name: Upload image artifact
uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.distro }}
path: glb-director-build-${{ matrix.distro }}.tar
retention-days: 1



test:
needs: build-images
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test-suite: [director, director-xdp, healthcheck, redirect]
distro: [focal]
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Download image artifact
uses: actions/download-artifact@v4
with:
name: build-${{ matrix.distro }}

- name: Load Docker image
run: |
docker load --input glb-director-build-${{ matrix.distro }}.tar

- name: Run test suite in container
run: |
docker run --rm \
--privileged \
--volume $(pwd):/workspace \
--workdir /workspace \
glb-director-build-${{ matrix.distro }}:latest \
bash -c "cd /workspace/src/glb-${{ matrix.test-suite }} && script/test"
20 changes: 18 additions & 2 deletions script/Dockerfile.focal
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:focal
FROM --platform=linux/amd64 ubuntu:focal@sha256:8feb4d8ca5354def3d8fce243717141ce31e2c428701f6682bd2fafe15388214

RUN echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80-retries

Expand All @@ -18,6 +18,11 @@ RUN wget --quiet https://golang.org/dl/go1.24.5.linux-amd64.tar.gz -O- | tar -C
ENV GOROOT /usr/local/go
ENV GOPATH /go
ENV PATH="${GOPATH}/bin:${GOROOT}/bin:${PATH}"
# Disable VCS stamping in Go 1.24+ builds. The repo is bind-mounted from the
# host so git refuses to operate on it inside the container ("dubious
# ownership"), which causes `go build` to fail with
# "error obtaining VCS status: exit status 128".
ENV GOFLAGS=-buildvcs=false

# fpm for packaging
RUN apt-get update && apt-get install -y ruby ruby-dev rubygems build-essential
Expand All @@ -30,11 +35,22 @@ RUN gem install rake fpm
# XDP
# linux-libc-dev must be upgraded to get a bpf.h that matches what we use. the rest match what we do in Vagrant for testing.
RUN apt-get update && apt install -y apt-transport-https curl software-properties-common
RUN apt-get update && apt install -y iproute2 libbpf-dev linux-libc-dev clang-10
RUN apt-get update && apt install -y iproute2 libbpf-dev linux-libc-dev clang-10 clang-tools-10

# Hack because the kernel headers are not installed in the right place (linuxkit vs generic)
RUN ln -s /usr/src/$(ls /usr/src/ | grep generic) /usr/src/linux-headers-$(uname -r)

# Hack for C99 math
RUN sed -i '1s/^/#define __USE_C99_MATH\n/' /usr/src/$(ls /usr/src/ | grep generic)/include/linux/kasan-checks.h
RUN sed -i '2s/^/#include <stdbool.h>\n/' /usr/src/$(ls /usr/src/ | grep generic)/include/linux/kasan-checks.h

# Python test dependencies (scapy/nose etc.) used by the test suites.
RUN apt-get update && apt-get install -y python3 python3-pip python3-dev
COPY requirements.txt /tmp/requirements.txt
RUN pip3 install --no-cache-dir -r /tmp/requirements.txt

# valgrind is required by the glb-director test suite
RUN apt-get update && apt-get install -y valgrind

# netcat and jq are required by the glb-healthcheck test suite
RUN apt-get update && apt-get install -y netcat jq tcpdump
17 changes: 14 additions & 3 deletions script/cibuild-create-packages
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,20 @@ cd "$(dirname "$0")/.."

. script/helpers/folding.sh

DISTRO="$1"
if [ -z "$DISTRO" ]; then
DISTRO="focal"
fi

DOCKERFILE="script/Dockerfile.$DISTRO"
if [ ! -f "$DOCKERFILE" ]; then
echo "Error: unsupported distro '$DISTRO' or missing Dockerfile '$DOCKERFILE'." >&2
exit 1
fi

begin_fold "Preparing Docker build environment"
(
docker build -t glb-director-build-stretch -f script/Dockerfile.stretch script
docker build -t glb-director-build-$DISTRO -f "$DOCKERFILE" "$HOSTPATH"
)
end_fold

Expand All @@ -21,8 +32,8 @@ begin_fold "Building packages"

docker run --rm \
--volume "$HOSTPATH":/glb-director \
"glb-director-build-stretch" \
"glb-director-build-$DISTRO" \
bash -c "cd /glb-director &&
make BUILDDIR=/glb-director/tmp/build clean mkdeb"
)
end_fold
end_fold
28 changes: 0 additions & 28 deletions script/cibuild-create-packages-focal

This file was deleted.

6 changes: 3 additions & 3 deletions script/helpers/folding.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/bash

begin_fold() {
echo "%%%FOLD {$*}%%%"
echo "::group::$*"
}

end_fold() {
echo "%%%END FOLD%%%"
}
echo "::endgroup::"
}
43 changes: 43 additions & 0 deletions script/test-local
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

set -e

DISTRO="${1}"

if [[ -z "$DISTRO" ]]; then
echo "Usage: $0 <distro>"
echo " e.g. $0 focal"
echo " e.g. $0 noble"
exit 1
fi

HOSTPATH=$(cd "$(dirname "$0")/.." && pwd)
IMAGE="glb-director-build-${DISTRO}:latest"
DOCKERFILE="script/Dockerfile.${DISTRO}"

if [[ ! -f "${HOSTPATH}/${DOCKERFILE}" ]]; then
echo "ERROR: Dockerfile not found: ${DOCKERFILE}"
exit 1
fi

cd "$HOSTPATH"

echo "==> Building Docker image for ${DISTRO}..."
docker build --platform linux/amd64 --file "${DOCKERFILE}" --tag "${IMAGE}" .

TEST_SUITES=(director director-xdp healthcheck redirect)

for suite in "${TEST_SUITES[@]}"; do
echo ""
echo "==> Running test suite: glb-${suite} (${DISTRO})"
docker run --rm \
--platform linux/amd64 \
--privileged \
--volume "$(pwd):/workspace" \
--workdir /workspace \
"${IMAGE}" \
bash -c "cd /workspace/src/glb-${suite} && script/test"
done

echo ""
echo "==> All test suites passed for ${DISTRO}."
Loading
Loading