Skip to content

ci(workflows): suggest lint fixes via reviewdog#29423

Open
caugner wants to merge 11 commits into
mainfrom
pr-reviewdog
Open

ci(workflows): suggest lint fixes via reviewdog#29423
caugner wants to merge 11 commits into
mainfrom
pr-reviewdog

Conversation

@caugner
Copy link
Copy Markdown
Contributor

@caugner caugner commented Apr 7, 2026

Summary

Updates the lint job of the test workflow to run lint:fix in case of failures, capturing the resulting diff in an artifact, which is passed to reviewdog via a new separate pr-reviewdog workflow.

Test results and supporting details

Example for how it looks: caugner#1

Related issues

@github-actions github-actions Bot added infra Infrastructure issues (npm, GitHub Actions, releases) of this project size:l [PR only] 101-1000 LoC changed labels Apr 7, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 7, 2026

Tip: Review these changes grouped by change (recommended for most PRs), or grouped by feature (for large PRs).

@caugner
Copy link
Copy Markdown
Contributor Author

caugner commented May 7, 2026

This was discussed in the BCD project meeting on 2026-04-14:

  • Concerns were raised around the experience for first-time contributors.
  • It was requested to include a link to the job (that ran the lint), or to docs explaining the workflow.

caugner added 4 commits May 7, 2026 18:00
Explains the `bcd-linter` review suggestions that CI posts on pull
requests when lint fails, and how contributors can apply them.
When inline suggestions are posted, also create or update a single PR
comment that links to the Test workflow run and to docs explaining how
to apply or push back on the suggestions.
Looks up the lint job's URL from the originating Test workflow run so
the sticky PR comment links directly to the lint logs instead of the
run overview. Falls back to the workflow run URL if the job lookup
returns nothing. Drops the now redundant "Originating workflow run"
trailer.
Filters the marker-comment lookup by author (github-actions[bot]) so a
spoofed comment from another user starting with the same HTML marker
can't be overwritten by the workflow.
@github-actions github-actions Bot added the docs Issues or pull requests regarding the documentation of this project. label May 7, 2026
Comment thread .github/workflows/pr-reviewdog.yml Dismissed
@caugner
Copy link
Copy Markdown
Contributor Author

caugner commented May 7, 2026

@ddbeck @Elchi3 How does this comment look?

@caugner caugner marked this pull request as ready for review May 7, 2026 17:05
@caugner caugner requested a review from a team as a code owner May 7, 2026 17:05
@caugner caugner requested a review from LeoMcA May 7, 2026 17:05
Copy link
Copy Markdown
Contributor

@ddbeck ddbeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm neutral on the message. Anything we can do to tighten this up? Maybe like this?

The lint check found auto-fixable issues. Apply suggested inline changes above (by bcd-linter) or, to fix all at once, run npm run lint:fix locally and commit the result.

See also Automated lint suggestions on pull requests.

Comment thread .github/workflows/pr-reviewdog.yml Outdated
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: lint-results
path: lint-results
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ought we specify the files to be uploaded? Seems potentially risky to upload a whole directory, where someone could upload… whatever they want? (I know it's not terribly likely, but then again my intuitions about what's dangerous about GA is… untrustworthy.)

Copy link
Copy Markdown
Contributor Author

@caugner caugner May 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test workflow runs on: pull_request, so it runs the version of the PR, and is under the control of the PR author.

We ignore all other files in the artifact, as we only use the lint.diff file here:

env -u GITHUB_ACTIONS reviewdog \
-guess \
-name="bcd-linter" \
-f=diff \
-f.diff.strip=1 \
-filter-mode=diff_context \
-reporter=github-pr-review < ../lint-results/lint.diff

The only risk is if reviewdog was vulnerable to some input, then an attacker might be able to exfiltrate the GITHUB_TOKEN, with the following permissions:

permissions:
# Download artifact from lint workflow.
actions: read
# Post inline review comments via reviewdog.
pull-requests: write
# Report commit status.
statuses: write

The advantage of having a folder artifact is that it retains the file name of the included file.

@caugner
Copy link
Copy Markdown
Contributor Author

caugner commented May 13, 2026

I'm neutral on the message. Anything we can do to tighten this up? Maybe like this?

Tightened it as follows now:

The lint check found auto-fixable issues. Apply suggested changes (attributed to bcd-linter) or, to fix all at once, run npm run lint:fix locally.

See also Automated lint suggestions on pull requests.

@caugner caugner requested a review from ddbeck May 13, 2026 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Issues or pull requests regarding the documentation of this project. infra Infrastructure issues (npm, GitHub Actions, releases) of this project size:l [PR only] 101-1000 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants