Skip to content

refactor: replace reviewdog with direct cargo calls and PR comment - #67

Merged
alexmohr merged 5 commits into
mainfrom
feature/improve-workflows
Aug 31, 2026
Merged

alexmohr merged 5 commits into
mainfrom
feature/improve-workflows

Conversation

@alexmohr

Copy link
Copy Markdown
Contributor

Summary

  • Remove rust-lint-and-format-action reviewdog integration (giraffate/clippy-action, reviewdog setup, checkstyle XML helpers)
  • Remove shared-config/cargo-fmt.sh and cargo-clippy.sh; pre-commit hooks now call cargo directly (language: system)
  • Nightly clippy runs warn-only (continue-on-error); findings are posted as a PR comment with a disclaimer that they are informational and may be unrelated to PR changes; no comment posted when clean
  • New action inputs: toolchain, all-features, post-pr-comment
  • Document RUSTUP_TOOLCHAIN=nightly as the local opt-in for nightly clippy via prek

Checklist

  • I have tested my changes locally
  • I have added or updated documentation
  • I have linked related issues or discussions
  • I have added or updated tests

Related

Notes for Reviewers

@alexmohr
alexmohr force-pushed the feature/improve-workflows branch 12 times, most recently from 3488859 to bc47422 Compare June 17, 2026 12:47
@alexmohr
alexmohr marked this pull request as ready for review June 17, 2026 13:37
@alexmohr
alexmohr force-pushed the feature/improve-workflows branch 2 times, most recently from 0ae1c3c to 5afa22d Compare June 18, 2026 20:00
Comment thread .pre-commit-hooks.yaml Outdated
Comment thread rust-lint-and-format-action/action.yml Outdated
run: |
git fetch --depth=1 origin "${{ inputs.base-sha }}" 2>/dev/null || true
git diff "${{ inputs.base-sha }}...HEAD" --unified=0 > /tmp/pr.diff
echo "diff_file=/tmp/pr.diff" >> "$GITHUB_OUTPUT"

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.

question: Why is it put as output result, but never used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

Comment thread rust-lint-and-format-action/action.yml Outdated
uses: giraffate/clippy-action@v1
- name: Post nightly-clippy comment on PR
if: >-
inputs.post-pr-comment == 'true' && github.event_name == 'pull_request' && steps.clippy.outputs.has_findings == 'true' && github.event.pull_request.head.repo.full_name == github.repository

@floroks floroks Jun 29, 2026 •

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.

I think this is missing the ${{ }}, otherwise it's not evaluated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Seems to work fine on the test PR I did on CDA eclipse-opensovd/classic-diagnostic-adapter#385 (comment), anyhow I will test again once I addressed the remaining issues :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No it's not necessary. But after looking at this again after some passed since I created this PR I was still pretty unhappy with how complicated it still is. I dropped all the comment handling for format and clippy, just look at the pipeline output directly.
I did add two small wrapper scripts, so we can configure pre commit properly for format and clippy.

Example for CDA.
Now if you run pre-commit it will run format with the correct nightly stage and clippy with 1.88 and the pinned nightly version.
We might want to update the nightly version to something more recent in the future but that is out of scope for here.

      - id: cargo-fmt
        args:
          - --toolchain=nightly-2025-07-14
          - --all
      - id: cargo-clippy
        name: clippy (stable)
        args:
          - --toolchain=1.88
          - --all-targets
          - --locked
          - --
          - -D
          - warnings
      - id: cargo-clippy
        name: clippy (nightly)
        args:
          - --toolchain=nightly-2025-07-14
          - --all-targets
          - --locked
          - --
          - -D
          - warnings

@alexmohr
alexmohr force-pushed the feature/improve-workflows branch 12 times, most recently from 780f272 to c512250 Compare July 1, 2026 09:14
@floroks

floroks commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

needs rebase (conflict in README)

alexmohr added 3 commits July 23, 2026 20:35
- Remove rust-lint-and-format-action reviewdog integration
  (giraffate/clippy-action, reviewdog setup, checkstyle XML helpers)
- Remove shared-config/cargo-fmt.sh and cargo-clippy.sh; pre-commit
  hooks now call cargo directly (language: system)
- Nightly clippy runs warn-only (continue-on-error); findings are
  posted as a PR comment with a disclaimer that they are informational
  and may be unrelated to PR changes; no comment posted when clean
- New action inputs: toolchain, all-features, post-pr-comment
- Document RUSTUP_TOOLCHAIN=nightly as the local opt-in for nightly
  clippy via prek

Signed-off-by: Alexander Mohr <alexander.m.mohr@mercedes-benz.com>
@alexmohr
alexmohr force-pushed the feature/improve-workflows branch from c512250 to 0f19d76 Compare July 23, 2026 18:35
@alexmohr

Copy link
Copy Markdown
Contributor Author

@floroks rebased :)

floroks
floroks previously approved these changes Aug 27, 2026

@mbfm mbfm left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Mostly nitpicks, but I spotted one bug as well.

Comment thread pre-commit-action/cargo-clippy-hook.py Outdated
Comment on lines +46 to +47
cargo = "cargo"
cmd = [cargo]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nitpick:

Suggested change
cargo = "cargo"
cmd = [cargo]
cmd = ["cargo"]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I am going to assume you also wanted me to remove the pointless variable above :)

Comment thread pre-commit-action/cargo-fmt-hook.py Outdated
Comment on lines +41 to +42
cargo = "cargo"
cmd = [cargo]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nitpick:

Suggested change
cargo = "cargo"
cmd = [cargo]
cmd = ["cargo"]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread rust-lint-and-format-action/action.yml Outdated
description: 'Reporter to use for reviewdog'
required: false
default: 'github-pr-review'
default: '--all-features --all-targets --D warnings'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think, this should be:

Suggested change
default: '--all-features --all-targets --D warnings'
default: '--all-features --all-targets --locked -- --deny=warnings'

The --locked is from .pre-commit-hooks.yaml. Not sure, if you maybe decided against that here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, done

|| FMT_EXIT=$?
- name: Format check (rustfmt)
id: fmt
continue-on-error: true

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
continue-on-error: true
continue-on-error: true # fail later to present all errors to user at once

I think, you mentioned this to me at some point. Maybe good to document that. 🙂

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Using same comment for both lines.

/tmp/checkstyle.xml /tmp/rustfmt_stderr.log "$STDERR_SEVERITY"
- name: Clippy
id: clippy
continue-on-error: true

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
continue-on-error: true
continue-on-error: true # fail later to present all errors to user at once

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Using # Set to 'true' to present all errors to user at once, 'false' fails immediately.

Comment thread .pre-commit-hooks.yaml Outdated
Comment on lines +72 to +73
- -D
- warnings

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Easier to understand like this:

Suggested change
- -D
- warnings
- --deny=warnings

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thanks, done :)

Signed-off-by: Alexander Mohr <alexander.m.mohr@mercedes-benz.com>
@alexmohr
alexmohr force-pushed the feature/improve-workflows branch from 6708173 to dc0f14e Compare August 28, 2026 11:07
@alexmohr
alexmohr merged commit febc566 into main Aug 31, 2026
4 checks passed
@alexmohr
alexmohr deleted the feature/improve-workflows branch August 31, 2026 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants