Skip to content

Commit

Permalink
Release v2 cleanup 3 (#5984)
Browse files Browse the repository at this point in the history
## Which problem is this PR solving?
- Part of #5889

## Description of the changes
- simplify all-in-one publishing by minimizing number of parameters
passed from workflow (v1/v2 only instead of binary name and healthcheck
flag - those are now set inside the script)
- implement overwrite `-o` flag in docker scripts to avoid accidental
overriding of numbered releases
- simplify flags management in docker scripts via FLAGS array instead of
individual variables
- fix base image building to respect selected platforms (by default it
was building all)
- allow `scripts/compute-version.sh` to accept semver with `-rcN` suffix

## How was this change tested?
- CI
- ran publish-release workflow manually
https://github.com/jaegertracing/jaeger/actions/runs/10865002272/job/30150937690

---------

Signed-off-by: Yuri Shkuro <github@ysh.us>
  • Loading branch information
yurishkuro authored Sep 14, 2024
1 parent 7d6ebaa commit 4640518
Show file tree
Hide file tree
Showing 9 changed files with 175 additions and 102 deletions.
18 changes: 2 additions & 16 deletions .github/workflows/ci-docker-all-in-one.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
mode:
- name: v1
binary: all-in-one
- name: v2
binary: jaeger
jaeger_version: [v1, v2]

steps:
- uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0
Expand Down Expand Up @@ -61,21 +57,11 @@ jobs:
;;
esac
- name: Determine healthcheck setting
id: healthcheck
run: |
if [[ "${{ matrix.mode.name }}" == "v1" ]]; then
echo "HEALTHCHECK_V2=false" >> $GITHUB_ENV
elif [[ "${{ matrix.mode.name }}" == "v2" ]]; then
echo "HEALTHCHECK_V2=true" >> $GITHUB_ENV
fi
- name: Build, test, and publish all-in-one image
run: |
bash scripts/build-all-in-one-image.sh \
${{ env.BUILD_FLAGS }} \
-b ${{ matrix.mode.binary }}
"${{ matrix.jaeger_version }}"
env:
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }}
HEALTHCHECK_V2: ${{ env.HEALTHCHECK_V2 }}
82 changes: 47 additions & 35 deletions .github/workflows/ci-release.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
name: Publish release

on:
release:
types:
- published
# allow running release workflow manually
# Disable auto-run, once we sunset 1.x components we might go back to auto-release.
#
# release:
# types:
# - published

workflow_dispatch:
# Determine the version numbers that will be assigned to the release.
inputs:
version_v1:
required: true
type: string
description: Version number for 1.x components. Don't include a leading `v`.
# Disable version inputs for now, the build always uses the latest tags.
#
# version_v1:
# required: true
# type: string
# description: Version number for 1.x components. Don't include a leading `v`.

version_v2:
required: true
type: string
description: Version number for 2.x components. Don't include a leading `v`.
# version_v2:
# required: true
# type: string
# description: Version number for 2.x components. Don't include a leading `v`.

dry_run:
required: true
Expand All @@ -28,10 +31,6 @@ on:
type: boolean
description: Allow overwriting artifacts.

# See https://github.com/jaegertracing/jaeger/issues/4017
permissions:
contents: read

jobs:
publish-release:
permissions:
Expand Down Expand Up @@ -71,30 +70,32 @@ jobs:
- name: Determine parameters
id: params
run: |
docker_flags=()
if [[ "${{ inputs.dry_run }}" == "true" ]]; then
echo "local_build=-l" >> $GITHUB_OUTPUT
docker_flags=("${docker_flags[@]}" -l -p linux/amd64)
echo "platforms=linux/amd64" >> $GITHUB_OUTPUT
echo "linux_platforms=linux/amd64" >> $GITHUB_OUTPUT
echo "gpg_key_override=-k skip" >> $GITHUB_OUTPUT
else
echo "local_build=" >> $GITHUB_OUTPUT
echo "platforms=$(make echo-platforms)" >> $GITHUB_OUTPUT
echo "linux_platforms=$(make echo-linux-platforms)" >> $GITHUB_OUTPUT
fi
if [[ "${{ inputs.overwrite }}" == "true" ]]; then
docker_flags=("${docker_flags[@]}" -o)
fi
echo "docker_flags=${docker_flags[@]}" >> $GITHUB_OUTPUT
cat $GITHUB_OUTPUT
- name: Export BRANCH variable and validate it is a semver
# Many scripts depend on BRANCH variable. We do not want to
# use ./.github/actions/setup-branch here because it may set
# BRANCH=main when the workflow is triggered manually.
#
# TODO this currently utilizes 1.x version tag
# TODO this currently utilizes 1.x version tag, which is ok for v1
# binaries, but for tools/utils we may need to change in the future.
run: |
BRANCH=$(make echo-v1)
echo "BRANCH=${BRANCH}" >> ${GITHUB_ENV}
echo Validate that the latest tag ${BRANCH} is in semver format
echo ${BRANCH} | grep -E '^v[0-9]+.[0-9]+.[0-9]+$'
- run: make install-ci
echo "BRANCH=${BRANCH}" >> ${GITHUB_ENV}
- name: Configure GPG Key
if: ${{ inputs.dry_run != true }}
Expand All @@ -107,8 +108,10 @@ jobs:
run: make build-all-platforms PLATFORMS=${{ steps.params.outputs.platforms }}

