Skip to content

Commit

Permalink
create-pr.sh: fix "Argument list too long" error (hopefully)
Browse files Browse the repository at this point in the history
  • Loading branch information
samuela committed Sep 22, 2023
1 parent c9ea914 commit 578bf79
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions create-pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,14 @@ pr_url=$(gh pr create \
--title "$PACKAGE: $PRE_VERSION -> $newversion" \
--body "$body" \
--draft)
echo "Created PR: $pr_url"

echo "Running nix-build..."
if build_log=$(nix-build -A "$PACKAGE" 2>&1); then
body=$(cat <<-_EOM_
# Use --body-file to work around "Argument list too long" errors.
body_file=$(mktemp)

cat <<-_EOM_ > "$body_file"
nix-build was successful! Marking this PR as ready for review.
<details>
Expand All @@ -113,14 +117,15 @@ nix-build was successful! Marking this PR as ready for review.
${build_log}
\`\`\`
</details>
_EOM_
)
gh pr comment "$pr_url" --body "$body"

gh pr comment "$pr_url" --body-file "$body_file"
gh pr ready "$pr_url"
rm -f "$body_file"
else
abbreviated_build_log=$(tail -n15 < "$build_log")
body=$(cat <<-_EOM_
body_file=$(mktemp)
cat <<-_EOM_ > "$body_file"
nix-build failed. Leaving this PR as a draft for now. Push commits to this branch and mark as "ready for review" once
the build issues have been resolved.
Expand All @@ -139,10 +144,10 @@ ${abbreviated_build_log}
${build_log}
\`\`\`
</details>
_EOM_
)
gh pr comment "$pr_url" --body "$body"

gh pr comment "$pr_url" --body-file "$body_file"
rm -f "$body_file"
fi

# TODO: run nixpkgs-review as well if nix-build succeeds

0 comments on commit 578bf79

Please sign in to comment.