diff --git a/.github/actions/pr-check/action.yml b/.github/actions/pr-check/action.yml new file mode 100644 index 000000000..28dc95e1e --- /dev/null +++ b/.github/actions/pr-check/action.yml @@ -0,0 +1,137 @@ +name: PR check +description: >- + Runs one dev/check-.mjs on the lines a pull request adds and reports + its findings on the PR: a summary comment plus a review comment on each + flagged line (dev/check-report.sh). The job must check out the repository + first, with fetch-depth 0; the default ref, the merge commit, is right. + +inputs: + script: + description: The check script, e.g. dev/check-links.mjs + required: true + name: + description: >- + Marks the comments the check posts, e.g. check-links; see + dev/check-report.sh + required: true + arguments: + description: Flags for every run of the script + default: '' + head-only-arguments: + description: >- + Flags for the run on the pull request only, not for recording the + baseline on the merge base + default: '' + diff-paths: + description: Paths the diff of the pull request is limited to; all by default + default: '' + baseline: + description: >- + Record the script's findings on the merge base too (--format json + --root) and pass them as --baseline, so only the findings this PR + introduces are reported + default: 'false' + dependency: + description: >- + An npm package the script imports, installed at the version in + package.json without the rest of the site's dependencies + default: '' + fail-on-findings: + description: Fail the job when the script reports findings; advisory otherwise + default: 'false' + +outputs: + result: + description: clean, found, or crashed + value: ${{ steps.check.outputs.result }} + +runs: + using: composite + steps: + # The workflow and this action are read from the merge commit, so run + # the scripts from there too: a branch that predates a check has no + # script for it, and the merge commit also has this PR's changes to + # them. Everything else is checked as the PR branch has it. + - name: Check out the pull request head, with the check scripts from the merge commit + shell: bash + env: + HEAD_SHA: ${{ github.event.pull_request.head.sha }} + run: | + git checkout --quiet "$HEAD_SHA" + git checkout --quiet "$GITHUB_SHA" -- dev + + - name: Install ${{ inputs.dependency }} + if: inputs.dependency != '' + shell: bash + env: + DEPENDENCY: ${{ inputs.dependency }} + # Into a scratch prefix, not the repo: `npm install ` next to + # package.json would install every dependency of the site + run: | + npm install --prefix "$RUNNER_TEMP/deps" --no-package-lock --no-audit --no-fund \ + "$DEPENDENCY@$(node -p "require('./package.json').dependencies['$DEPENDENCY']")" + ln -s "$RUNNER_TEMP/deps/node_modules" node_modules + + # The script exits 1 both with findings and when it crashes. It writes + # its output in one go at the end, so a crash leaves it empty. A crash + # does not fail the check, since it says nothing about the PR; the + # report step says so instead of posting the empty report. + - name: Run ${{ inputs.script }} on the lines this PR adds + id: check + shell: bash + env: + SCRIPT: ${{ inputs.script }} + ARGUMENTS: ${{ inputs.arguments }} + HEAD_ONLY_ARGUMENTS: ${{ inputs.head-only-arguments }} + DIFF_PATHS: ${{ inputs.diff-paths }} + BASELINE: ${{ inputs.baseline }} + BASE_SHA: ${{ github.event.pull_request.base.sha }} + # File links in the report open the file on the PR branch + LINK_BASE: ${{ github.event.pull_request.head.repo.html_url }}/blob/${{ github.event.pull_request.head.ref }} + run: | + # The arguments are lists, so they are left unquoted on purpose + # shellcheck disable=SC2086 + merge_base=$(git merge-base "$BASE_SHA" HEAD) + git diff -U0 "$merge_base" HEAD -- $DIFF_PATHS > "$RUNNER_TEMP/changes.diff" + + baseline_flag= + if [ "$BASELINE" = true ]; then + git worktree add --quiet "$RUNNER_TEMP/base" "$merge_base" + node "$SCRIPT" $ARGUMENTS --format json --root "$RUNNER_TEMP/base" > "$RUNNER_TEMP/baseline.json" || true + if ! [ -s "$RUNNER_TEMP/baseline.json" ]; then + echo "::warning::$SCRIPT crashed on the base branch, so this PR was not checked" + echo "result=crashed" >> "$GITHUB_OUTPUT" + exit 0 + fi + baseline_flag="--baseline $RUNNER_TEMP/baseline.json" + fi + + if node "$SCRIPT" $ARGUMENTS $HEAD_ONLY_ARGUMENTS --format markdown $baseline_flag \ + --diff "$RUNNER_TEMP/changes.diff" \ + --review "$RUNNER_TEMP/review.json" \ + --link-base "$LINK_BASE" > "$RUNNER_TEMP/report.md"; then + echo "result=clean" >> "$GITHUB_OUTPUT" + elif [ -s "$RUNNER_TEMP/report.md" ]; then + echo "result=found" >> "$GITHUB_OUTPUT" + else + echo "::warning::$SCRIPT crashed, so this PR was not checked" + echo "result=crashed" >> "$GITHUB_OUTPUT" + fi + cat "$RUNNER_TEMP/report.md" + + - name: Report on the pull request + # Fork PRs get a read-only token; the report is still in the job log + if: github.event.pull_request.head.repo.full_name == github.repository + shell: bash + env: + GH_TOKEN: ${{ github.token }} + PR_NUMBER: ${{ github.event.pull_request.number }} + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + NAME: ${{ inputs.name }} + RESULT: ${{ steps.check.outputs.result }} + run: dev/check-report.sh "$NAME" "$RESULT" "$RUNNER_TEMP/report.md" "$RUNNER_TEMP/review.json" + + - name: Fail when this PR introduces findings + if: inputs.fail-on-findings == 'true' && steps.check.outputs.result == 'found' + shell: bash + run: exit 1 diff --git a/.github/workflows/check-duplicates.yml b/.github/workflows/check-duplicates.yml index d295a7a28..e65340d51 100644 --- a/.github/workflows/check-duplicates.yml +++ b/.github/workflows/check-duplicates.yml @@ -10,7 +10,9 @@ on: paths: - 'docs/**' - 'dev/check-duplicates.mjs' - - 'dev/sync-review-comments.sh' + - 'dev/check-shared.mjs' + - 'dev/check-report.sh' + - '.github/actions/pr-check/action.yml' - '.github/workflows/check-duplicates.yml' # A new push supersedes the run for the previous one @@ -27,93 +29,13 @@ jobs: name: Duplicated content introduced by this PR (advisory) runs-on: ubuntu-latest steps: - - name: Check out pull request head - uses: actions/checkout@v7 + - uses: actions/checkout@v7 with: - ref: ${{ github.event.pull_request.head.sha }} fetch-depth: 0 - - name: Check out merge base - env: - BASE_SHA: ${{ github.event.pull_request.base.sha }} - run: | - merge_base=$(git merge-base "$BASE_SHA" HEAD) - git worktree add "$RUNNER_TEMP/base" "$merge_base" - git diff -U0 "$merge_base" HEAD -- docs > "$RUNNER_TEMP/changes.diff" - - # The script exits 1 both with findings and when it crashes. It writes - # its output in one go at the end, so a crash leaves it empty. A crash - # does not fail the check, since it says nothing about the PR; the - # comment step reports it instead of posting the empty report. - - name: Record duplicated passages already present on the base branch - run: | - node dev/check-duplicates.mjs --format json \ - --root "$RUNNER_TEMP/base" > "$RUNNER_TEMP/base-duplicates.json" || true - - - name: Find duplicated passages introduced by this PR - id: check - env: - # File links in the report open the file on the PR branch - LINK_BASE: ${{ github.event.pull_request.head.repo.html_url }}/blob/${{ github.event.pull_request.head.ref }} - run: | - if ! [ -s "$RUNNER_TEMP/base-duplicates.json" ]; then - echo "::warning::check-duplicates crashed on the base branch, so this PR was not checked" - echo "result=crashed" >> "$GITHUB_OUTPUT" - exit 0 - fi - if node dev/check-duplicates.mjs --format markdown \ - --baseline "$RUNNER_TEMP/base-duplicates.json" \ - --diff "$RUNNER_TEMP/changes.diff" \ - --review "$RUNNER_TEMP/review.json" \ - --link-base "$LINK_BASE" > "$RUNNER_TEMP/report.md"; then - echo "result=clean" >> "$GITHUB_OUTPUT" - elif [ -s "$RUNNER_TEMP/report.md" ]; then - echo "result=found" >> "$GITHUB_OUTPUT" - else - echo "::warning::check-duplicates crashed, so this PR was not checked" - echo "result=crashed" >> "$GITHUB_OUTPUT" - fi - cat "$RUNNER_TEMP/report.md" - - - name: Comment on the pull request - # Fork PRs get a read-only token; the report is still in the job log - if: github.event.pull_request.head.repo.full_name == github.repository - env: - GH_TOKEN: ${{ github.token }} - PR_NUMBER: ${{ github.event.pull_request.number }} - RESULT: ${{ steps.check.outputs.result }} - RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - run: | - marker='' - existing_comment=$(gh api "repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments" \ - --paginate --jq ".[] | select(.body | startswith(\"$marker\")) | .id" | head -n 1) - - # Comment when there is something to report, or an earlier report to resolve - case "$RESULT" in - found) - { echo "$marker"; cat "$RUNNER_TEMP/report.md"; } > "$RUNNER_TEMP/comment.md" ;; - crashed) - printf '%s\n### ⚠️ The duplicated content check could not run on this revision\n\nThis is a problem with the check, not with this PR; see the [job log](%s).\n' \ - "$marker" "$RUN_URL" > "$RUNNER_TEMP/comment.md" ;; - *) - [ -n "$existing_comment" ] || exit 0 - { echo "$marker"; cat "$RUNNER_TEMP/report.md"; } > "$RUNNER_TEMP/comment.md" ;; - esac - - if [ -n "$existing_comment" ]; then - gh api --method PATCH "repos/$GITHUB_REPOSITORY/issues/comments/$existing_comment" \ - --field body=@"$RUNNER_TEMP/comment.md" - else - gh pr comment "$PR_NUMBER" --body-file "$RUNNER_TEMP/comment.md" - fi - - - name: Point out the duplicates as review comments - # One comment per added passage, kept in sync with the findings; - # see dev/sync-review-comments.sh - if: >- - github.event.pull_request.head.repo.full_name == github.repository - && contains(fromJSON('["clean", "found"]'), steps.check.outputs.result) - env: - GH_TOKEN: ${{ github.token }} - PR_NUMBER: ${{ github.event.pull_request.number }} - run: dev/sync-review-comments.sh '' - existing_comment=$(gh api "repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments" \ - --paginate --jq ".[] | select(.body | startswith(\"$marker\")) | .id" | head -n 1) - - # Comment when there is something to report, or an earlier report to resolve - case "$RESULT" in - found) - { echo "$marker"; cat "$RUNNER_TEMP/report.md"; } > "$RUNNER_TEMP/comment.md" ;; - crashed) - printf '%s\n### ⚠️ The example hostnames check could not run on this revision\n\nThis is a problem with the check, not with this PR; see the [job log](%s).\n' \ - "$marker" "$RUN_URL" > "$RUNNER_TEMP/comment.md" ;; - *) - [ -n "$existing_comment" ] || exit 0 - { echo "$marker"; cat "$RUNNER_TEMP/report.md"; } > "$RUNNER_TEMP/comment.md" ;; - esac - - if [ -n "$existing_comment" ]; then - gh api --method PATCH "repos/$GITHUB_REPOSITORY/issues/comments/$existing_comment" \ - --field body=@"$RUNNER_TEMP/comment.md" - else - gh pr comment "$PR_NUMBER" --body-file "$RUNNER_TEMP/comment.md" - fi - - - name: Suggest fixes as review comments - # One suggested change per flagged line, kept in sync with the - # findings; see dev/sync-review-comments.sh - if: >- - github.event.pull_request.head.repo.full_name == github.repository - && contains(fromJSON('["clean", "found"]'), steps.check.outputs.result) - env: - GH_TOKEN: ${{ github.token }} - PR_NUMBER: ${{ github.event.pull_request.number }} - run: dev/sync-review-comments.sh '' - existing_comment=$(gh api "repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments" \ - --paginate --jq ".[] | select(.body | startswith(\"$marker\")) | .id" | head -n 1) - - # Comment when there is something to report, or an earlier report to resolve - case "$RESULT" in - broken) - { echo "$marker"; cat "$RUNNER_TEMP/report.md"; } > "$RUNNER_TEMP/comment.md" ;; - crashed) - printf '%s\n### ⚠️ The links check could not run on this revision\n\nThis is a problem with the check, not with this PR; see the [job log](%s).\n' \ - "$marker" "$RUN_URL" > "$RUNNER_TEMP/comment.md" ;; - *) - [ -n "$existing_comment" ] || exit 0 - printf '%s\n### ✅ This revision introduces no broken links\n' \ - "$marker" > "$RUNNER_TEMP/comment.md" ;; - esac - - if [ -n "$existing_comment" ]; then - gh api --method PATCH "repos/$GITHUB_REPOSITORY/issues/comments/$existing_comment" \ - --field body=@"$RUNNER_TEMP/comment.md" - else - gh pr comment "$PR_NUMBER" --body-file "$RUNNER_TEMP/comment.md" - fi - - - name: Suggest fixes as review comments - # One suggested change per finding with a fix, kept in sync with the - # findings; see dev/sync-review-comments.sh - if: >- - github.event.pull_request.head.repo.full_name == github.repository - && contains(fromJSON('["clean", "broken"]'), steps.check.outputs.result) - env: - GH_TOKEN: ${{ github.token }} - PR_NUMBER: ${{ github.event.pull_request.number }} - run: dev/sync-review-comments.sh '' - existing_comment=$(gh api "repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments" \ - --paginate --jq ".[] | select(.body | startswith(\"$marker\")) | .id" | head -n 1) - - # Comment when there is something to report, or an earlier report to resolve - case "$RESULT" in - broken) - { echo "$marker"; cat "$RUNNER_TEMP/report.md"; } > "$RUNNER_TEMP/comment.md" ;; - crashed) - printf '%s\n### ⚠️ The redirects check could not run on this revision\n\nThis is a problem with the check, not with this PR; see the [job log](%s).\n' \ - "$marker" "$RUN_URL" > "$RUNNER_TEMP/comment.md" ;; - *) - [ -n "$existing_comment" ] || exit 0 - printf '%s\n### ✅ This revision breaks no redirects\n' \ - "$marker" > "$RUNNER_TEMP/comment.md" ;; - esac - - if [ -n "$existing_comment" ]; then - gh api --method PATCH "repos/$GITHUB_REPOSITORY/issues/comments/$existing_comment" \ - --field body=@"$RUNNER_TEMP/comment.md" - else - gh pr comment "$PR_NUMBER" --body-file "$RUNNER_TEMP/comment.md" - fi - - - name: Suggest fixes as review comments - # One suggested change per fixable entry this PR added, kept in sync - # with the findings; see dev/sync-review-comments.sh - if: >- - github.event.pull_request.head.repo.full_name == github.repository - && contains(fromJSON('["clean", "broken"]'), steps.check.outputs.result) - env: - GH_TOKEN: ${{ github.token }} - PR_NUMBER: ${{ github.event.pull_request.number }} - run: dev/sync-review-comments.sh '` and each review comment +# `` +# report the Markdown the check script wrote, the summary body for clean +# and found; crashed gets a message linking the job log instead +# review {comments: [{path, line, start_line?, body}]} from the script's +# --review, not read when crashed +# +# The summary is posted or reopened for findings and a crash; a clean result +# only updates and minimizes the summary of an earlier run, so a PR that +# never had findings never gets a comment. Review comments are posted for the +# new findings, updated when their text changed, and deleted when their +# finding is gone or GitHub could not carry them to the new revision (line is +# null). Needs GH_TOKEN, GITHUB_REPOSITORY, GITHUB_WORKFLOW, PR_NUMBER, and +# RUN_URL. +set -eu +name=$1 +result=$2 +report=$3 +review=$4 +repository="repos/$GITHUB_REPOSITORY" + +# Summary comment + +marker="" +existing=$(gh api "$repository/issues/$PR_NUMBER/comments" --paginate \ + --jq ".[] | select(.body | startswith(\"$marker\")) | \"\(.id) \(.node_id)\"" | head -n 1) + +if [ "$result" = crashed ]; then + body=$(printf '%s\n### ⚠️ %s could not run on this revision\n\nThis is a problem with the check, not with this PR; see the [job log](%s).\n' \ + "$marker" "$GITHUB_WORKFLOW" "$RUN_URL") +else + body=$(printf '%s\n' "$marker"; cat "$report") +fi + +if [ -z "$existing" ]; then + [ "$result" = clean ] || gh api --method POST "$repository/issues/$PR_NUMBER/comments" --raw-field body="$body" --silent +else + gh api --method PATCH "$repository/issues/comments/${existing% *}" --raw-field body="$body" --silent + # Minimizing is GraphQL-only. Both mutations are idempotent + if [ "$result" = clean ]; then + mutation="minimizeComment(input: {subjectId: \$id, classifier: RESOLVED})" + else + mutation="unminimizeComment(input: {subjectId: \$id})" + fi + gh api graphql --raw-field id="${existing#* }" \ + --raw-field query="mutation(\$id: ID!) { $mutation { clientMutationId } }" --silent +fi + +[ "$result" != crashed ] || exit 0 + +# Review comments, matched to the findings by file, line, and marker line + +marker="`, ...explanation].join( + '\n' + ) + }; +} + +// Body for POST /repos/{owner}/{repo}/pulls/{n}/reviews: one comment per +// finding in a file; title and description findings have no line to comment +// on. No review body: a submitted review cannot be deleted, so a body would +// outlive the comments once the words are fixed. +function reviewRequest(findings) { + const comments = findings + .filter(finding => !finding.field) + .slice(0, MAX_INLINE_COMMENTS) + .map(reviewComment); + return {event: 'COMMENT', body: '', comments}; +} + +function main() { + if (!DIFF) { + throw new Error('Missing required --diff '); + } + const files = [...DIFF.keys()]; const findings = [ - ...findingsOnAddedLines(ranges, [ + ...findingsOnAddedLines([ ...runCSpell(files), ...unsortedDictionaryEntries(files) ]), ...(PULL_REQUEST_FILE ? pullRequestFindings(PULL_REQUEST_FILE) : []) ]; - process.stdout.write( - FORMAT === 'json' - ? JSON.stringify(findings, null, '\t') + '\n' - : formatText(findings) + report(findings, {text: formatText, markdown: formatMarkdown}, () => + reviewRequest(findings) ); - process.exit(findings.length === 0 ? 0 : 1); } -main().catch(error => { +try { + main(); +} catch (error) { console.error(error); process.exit(2); -}); +} diff --git a/dev/post-spelling-review.mjs b/dev/post-spelling-review.mjs deleted file mode 100644 index 109f1e711..000000000 --- a/dev/post-spelling-review.mjs +++ /dev/null @@ -1,388 +0,0 @@ -#!/usr/bin/env node - -/** - * Reports CSpell findings on a pull request: one summary comment in the - * discussion, plus an inline review comment on each flagged line. Findings in - * the pull request's title or description (those with a `field`) have no line - * to comment on, so they appear in the summary only. Once the findings are - * fixed, the summary is minimized as resolved and the inline comments are - * deleted; the review that carried them has no body, so nothing of it remains - * visible. - * - * Usage: node dev/post-spelling-review.mjs --findings [--dry-run] - * node dev/post-spelling-review.mjs --crashed [--dry-run] - * - * Reads the JSON written by `dev/check-spelling.mjs --format json`. With - * `--crashed`, the summary says the check could not run and links the job log - * (RUN_URL) instead; the inline comments are left as they are. - * Requires GH_TOKEN, GITHUB_REPOSITORY, PR_NUMBER, HEAD_SHA and HEAD_REF. - */ - -import {readFileSync} from 'fs'; - -const args = process.argv.slice(2); -const FINDINGS_FILE = args[args.indexOf('--findings') + 1]; -const CRASHED = args.includes('--crashed'); -const DRY_RUN = args.includes('--dry-run'); -const MAX_INLINE_COMMENTS = 25; - -const API_URL = process.env.GITHUB_API_URL ?? 'https://api.github.com'; -const REPOSITORY = process.env.GITHUB_REPOSITORY; -const PR_NUMBER = process.env.PR_NUMBER; -const HEAD_SHA = process.env.HEAD_SHA; -const HEAD_REF = process.env.HEAD_REF; -const RUN_URL = process.env.RUN_URL; - -// Link to the PR branch, not the commit, so GitHub's edit button works from it -const ALLOW_LIST_LINK = `[\`cspell-allow-list.txt\`](https://github.com/${REPOSITORY}/blob/${HEAD_REF}/cspell-allow-list.txt)`; - -const SUMMARY_MARKER = ''; -const INLINE_MARKER = '/)?.[1]; - return word && findingKey({file: comment.path, line: comment.line, word}); -} - -// CSpell suggests case-insensitively, so prefer a suggestion whose first -// letter matches the case of the flagged word. -function bestSuggestion({word, suggestions}) { - const isUpper = letter => letter === letter.toUpperCase(); - return ( - suggestions.find( - suggestion => isUpper(suggestion[0]) === isUpper(word[0]) - ) ?? suggestions[0] - ); -} - -// One GitHub suggestion block with an apply button. A four-backtick fence so -// lines containing ``` cannot break out of the block. -function suggestionBlock(finding) { - const suggestion = bestSuggestion(finding); - if (!suggestion) { - return []; - } - const {text, column, word} = finding; - const start = column - 1; - return [ - `Did you mean \`${suggestion}\`?`, - '', - '````suggestion', - text.slice(0, start) + suggestion + text.slice(start + word.length), - '````', - '' - ]; -} - -function inlineBody(finding) { - const explanation = finding.message - ? [messageText(finding)] - : [ - `\`${finding.word}\` is not in the dictionary.`, - '', - ...suggestionBlock(finding), - `Please correct the spelling, or add words which are correct to ${ALLOW_LIST_LINK}.`, - '', - `Comment on this PR with \`/spell ${finding.word}\`, and a bot will push a commit to your branch adding it to ${ALLOW_LIST_LINK} for you.` - ]; - return [`${INLINE_MARKER} ${finding.word} -->`, ...explanation].join('\n'); -} - -async function syncInlineComments(findings) { - const wanted = new Map( - findings - .filter(finding => !finding.field) - .map(finding => [findingKey(finding), finding]) - ); - const comments = await githubList( - `/repos/${REPOSITORY}/pulls/${PR_NUMBER}/comments` - ); - - for (const comment of comments) { - const key = existingCommentKey(comment); - if (!key) { - continue; - } - if (wanted.has(key)) { - const body = inlineBody(wanted.get(key)); - if (body !== comment.body) { - await githubWrite( - 'PATCH', - `/repos/${REPOSITORY}/pulls/comments/${comment.id}`, - {body} - ); - } - wanted.delete(key); - } else { - await githubWrite( - 'DELETE', - `/repos/${REPOSITORY}/pulls/comments/${comment.id}` - ); - } - } - - const fresh = [...wanted.values()]; - if (fresh.length === 0) { - return; - } - // No review body: the inline comments say it all, and a submitted review - // cannot be deleted, so a body would outlive the comments once fixed. - await githubWrite( - 'POST', - `/repos/${REPOSITORY}/pulls/${PR_NUMBER}/reviews`, - { - commit_id: HEAD_SHA, - event: 'COMMENT', - body: '', - comments: fresh.slice(0, MAX_INLINE_COMMENTS).map(finding => ({ - path: finding.file, - line: finding.line, - side: 'RIGHT', - body: inlineBody(finding) - })) - } - ); -} - -async function main() { - for (const name of [ - 'GH_TOKEN', - 'GITHUB_REPOSITORY', - 'PR_NUMBER', - 'HEAD_SHA', - 'HEAD_REF' - ]) { - if (!process.env[name]) { - throw new Error(`Missing required environment variable ${name}`); - } - } - if (CRASHED) { - if (!RUN_URL) { - throw new Error('Missing required environment variable RUN_URL'); - } - console.log('Reporting that the check crashed'); - await upsertSummaryComment(crashedBody(), false); - return; - } - if (!FINDINGS_FILE) { - throw new Error('Missing required --findings '); - } - - const findings = JSON.parse(readFileSync(FINDINGS_FILE, 'utf8')); - console.log(`${findings.length} finding(s) to report`); - const resolved = findings.length === 0; - await upsertSummaryComment( - resolved ? RESOLVED_BODY : summaryBody(findings), - resolved - ); - await syncInlineComments(findings); -} - -main().catch(error => { - console.error(error); - process.exit(2); -}); diff --git a/dev/sync-review-comments.sh b/dev/sync-review-comments.sh deleted file mode 100755 index 6ecd7b806..000000000 --- a/dev/sync-review-comments.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env sh -# Make a check's suggested-change review comments on a PR match a review.json -# ({comments: [{path, line, start_line?, body}]}): post the new ones, update -# the ones whose text changed, and delete the ones whose finding is gone. -# GitHub sets line to null on comments it could not carry to the new revision, -# so those are deleted too. Comments are matched by file, line, and the -# marker comment on their first line, e.g. "". -# -# Usage: dev/sync-review-comments.sh '