Skip to content

Commit

Permalink
cache log
Browse files Browse the repository at this point in the history
  • Loading branch information
charlielye committed Jan 4, 2025
1 parent ffd818f commit 3837986
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 10 deletions.
6 changes: 2 additions & 4 deletions barretenberg/ts/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ hash=$(cache_content_hash ../cpp/.rebuild_patterns .rebuild_patterns)

function build {
echo_header "bb.js build"
denoise "yarn install"

if ! cache_download bb.js-$hash.tar.gz; then
denoise "yarn install"
find . -exec touch -d "@0" {} + 2>/dev/null || true

denoise "yarn build"
cache_upload bb.js-$hash.tar.gz dest
else
denoise "yarn install"
fi

# We copy snapshot dirs to dest so we can run tests from dest.
Expand Down
6 changes: 3 additions & 3 deletions boxes/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ hash=$(cache_content_hash \

function build {
echo_header "boxes build"
denoise yarn

if ! cache_download boxes-$hash.tar.gz; then
denoise 'yarn && echo "Building... " && yarn build'
denoise 'yarn build'
cache_upload boxes-$hash.tar.gz boxes/*/{artifacts,dist,src/contracts/target}
else
denoise yarn
fi
}

Expand Down
5 changes: 3 additions & 2 deletions ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ function echo_cmd {
function print_usage {
echo "usage: $(basename $0) <cmd>"
echo
echo_cmd "ec2" "Launch an ec2 instance and bootstrap on it. Exactly what Github action does, but doesn't touch GA."
echo_cmd "ec2" "Launch an ec2 instance and bootstrap on it." \
"Exactly what Github Action's does, but doesn't touch GA."
echo_cmd "local" "Clone your last commit into the ci container and bootstrap on local hardware."
echo_cmd "trigger" "Trigger the GA workflow on the PR associated with the current branch." \
"Effectively the same as ec2, only the results will be tracked on your PR."
Expand Down Expand Up @@ -88,7 +89,7 @@ case "$cmd" in
./bootstrap.sh ci
;;
"trigger")
# Trigger workflow and drop through to start logging.
# Trigger workflow.
# We use this label trick because triggering the workflow direct doesn't associate with the PR.
pr_number=$(gh pr list --head "$BRANCH" --json number --jq '.[0].number')
if [ -z "$pr_number" ]; then
Expand Down
5 changes: 5 additions & 0 deletions ci3/bootstrap_ec2
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ if [ -t 0 ]; then
ssh_args="-t"
docker_args+=" -ti"
shell_on_fail="|| exec zsh"
else
cache_log=" | cache_log ${LOG_ID:-}"
fi

# Use ~/.ssh/build_instance_key to ssh into our requested instance.
Expand All @@ -71,10 +73,12 @@ fi
# We provide the host user and group ids to the entrypoint script to ensure alignment.
# We raise the default pid limit to 32k.
ssh ${ssh_args:-} -F $ci3/aws/build_instance_ssh_config ubuntu@$ip "
{
echo "Loading CRS into tmpfs..."
sudo mkdir /mnt/bb-crs
sudo mount -t tmpfs -o size=3G tmpfs /mnt/bb-crs
sudo cp -r \$HOME/.bb-crs/* /mnt/bb-crs
echo "Done in \$SECONDS seconds."
echo "Starting devbox..."
docker run --privileged ${docker_args:-} \
Expand Down Expand Up @@ -104,4 +108,5 @@ ssh ${ssh_args:-} -F $ci3/aws/build_instance_ssh_config ubuntu@$ip "
git checkout FETCH_HEAD
$cmd ${shell_on_fail:-}
'
} 2>&1 ${cache_log:-}
"
24 changes: 24 additions & 0 deletions ci3/cache_log
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
# Runs the given command.
# If a redis cache is available and we're not in a terminal, duplicate output into a cache log.
NO_CD=1 source $(git rev-parse --show-toplevel)/ci3/source

if [ -n "$CI_REDIS" ] && [ ! -t 1 ]; then
key=${LOG_ID:-$(uuid)}
echo -e "Log id: ${yellow}$key${reset}"
tee >(redis-cli -h $CI_REDIS -x SETEX $key 604800 &>/dev/null)
echo -e "Log id: ${yellow}$key${reset}"
else
cat
fi

# NO_CD=1 source $(git rev-parse --show-toplevel)/ci3/source

# if [ -n "$CI_REDIS" ] && [ ! -t 1 ]; then
# key=$(uuid)
# echo -e "Executing: $1 (${yellow}$key${reset})"
# bash -c "$1" | tee >(redis-cli -h $CI_REDIS -x SETEX $key 604800 &>/dev/null)
# echo -e "Complete: $1 (${yellow}$key${reset})"
# else
# exec bash -c "$1"
# fi
3 changes: 2 additions & 1 deletion noir/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ function build_native {
# Builds js packages.
function build_packages {
set -euo pipefail

if cache_download noir-packages-$hash.tar.gz; then
cd noir-repo
yarn
yarn install
return
fi

Expand Down

0 comments on commit 3837986

Please sign in to comment.