Collect timing metrics for CI jobs
This commit is contained in:
parent
4b07772e22
commit
72ab83cd45
|
@ -0,0 +1,2 @@
|
|||
CI_BUILD_START=$(date +%s)
|
||||
export CI_BUILD_START
|
|
@ -0,0 +1 @@
|
|||
post-checkout
|
|
@ -1,14 +1,50 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
[[ -n "$CARGO_TARGET_CACHE_NAME" ]] || exit 0
|
||||
|
||||
#
|
||||
# Save target/ for the next CI build on this machine
|
||||
#
|
||||
if [[ -n $CARGO_TARGET_CACHE_NAME ]]; then
|
||||
(
|
||||
d=$HOME/cargo-target-cache/"$CARGO_TARGET_CACHE_NAME"
|
||||
mkdir -p $d
|
||||
mkdir -p "$d"
|
||||
set -x
|
||||
rsync -a --delete --link-dest=$PWD target $d
|
||||
du -hs $d
|
||||
rsync -a --delete --link-dest="$PWD" target "$d"
|
||||
du -hs "$d"
|
||||
)
|
||||
fi
|
||||
|
||||
#
|
||||
# Add job_stats data point
|
||||
#
|
||||
if [[ -z $CI_BUILD_START ]]; then
|
||||
echo Error: CI_BUILD_START empty
|
||||
else
|
||||
CI_BUILD_DURATION=$(( $(date +%s) - CI_BUILD_START + 1 ))
|
||||
|
||||
CI_LABEL=${BUILDKITE_LABEL:-build label missing}
|
||||
|
||||
PR=false
|
||||
if [[ $BUILDKITE_BRANCH =~ pull/* ]]; then
|
||||
PR=true
|
||||
fi
|
||||
|
||||
SUCCESS=true
|
||||
if [[ $BUILDKITE_COMMAND_EXIT_STATUS != 0 ]]; then
|
||||
SUCCESS=false
|
||||
fi
|
||||
|
||||
point_tags="pipeline=$BUILDKITE_PIPELINE_SLUG,job=$CI_LABEL,pr=$PR,success=$SUCCESS"
|
||||
point_tags="${point_tags// /\\ }" # Escape spaces
|
||||
|
||||
point_fields="duration=$CI_BUILD_DURATION"
|
||||
point_fields="${point_fields// /\\ }" # Escape spaces
|
||||
|
||||
point="job_stats,$point_tags $point_fields"
|
||||
echo "Influx data point: $point"
|
||||
if [[ -n $INFLUX_USERNAME && -n $INFLUX_PASSWORD ]]; then
|
||||
echo "https://metrics.solana.com:8086/write?db=ci&u=${INFLUX_USERNAME}&p=${INFLUX_PASSWORD}" \
|
||||
| xargs curl -XPOST --data-binary "$point"
|
||||
else
|
||||
echo Influx user credentials not found
|
||||
fi
|
||||
fi
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
post-command
|
|
@ -7,7 +7,7 @@
|
|||
#
|
||||
(
|
||||
d=$HOME/cargo-target-cache/"$CARGO_TARGET_CACHE_NAME"
|
||||
mkdir -p $d/target
|
||||
mkdir -p "$d"/target
|
||||
set -x
|
||||
rsync -a --delete --link-dest=$d $d/target .
|
||||
rsync -a --delete --link-dest="$d" "$d"/target .
|
||||
)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
pre-command
|
Loading…
Reference in New Issue