From 7b600344251e79b1554b78ed8a972cac2aea4f3f Mon Sep 17 00:00:00 2001 From: John Turner Date: Fri, 28 Nov 2025 17:16:33 +0000 Subject: [PATCH] use gnu parallel to run pre-commit hook check commands in parallel --- check.sh | 24 ++++++++---------------- check_commands.txt | 4 ++++ 2 files changed, 12 insertions(+), 16 deletions(-) create mode 100644 check_commands.txt diff --git a/check.sh b/check.sh index 3f707f2..1d5bb19 100755 --- a/check.sh +++ b/check.sh @@ -1,28 +1,20 @@ #!/bin/bash source /etc/profile +source /lib/gentoo/functions.sh export PATH="${HOME}/.local/bin:${PATH}" CC=clang CXX=clang++ -if command -v ldd; then - export LDFLAGS=-fuse-ld=lld -fi +ldd=$(command -v ldd) -for file in $(find src -type f -name '*.rs'); do - rustfmt --edition 2024 --check ${file} || exit $? -done +if [[ -n ${ldd} ]]; then + export LDFLAGS=-fuse-ld=${ldd} +fi if [[ ! -d build ]]; then meson setup -Dfuzz=enabled -Dtests=enabled build || exit $? fi -meson compile -C build || exit $? - -ninja clippy -C build || exit $? - -for test in unittests; do - meson test -v ${test} -C build || exit $? -done - -# hack to make sure we use the system meson, since meson format from git is broken -/usr/bin/meson format --recursive --check-only || exit $? +ebegin "running check commands" +parallel --halt soon,fail=1 --keep-order -j$(nproc) < check_commands.txt +eend $? || exit $? diff --git a/check_commands.txt b/check_commands.txt new file mode 100644 index 0000000..f1c34fd --- /dev/null +++ b/check_commands.txt @@ -0,0 +1,4 @@ +/usr/bin/meson format --recursive --check-only +rustfmt --edition 2024 --check $(find src -type f -name '*.rs') +ninja clippy -C build +meson test unittests -C build