File: pre-push

package info (click to toggle)
rust-zerocopy 0.8.26-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,748 kB
  • sloc: sh: 116; makefile: 2
file content (49 lines) | stat: -rwxr-xr-x 2,278 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env bash
#
# Copyright 2024 The Fuchsia Authors
#
# Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
# <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
# license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
# This file may not be copied, modified, or distributed except according to
# those terms.

set -eo pipefail
echo "Running pre-push git hook: $0"
# Forego redirecting stdout to /dev/null on check_fmt.sh because the output from
# `cargo fmt` is useful (and the good stuff is not delivered by stderr).
#
# Background all jobs and wait for them so they can run in parallel.
./ci/check_fmt.sh                              & FMT_PID=$!
./ci/check_all_toolchains_tested.sh >/dev/null & TOOLCHAINS_PID=$!
./ci/check_job_dependencies.sh      >/dev/null & JOB_DEPS_PID=$!
./ci/check_readme.sh                >/dev/null & README_PID=$!
./ci/check_todo.sh                  >/dev/null & XODO_PID=$!
./ci/check_versions.sh              >/dev/null & VERSIONS_PID=$!

# `wait <pid>` exits with the same status code as the job it's waiting for.
# Since we `set -e` above, this will have the effect of causing the entire
# script to exit with a non-zero status code if any of these jobs does the same.
# Note that, while `wait` (with no PID argument) waits for all backgrounded
# jobs, it exits with code 0 even if one of the backgrounded jobs does not, so
# we can't use it here.
wait $FMT_PID
wait $TOOLCHAINS_PID
wait $JOB_DEPS_PID
wait $README_PID
wait $XODO_PID
wait $VERSIONS_PID

# Ensure that this script calls all scripts in `ci/*`. This isn't a foolproof
# check since it just checks for the string in this script (e.g., it could be in
# a comment, which would trigger a false positive), but it should catch obvious
# errors. Also note that this entire hook is a nice-to-have - failures that
# aren't caught here will still be caught in CI.
#
# This was added because, in #728, we added `ci/check_all_toolchains_tested.sh`
# without calling it from this script.
GLOBIGNORE="./*/release_crate_version.sh" # We don't want to run this one
for f in ./ci/*; do
    grep "$f" githooks/pre-push >/dev/null || { echo "$f not called from githooks/pre-push" >&2 ; exit 1; }
done
unset GLOBIGNORE