Skip to content

Commit 32a5153

Browse files
Manoramsharmayurishkuro
authored andcommitted
Skip building HotROD for all platforms for pull requests (jaegertracing#5765)
## Which problem is this PR solving? - Resolves jaegertracing#5743 ## Description of the changes - Similar to the functionality we have for all-in-one image I tried to achieve same build configuration supported by corresponding script file. ## Checklist - [x] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [x] I have signed all commits - [ ] I have added unit tests for the new functionality - [x] I have run lint and test steps successfully - for `jaeger`: `make lint test` - for `jaeger-ui`: `yarn lint` and `yarn test` --------- Signed-off-by: Manoramsharma <[email protected]> Signed-off-by: Yuri Shkuro <[email protected]> Co-authored-by: Yuri Shkuro <[email protected]>
1 parent 150fb12 commit 32a5153

File tree

2 files changed

+54
-19
lines changed

2 files changed

+54
-19
lines changed

.github/workflows/ci-docker-hotrod.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,21 @@ jobs:
3939
- name: Export BRANCH variable
4040
uses: ./.github/actions/setup-branch
4141

42-
- name: Install tools
43-
run: make install-ci
44-
4542
- uses: docker/setup-qemu-action@5927c834f5b4fdf503fca6f4c7eccda82949e1ee # v3.1.0
4643

44+
- name: Define BUILD_FLAGS var if running on a Pull Request
45+
run: |
46+
case ${GITHUB_EVENT_NAME} in
47+
pull_request)
48+
echo "BUILD_FLAGS=-l -p linux/amd64" >> ${GITHUB_ENV}
49+
;;
50+
*)
51+
echo "BUILD_FLAGS=" >> ${GITHUB_ENV}
52+
;;
53+
esac
54+
4755
- name: Build, test, and publish hotrod image
48-
run: bash scripts/hotrod-integration-test.sh
56+
run: bash scripts/hotrod-integration-test.sh ${{ env.BUILD_FLAGS }}
4957
env:
5058
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
5159
QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }}

scripts/hotrod-integration-test.sh

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,60 @@
22

33
set -euxf -o pipefail
44

5+
print_help() {
6+
echo "Usage: $0 [-l] [-D] [-p platforms] [-h]"
7+
echo "-h: Print help"
8+
echo "-l: Enable local-only mode that only pushes images to local registry"
9+
echo "-p: Comma-separated list of platforms to build for (default: all supported)"
10+
exit 1
11+
}
12+
513
docker_compose_file="./examples/hotrod/docker-compose.yml"
614
platforms="linux/amd64,linux/s390x,linux/ppc64le,linux/arm64"
15+
current_platform="$(go env GOOS)/$(go env GOARCH)"
16+
LOCAL_FLAG=''
17+
18+
while getopts "lp:h" opt; do
19+
case "${opt}" in
20+
l)
21+
# in the local-only mode the images will only be pushed to local registry
22+
LOCAL_FLAG='-l'
23+
;;
24+
p)
25+
platforms=${OPTARG}
26+
;;
27+
*)
28+
print_help
29+
;;
30+
esac
31+
done
732

833
teardown() {
934
echo "Tearing down..."
1035
docker compose -f "$docker_compose_file" down
1136
}
1237
trap teardown EXIT
1338

14-
make build-examples GOOS=linux GOARCH=amd64
15-
make build-examples GOOS=linux GOARCH=s390x
16-
make build-examples GOOS=linux GOARCH=ppc64le
17-
make build-examples GOOS=linux GOARCH=arm64
18-
1939
make prepare-docker-buildx
2040
make create-baseimg
2141

22-
# Loop through each platform (separated by commas)
42+
# Build hotrod binary for each target platform (separated by commas)
2343
for platform in $(echo "$platforms" | tr ',' ' '); do
44+
# Extract the operating system from the platform string
45+
os=${platform%%/*} #remove everything after the last slash
2446
# Extract the architecture from the platform string
2547
arch=${platform##*/} # Remove everything before the last slash
26-
make "build-all-in-one" GOOS=linux GOARCH="${arch}"
48+
make build-examples GOOS="${os}" GOARCH="${arch}"
2749
done
2850

29-
# Build image locally (-l) for integration test
30-
bash scripts/build-upload-a-docker-image.sh -l -c example-hotrod -d examples/hotrod -p "${platforms}"
31-
bash scripts/build-upload-a-docker-image.sh -l -b -c all-in-one -d cmd/all-in-one -p "${platforms}" -t release
51+
# Build hotrod image locally (-l) for integration test.
52+
# Note: hotrod's Dockerfile is different from main binaries,
53+
# so we do not pass flags like -b and -t.
54+
bash scripts/build-upload-a-docker-image.sh -l -c example-hotrod -d examples/hotrod -p "${current_platform}"
55+
56+
# Build all-in-one image locally (-l) for integration test
57+
make build-all-in-one
58+
bash scripts/build-upload-a-docker-image.sh -l -b -c all-in-one -d cmd/all-in-one -p "${current_platform}" -t release
3259

3360
JAEGER_VERSION=$GITHUB_SHA REGISTRY="localhost:5000/" docker compose -f "$docker_compose_file" up -d
3461

@@ -57,17 +84,16 @@ fi
5784
JAEGER_QUERY_URL="http://localhost:16686"
5885
EXPECTED_SPANS=35
5986
MAX_RETRIES=30
60-
SLEEP_INTERVAL=10
87+
SLEEP_INTERVAL=3
6188

62-
# Function to poll Jaeger for the trace
6389
poll_jaeger() {
6490
local trace_id=$1
6591
local url="${JAEGER_QUERY_URL}/api/traces/${trace_id}"
6692

6793
curl -s "${url}" | jq '.data[0].spans | length' || echo "0"
6894
}
6995

70-
# Polling loop
96+
# Poll Jaeger until trace with desired number of spans is loaded or we timeout.
7197
span_count=0
7298
for ((i=1; i<=MAX_RETRIES; i++)); do
7399
span_count=$(poll_jaeger "${TRACE_ID}")
@@ -86,5 +112,6 @@ if [[ "$span_count" -lt "$EXPECTED_SPANS" ]]; then
86112
exit 1
87113
fi
88114

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

0 commit comments

Comments
 (0)