Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[githooks][pre-push] Run steps in parallel #942

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ci/check_all_toolchains_tested.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ set -eo pipefail
diff \
<(cat .github/workflows/ci.yml | yq '.jobs.build_test.strategy.matrix.toolchain | .[]' | \
sort -u | grep -v '^\(msrv\|stable\|nightly\)$') \
<(cargo metadata --format-version 1 | \
<(cargo metadata -q --format-version 1 | \
jq -r ".packages[] | select(.name == \"zerocopy\").metadata.\"build-rs\" | keys | .[]" | \
sort -u)
2 changes: 1 addition & 1 deletion ci/check_msrv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -eo pipefail

# Usage: msrv <crate-name>
function msrv {
cargo metadata --format-version 1 | jq -r ".packages[] | select(.name == \"$1\").rust_version"
cargo metadata -q --format-version 1 | jq -r ".packages[] | select(.name == \"$1\").rust_version"
}

ver_zerocopy=$(msrv zerocopy)
Expand Down
2 changes: 1 addition & 1 deletion ci/check_readme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -eo pipefail
# Install again in case the installation failed during the
# `generate_cache` step. We treat that step as best-effort and
# suppress all errors from it.
cargo install cargo-readme --version 3.2.0 -q
cargo install -q cargo-readme --version 3.2.0

diff <(cargo -q run --manifest-path tools/Cargo.toml -p generate-readme) README.md
exit $?
4 changes: 2 additions & 2 deletions ci/check_versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -eo pipefail

# Usage: version <crate-name>
function version {
cargo metadata --format-version 1 | jq -r ".packages[] | select(.name == \"$1\").version"
cargo metadata -q --format-version 1 | jq -r ".packages[] | select(.name == \"$1\").version"
}

ver_zerocopy=$(version zerocopy)
Expand All @@ -13,7 +13,7 @@ ver_zerocopy_derive=$(version zerocopy-derive)
function dependency-version {
KIND="$1"
TARGET="$2"
cargo metadata --format-version 1 \
cargo metadata -q --format-version 1 \
| jq -r ".packages[] | select(.name == \"zerocopy\").dependencies[] | select((.name == \"zerocopy-derive\") and .kind == $KIND and .target == $TARGET).req"
}

Expand Down
18 changes: 11 additions & 7 deletions githooks/pre-push
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#!/usr/bin/env bash
set -eo pipefail
echo "Running pre-push git hook: $0"
# forego redirecting stdout to /dev/null on check_fmt.sh because the output
# from cargofmt is useful (and the good stuff is not delivered by stderr)
./ci/check_fmt.sh
./ci/check_job_dependencies.sh > /dev/null
./ci/check_msrv.sh > /dev/null
./ci/check_readme.sh > /dev/null
./ci/check_versions.sh > /dev/null
# 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 &
./ci/check_job_dependencies.sh >/dev/null &
./ci/check_msrv.sh >/dev/null &
./ci/check_readme.sh >/dev/null &
./ci/check_versions.sh >/dev/null &

wait
Loading