Skip to content

Commit

Permalink
add script for nightly runner
Browse files Browse the repository at this point in the history
  • Loading branch information
kbhargava-jump committed May 3, 2024
1 parent f896c94 commit be6f39e
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/flamenco/runtime/tests/Local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@ run-runtime-test-3: $(OBJDIR)/bin/fd_ledger
OBJDIR=$(OBJDIR) src/flamenco/runtime/tests/run_ledger_tests.sh -l mainnet-257059815 -s snapshot-257059815-AmWkVebTmg6ih2VTEjMmU9WtXhT3RygEoSJBHfDpyAG3.tar.zst -p 32 -m 5000000 -e 257059818 --zst
OBJDIR=$(OBJDIR) src/flamenco/runtime/tests/run_ledger_tests.sh -l mainnet-257061172 -s snapshot-257061172-8e6cUSMUx2VZZBDzwXjEY6bGkzPgnUmqrDyr4uErG8BF.tar.zst -p 32 -m 5000000 -e 257061175 --zst
# OBJDIR=$(OBJDIR) src/flamenco/runtime/tests/run_ledger_tests.sh -l v20-ledger

run-runtime-test-nightly: $(OBJDIR)/unit-test/test_runtime $(OBJDIR)/bin/fd_ledger
OBJDIR=$(OBJDIR) src/flamenco/runtime/tests/run_ledger_tests.sh -l mainnet-257033306 -s snapshot-257033306-EE3WdRoE4J1LTjegJMK3ZzxKZbSMQhLMaTM5Jp4SygMU.tar.zst -p 400 -m 500000000 -e 257163306 --zst
83 changes: 83 additions & 0 deletions src/flamenco/runtime/tests/run_nightly_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/bin/bash -f

# Defaults
BRANCH="main"

# Read command-line args
while [[ $# -gt 0 ]]; do
case $1 in
-r|--repo-dir)
REPO_DIR="$2"
shift 2
;;
-b|--branch)
BRANCH="$2"
shift 2
;;
-s|--slack-webhook-url)
SLACK_WEBHOOK_URL="$2"
shift 2
;;
*)
echo "Unknown flag"
exit 1
;;
esac
done

# Error if required args are not provided
if [ -z "${REPO_DIR}" ]; then
echo "Error: Repository directory not specified"
exit 1
fi

if [ -z "${SLACK_WEBHOOK_URL}" ]; then
echo "Error: Slack webhook URL not specified"
exit 1
fi

# Pull the latest code
cd $REPO_DIR
git checkout $BRANCH
git pull origin $BRANCH
COMMIT=$(git rev-parse HEAD)

# Notify start of the test
start_message="Alert: Starting Nightly Ledger Test using Commit \`$COMMIT\` on Branch \`$BRANCH\`"
start_json_payload=$(cat <<EOF
{
"text": "$start_message"
}
EOF
)
curl -X POST -H 'Content-type: application/json' --data "$start_json_payload" $SLACK_WEBHOOK_URL

# Set up environment
PATH=/opt/rh/gcc-toolset-12/root/usr/bin:$PATH
export PATH
PKG_CONFIG_PATH=/usr/lib64/pkgconfig:$PKG_CONFIG_PATH

make distclean && make clean
./deps.sh nuke
echo "y" | ./deps.sh +dev
make -j

# Run the test
make run-runtime-test-nightly
status=$?

# Notify the test status
if [ $status -eq 0 ]; then
end_message="Alert: Nightly Ledger Test Passed using Commit \`$COMMIT\` on Branch \`$BRANCH\`"
else
end_message="@here Alert: Nightly Ledger Test Failed using Commit \`$COMMIT\` on Branch \`$BRANCH\`"
fi

json_payload=$(cat <<EOF
{
"text": "$end_message",
"link_names": 1
}
EOF
)
curl -X POST -H 'Content-type: application/json' --data "$json_payload" $SLACK_WEBHOOK_URL

0 comments on commit be6f39e

Please sign in to comment.