use gnu parallel to run pre-commit hook check commands in parallel

This commit is contained in:
John Turner
2025-11-28 17:16:33 +00:00
parent 558e213ab4
commit 7b60034425
2 changed files with 12 additions and 16 deletions

View File

@@ -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 $?

4
check_commands.txt Normal file
View File

@@ -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