From: "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: "Chris. Webster" <chris@webstech.net>,
Johannes Schindelin <johannes.schindelin@gmx.de>,
Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: [PATCH] ci: make the whitespace checker more robust
Date: Tue, 03 Nov 2020 15:55:31 +0000 [thread overview]
Message-ID: <pull.778.git.1604418931303.gitgitgadget@gmail.com> (raw)
From: Johannes Schindelin <johannes.schindelin@gmx.de>
In 32c83afc2c69 (ci: github action - add check for whitespace errors,
2020-09-22), we introduced a GitHub workflow that automatically checks
Pull Requests for whitespace problems.
However, when affected lines contain one or more double quote
characters, this workflow failed to attach the informative comment
because the Javascript snippet incorrectly interpreted these quotes
instead of using the `git log` output as-is.
Let's fix that.
While at it, let's `await` the result of the `createComment()` function.
Finally, we enclose the log in the comment with ```...``` to avoid
having the diff marker be misinterpreted as an enumeration bullet.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
ci: make the whitespace checker more robust
I noticed that the checker failed to add a comment
[https://github.com/gitgitgadget/git/runs/1344883313?check_suite_focus=true]
in one of my PRs. Turns out that the double-quote characters in the log
output made it fail.
One thing we discussed earlier whether the log should be pasted as
pre-formatted text or not, and we fell on the side of not pre-formatting
it. However, in my tests, this does not look right
[https://github.com/dscho/git/pull/18#issuecomment-721160985], and it
looks much better pre-formatted
[https://github.com/dscho/git/pull/18#issuecomment-721167209] (even if
we unfortunately lose the direct link to the commit
[https://github.com/dscho/git/commit/68317764849af81b17c4b31906da20bdf2c52082]
).
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-778%2Fdscho%2Ffix-whitespace-github-workflow-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-778/dscho/fix-whitespace-github-workflow-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/778
.github/workflows/check-whitespace.yml | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/check-whitespace.yml b/.github/workflows/check-whitespace.yml
index 9d070b9cdf..80a961716b 100644
--- a/.github/workflows/check-whitespace.yml
+++ b/.github/workflows/check-whitespace.yml
@@ -58,12 +58,14 @@ jobs:
- name: Add Check Output as Comment
uses: actions/github-script@v3
id: add-comment
+ env:
+ log: ${{ steps.check_out.outputs.checkout }}
with:
script: |
- github.issues.createComment({
+ await github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
- body: "Whitespace errors found in workflow ${{ github.workflow }}:\n\n${{ steps.check_out.outputs.checkout }}"
+ body: `Whitespace errors found in workflow ${{ github.workflow }}:\n\n\`\`\`\n${process.env.log.replace(/\\n/g, "\n")}\n\`\`\``
})
if: ${{ failure() }}
base-commit: 32c83afc2c69aa51b82aa223f2099389f1f0be0a
--
gitgitgadget
next reply other threads:[~2020-11-03 15:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-03 15:55 Johannes Schindelin via GitGitGadget [this message]
2020-11-03 22:02 ` [PATCH] ci: make the whitespace checker more robust Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=pull.778.git.1604418931303.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=chris@webstech.net \
--cc=git@vger.kernel.org \
--cc=johannes.schindelin@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).