sourcegraph/dev/ci/parallel_run.sh
Noah S-C bc97fdbe34
add shellcheck & shfmt to pre-commit's pre-push hook (#59485)
Closes https://github.com/sourcegraph/sourcegraph/issues/54829

Next steps: 
- what safeguards will we have in place for when we remove this from `sg lint`
- should we remove it from `sg lint`, its likely not contributing much overhead even in the uncommon case of shell files being touched

_How did some of these violations get in when theres shell lints :clueless:_

## Test plan

`pre-commit run --hook-stage=pre-push shellcheck shfmt`
2024-01-11 14:16:22 +00:00

30 lines
610 B
Bash
Executable File

#!/usr/bin/env bash
create_annotation() {
code=$1
file=$2
if [ "$code" -eq 0 ]; then
return
fi
slurp=$(cat "$file")
printf "\`\`\`\n%s\n\`\`\`\n" "$slurp" >"$(dirname "${BASH_SOURCE[0]}")/../../annotations/Job log.md"
}
log_file=$(mktemp)
# shellcheck disable=SC2064
trap "rm -rf $log_file" EXIT
# Remove parallel citation log spam.
echo 'will cite' | parallel --citation &>/dev/null
parallel --jobs 4 --memfree 500M --keep-order --line-buffer --joblog "$log_file" -v "$@"
code=$?
echo "--- done - displaying job log:"
cat "$log_file"
create_annotation "$code" "$log_file"
exit "$code"