Skip to content
Merged
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
27 changes: 22 additions & 5 deletions nextflow-lint-hook
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,28 @@ if [[ ${#files[@]} -eq 0 ]]; then
exit 0
fi

# Run nextflow lint with flags followed by files
# Use ${args[@]+"${args[@]}"} for bash 3.x compatibility (empty array + set -u)
if nextflow lint ${args[@]+"${args[@]}"} "${files[@]}"; then
echo "✅ Nextflow lint passed"
else
# Run nextflow lint in batches to avoid "Argument list too long" (E2BIG)
# when pre-commit passes thousands of files on large repos.
# Capture output so we can filter per-batch success noise while
# always showing errors, warnings, and any other diagnostic output.
batch_size=200
lint_failed=false
all_output=""

for ((i=0; i<${#files[@]}; i+=batch_size)); do
batch=("${files[@]:i:batch_size}")
# Use ${args[@]+...} for bash 3.x compatibility (empty array + set -u)
batch_output=$(nextflow lint ${args[@]+"${args[@]}"} "${batch[@]}" 2>&1) || lint_failed=true
all_output+="$batch_output"$'\n'
done

# Always display output (errors are never hidden), but filter out
# the per-batch success summaries to keep CI logs readable.
printf '%s' "$all_output" | grep -vE 'Nextflow linting complete!|files had no errors' || true

if $lint_failed; then
echo "❌ Nextflow lint failed"
exit 1
else
echo "✅ Nextflow lint passed (${#files[@]} files)"
fi