Debian Codegraph @

.cargo/vendor/zerocopy/githooks/pre-push

raw
1 #!/usr/bin/env bash
2 #
3 # Copyright 2024 The Fuchsia Authors
4 #
5 # Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
6 # <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
7 # license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
8 # This file may not be copied, modified, or distributed except according to
9 # those terms.
10
11 set -eo pipefail
12 echo "Running pre-push git hook: $0"
13 # Forego redirecting stdout to /dev/null on check_fmt.sh because the output from
14 # `cargo fmt` is useful (and the good stuff is not delivered by stderr).
15 #
16 # Background all jobs and wait for them so they can run in parallel.
17 ./ci/check_fmt.sh & FMT_PID=$!
18 ./ci/check_all_toolchains_tested.sh >/dev/null & TOOLCHAINS_PID=$!
19 ./ci/check_job_dependencies.sh >/dev/null & JOB_DEPS_PID=$!
20 ./ci/check_readme.sh >/dev/null & README_PID=$!
21 ./ci/check_todo.sh >/dev/null & XODO_PID=$!
22 ./ci/check_versions.sh >/dev/null & VERSIONS_PID=$!
23
24 # `wait <pid>` exits with the same status code as the job it's waiting for.
25 # Since we `set -e` above, this will have the effect of causing the entire
26 # script to exit with a non-zero status code if any of these jobs does the same.
27 # Note that, while `wait` (with no PID argument) waits for all backgrounded
28 # jobs, it exits with code 0 even if one of the backgrounded jobs does not, so
29 # we can't use it here.
30 wait $FMT_PID
31 wait $TOOLCHAINS_PID
32 wait $JOB_DEPS_PID
33 wait $README_PID
34 wait $XODO_PID
35 wait $VERSIONS_PID
36
37 # Ensure that this script calls all scripts in `ci/*`. This isn't a foolproof
38 # check since it just checks for the string in this script (e.g., it could be in
39 # a comment, which would trigger a false positive), but it should catch obvious
40 # errors. Also note that this entire hook is a nice-to-have - failures that
41 # aren't caught here will still be caught in CI.
42 #
43 # This was added because, in #728, we added `ci/check_all_toolchains_tested.sh`
44 # without calling it from this script.
45 GLOBIGNORE="./*/release_crate_version.sh" # We don't want to run this one
46 for f in ./ci/*; do
47 grep "$f" githooks/pre-push >/dev/null || { echo "$f not called from githooks/pre-push" >&2 ; exit 1; }
48 done
49 unset GLOBIGNORE