Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] adding pre-commit CI and JuliaFormatter #47094

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Format suggestions

on:
pull_request:

concurrency:
# Skip intermediate builds: always.
# Cancel intermediate builds: only if it is a pull request build.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}

jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Moelf marked this conversation as resolved.
Show resolved Hide resolved
- uses: julia-actions/setup-julia@latest
Moelf marked this conversation as resolved.
Show resolved Hide resolved
with:
version: 1
- run: |
julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="1.0.10"))'
julia -e 'using JuliaFormatter; format(".", MinimalStyle(); normalize_line_endings = "unix")'
Moelf marked this conversation as resolved.
Show resolved Hide resolved
- uses: reviewdog/action-suggester@v1
Moelf marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

@t-bltg t-bltg Oct 8, 2022

Choose a reason for hiding this comment

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

Are the annotations left by reviewdog/action-suggester really helpful ? IMO, they just pollute the Files changed view by adding tons of annotations. I know they can be disabled (manual intervention needed - cumbersome), but they tend to distract attention. I think that the failing JuliaFormatter check is enough (we don't want contributors to fix this by hand as reviewdog suggests (wrong signal), but run the formatter in the repo instead).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They don't pollute file changes more than the original PR, in the ideal case it pushes to the PR branch

Failing a formatting test is a step in wrong direction, now you have something that PR author needs to download and setup in order to make PR, super annoying

Copy link
Contributor

Choose a reason for hiding this comment

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

PRs with many comments, like for example #43990, would become even more unwieldy though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

which is why I always wanted it to be directly pushing to fork branch

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I mean idk, it seems people think nothing is better than anything so maybe I will just drop this

with:
tool_name: JuliaFormatter
fail_on_error: true
filter_mode: added
13 changes: 13 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v15.0.0
hooks:
- id: clang-format
types_or: [c++, c]