- name: Package binaries
id: package-binaries
run: bash scripts/package-deploy.sh -p ${{ steps.params.outputs.platforms }} ${{ steps.params.outputs.gpg_key_override }}
run: |
bash scripts/package-deploy.sh \
-p ${{ steps.params.outputs.platforms }} \
${{ steps.params.outputs.gpg_key_override }}
- name: Upload binaries
if: ${{ inputs.dry_run != true }}
Expand All @@ -131,26 +134,35 @@ jobs:
# -B skips building the binaries since we already did that above
run: |
bash scripts/build-upload-docker-images.sh -B \
-p ${{ steps.params.outputs.linux_platforms }} \
${{ steps.params.outputs.local_build }}
${{ steps.params.outputs.docker_flags }}
env:
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }}

- name: Build, test, and publish all-in-one v1 image
run: |
BRANCH=$(make echo-v1) \
bash scripts/build-all-in-one-image.sh \
${{ steps.params.outputs.docker_flags }} \
v1
env:
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }}

- name: Build, test, and publish all-in-one image
- name: Build, test, and publish v2 image
run: |
BRANCH=$(make echo-v2) \
bash scripts/build-all-in-one-image.sh \
-p ${{ steps.params.outputs.linux_platforms }} \
${{ steps.params.outputs.local_build }}
${{ steps.params.outputs.docker_flags }} \
v2
env:
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }}

- name: Build, test, and publish hotrod image
run: |
bash scripts/build-hotrod-image.sh \
-p ${{ steps.params.outputs.linux_platforms }} \
${{ steps.params.outputs.local_build }}
${{ steps.params.outputs.docker_flags }}
env:
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }}
Expand All @@ -165,11 +177,11 @@ jobs:
- name: Upload SBOM
# Upload SBOM manually, because anchore/sbom-action does not do that
# when the workflow is triggered manually, only from a release.
# See https://github.com/jaegertracing/jaeger/issues/4817
uses: svenstaro/upload-release-action@04733e069f2d7f7f0b4aebc4fbdbce8613b03ccd # 2.9.0
if: ${{ inputs.dry_run != true }}
with:
file: jaeger-SBOM.spdx.json
overwrite: ${{ inputs.overwrite }}
# TODO this will only work for 1.x artifacts
tag: ${{ env.BRANCH }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
60 changes: 41 additions & 19 deletions scripts/build-all-in-one-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,31 @@
set -euf -o pipefail

print_help() {
echo "Usage: $0 [-b binary] [-D] [-h] [-l] [-p platforms]"
echo "-b: Which binary to build: 'all-in-one' (default) or 'jaeger' (v2)"
echo "-D: Disable building of images with debugger"
echo "-h: Print help"
echo "-l: Enable local-only mode that only pushes images to local registry"
echo "-p: Comma-separated list of platforms to build for (default: all supported)"
echo "Usage: $0 [-b binary] [-D] [-h] [-l] [-o] [-p platforms] <jaeger_version>"
echo " -D: Disable building of images with debugger"
echo " -h: Print help"
echo " -l: Enable local-only mode that only pushes images to local registry"
echo " -o: overwrite image in the target remote repository even if the semver tag already exists"
echo " -p: Comma-separated list of platforms to build for (default: all supported)"
echo " jaeger_version: major version, v1 | v2"
exit 1
}

add_debugger='Y'
platforms="$(make echo-linux-platforms)"
LOCAL_FLAG=''
BINARY='all-in-one'
FLAGS=()

while getopts "b:Dhlp:" opt; do
while getopts "Dhlop:" opt; do
case "${opt}" in
b)
BINARY=${OPTARG}
;;
D)
add_debugger='N'
;;
l)
# in the local-only mode the images will only be pushed to local registry
LOCAL_FLAG='-l'
FLAGS=("${FLAGS[@]}" -l)
;;
o)
FLAGS=("${FLAGS[@]}" -o)
;;
p)
platforms=${OPTARG}
Expand All @@ -41,6 +41,28 @@ while getopts "b:Dhlp:" opt; do
esac
done

# remove flags, leave only positional args
shift $((OPTIND - 1))

if [[ $# -eq 0 ]]; then
echo "Jaeger major version is required as argument"
print_help
fi

case $1 in
v1)
BINARY='all-in-one'
export HEALTHCHECK_V2=false
;;
v2)
BINARY='jaeger'
export HEALTHCHECK_V2=true
;;
*)
echo "Jaeger major version is required as argument"
print_help
esac

set -x

# Set default GOARCH variable to the host GOARCH, the target architecture can
Expand Down Expand Up @@ -85,19 +107,19 @@ for platform in $(echo "$platforms" | tr ',' ' '); do
make "build-${BINARY}" GOOS=linux GOARCH="${arch}"
done

