*: Add presubmit script Adds a `presubmit.sh` script to the repository root to automate CI/CD checks. The script ensures code quality by running a series of checks in the `rust/` directory. Using `set -eux`, the script is configured to exit immediately if any of the following steps fail: - Build the project with `cargo build` - Check code formatting with `cargo fmt -- --check` - Run the test suite with `cargo test` Bug: b/439013538 Test: Ran the script locally Change-Id: I0344c0e494bda49e0b09778f5cfdd0d3e4c01f26 Reviewed-on: https://bluetooth-review.googlesource.com/c/bluetooth/+/2700 Reviewed-by: Rob Mohr <mohrr@google.com> Reviewed-by: Marie Janssen <jamuraa@google.com>
diff --git a/presubmit.sh b/presubmit.sh new file mode 100755 index 0000000..3da037b --- /dev/null +++ b/presubmit.sh
@@ -0,0 +1,24 @@ +#!/bin/bash +# Presubmit script for CI/CD + +# Exit on error, print commands, and exit on unset variables. +set -eux + +# Change to the rust directory to run cargo commands. +cd "$(dirname "$0")/rust" + +# 1. Build the code. +# `set -e` will cause the script to exit if this fails. +cargo build + +# 2. Check formatting. +# `cargo fmt -- --check` will exit with a non-zero status code if any +# files are not formatted correctly. +cargo fmt -- --check + +# 3. Run tests. +# `set -e` will cause the script to exit if any tests fail. +cargo test + +{ set +x; } 2>/dev/null +echo "Presubmit checks passed!";