Add temporary presubmit script for CI
This adds a script which ensures that the project compiles, and runs
lints and code formatting.
Change-Id: I9b02d5f461d4cefba38052836812e1fa16ab82ed
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/qg/+/119750
Commit-Queue: Alexei Frolov <frolv@google.com>
Reviewed-by: Erik Gilling <konkers@google.com>
diff --git a/qg/src/lib.rs b/qg/src/lib.rs
index 0d10554..d9797db 100644
--- a/qg/src/lib.rs
+++ b/qg/src/lib.rs
@@ -12,6 +12,7 @@
// License for the specific language governing permissions and limitations under
// the License.
+#[must_use]
pub fn name() -> &'static str {
"qg"
}
diff --git a/rustfmt.toml b/rustfmt.toml
index 389a648..c98f3bf 100644
--- a/rustfmt.toml
+++ b/rustfmt.toml
@@ -1,3 +1,5 @@
edition = "2021"
-normalize_comments = true
use_field_init_shorthand = true
+
+# TODO(frolv): This is still unstable, but should be enabled when ready.
+# normalize_comments = true
diff --git a/tools/presubmit.sh b/tools/presubmit.sh
new file mode 100755
index 0000000..810e256
--- /dev/null
+++ b/tools/presubmit.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+set -e
+
+check() {
+ echo "==> Running $@"
+ "$@"
+ echo "==="
+}
+
+check cargo build
+check cargo test
+check cargo fmt --check
+check cargo clippy -- -D clippy::pedantic
+
+echo
+echo "All presubmit steps passed!"
\ No newline at end of file