baseimg_target='create-baseimg-debugimg'
if [[ "${add_debugger}" == "N" ]]; then
make create-baseimg
else
make create-baseimg-debugimg
baseimg_target='create-baseimg'
fi
make "$baseimg_target" LINUX_PLATFORMS="$platforms"

# build all-in-one image locally for integration test (the -l switch)
# build all-in-one image locally for integration test (the explicit -l switch)
bash scripts/build-upload-a-docker-image.sh -l -b -c "${BINARY}" -d "cmd/${BINARY}" -p "${platforms}" -t release

run_integration_test "localhost:5000/$repo"

# build all-in-one image and upload to dockerhub/quay.io
bash scripts/build-upload-a-docker-image.sh ${LOCAL_FLAG} -b -c "${BINARY}" -d "cmd/${BINARY}" -p "${platforms}" -t release
bash scripts/build-upload-a-docker-image.sh "${FLAGS[@]}" -b -c "${BINARY}" -d "cmd/${BINARY}" -p "${platforms}" -t release

# build debug image if requested
if [[ "${add_debugger}" == "Y" ]]; then
Expand All @@ -109,5 +131,5 @@ if [[ "${add_debugger}" == "Y" ]]; then
run_integration_test "localhost:5000/$repo"

# build & upload official image
bash scripts/build-upload-a-docker-image.sh ${LOCAL_FLAG} -b -c "${BINARY}-debug" -d "cmd/${BINARY}" -t debug
bash scripts/build-upload-a-docker-image.sh "${FLAGS[@]}" -b -c "${BINARY}-debug" -d "cmd/${BINARY}" -t debug
fi
25 changes: 18 additions & 7 deletions scripts/build-hotrod-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,31 @@
# Copyright (c) 2024 The Jaeger Authors.
# SPDX-License-Identifier: Apache-2.0

set -euxf -o pipefail
set -euf -o pipefail

print_help() {
echo "Usage: $0 [-h] [-l] [-p platforms]"
echo "Usage: $0 [-h] [-l] [-o] [-p platforms]"
echo "-h: Print help"
echo "-l: Enable local-only mode that only pushes images to local registry"
echo "-o: overwrite image in the target remote repository even if the semver tag already exists"
echo "-p: Comma-separated list of platforms to build for (default: all supported)"
exit 1
}

docker_compose_file="./examples/hotrod/docker-compose.yml"
platforms="$(make echo-linux-platforms)"
current_platform="$(go env GOOS)/$(go env GOARCH)"
LOCAL_FLAG=''
FLAGS=()
success="false"

while getopts "hlp:" opt; do
while getopts "hlop:" opt; do
case "${opt}" in
l)
# in the local-only mode the images will only be pushed to local registry
LOCAL_FLAG='-l'
FLAGS=("${FLAGS[@]}" -l)
;;
o)
FLAGS=("${FLAGS[@]}" -o)
;;
p)
platforms=${OPTARG}
Expand All @@ -34,6 +38,8 @@ while getopts "hlp:" opt; do
esac
done

set -x

dump_logs() {
local compose_file=$1
echo "::group:: Hotrod logs"
Expand All @@ -51,7 +57,7 @@ teardown() {
trap teardown EXIT

make prepare-docker-buildx
make create-baseimg
make create-baseimg LINUX_PLATFORMS="$platforms"

# Build hotrod binary for each target platform (separated by commas)
for platform in $(echo "$platforms" | tr ',' ' '); do
Expand All @@ -71,19 +77,24 @@ bash scripts/build-upload-a-docker-image.sh -l -c example-hotrod -d examples/hot
make build-all-in-one
bash scripts/build-upload-a-docker-image.sh -l -b -c all-in-one -d cmd/all-in-one -p "${current_platform}" -t release

echo '::group:: docker compose'
JAEGER_VERSION=$GITHUB_SHA REGISTRY="localhost:5000/" docker compose -f "$docker_compose_file" up -d
echo '::endgroup::'

i=0
while [[ "$(curl -s -o /dev/null -w '%{http_code}' localhost:8080)" != "200" && $i -lt 30 ]]; do
sleep 1
i=$((i+1))
done

echo '::group:: check HTML'
echo 'Check that home page contains text Rides On Demand'
body=$(curl localhost:8080)
if [[ $body != *"Rides On Demand"* ]]; then
echo "String \"Rides On Demand\" is not present on the index page"
exit 1
fi
echo '::endgroup::'

response=$(curl -i -X POST "http://localhost:8080/dispatch?customer=123")
TRACE_ID=$(echo "$response" | grep -Fi "Traceresponse:" | awk '{print $2}' | cut -d '-' -f 2)
Expand Down Expand Up @@ -130,4 +141,4 @@ success="true"

# Ensure the image is published after successful test (maybe with -l flag if on a pull request).
# This is where all those multi-platform binaries we built earlier are utilized.
bash scripts/build-upload-a-docker-image.sh ${LOCAL_FLAG} -c example-hotrod -d examples/hotrod -p "${platforms}"
bash scripts/build-upload-a-docker-image.sh "${FLAGS[@]}" -c example-hotrod -d examples/hotrod -p "${platforms}"
Loading

0 comments on commit 4640518

Please sign in to comment.