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

Precommit addition to the repo #82

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft

Precommit addition to the repo #82

wants to merge 1 commit into from

Conversation

ryandanehy
Copy link
Collaborator

@ryandanehy ryandanehy commented Nov 27, 2023

@ryandanehy ryandanehy force-pushed the precommit branch 3 times, most recently from 1282316 to 741140d Compare November 28, 2023 23:04
@pelesh
Copy link
Collaborator

pelesh commented Nov 29, 2023

@ryandanehy, can we stage this PR? First stage would be to set up configurations. Once that is merged, we can run formatting on the code and have a separate PR to merge formatted code. Is that doable?

@ryandanehy
Copy link
Collaborator Author

@ryandanehy, can we stage this PR? First stage would be to set up configurations. Once that is merged, we can run formatting on the code and have a separate PR to merge formatted code. Is that doable?

Once we merge this any push to a PR that rebased on Develop will automatically format the code. I can change the CI to only run when manually triggered if that is preferred?

Essentially options are manual trigger or automatically with every push to a PR.

@ryandanehy ryandanehy force-pushed the precommit branch 2 times, most recently from daf4126 to fd3d082 Compare November 29, 2023 21:36
@ryandanehy
Copy link
Collaborator Author

@pelesh I think this is good to go with the merge. Then I will open a new pr with all the precommit suggested code changes. The precommit ci fails currently because it thinks the code is not format correctly so it is doing it jobs correctly.

@pelesh pelesh marked this pull request as ready for review November 30, 2023 01:10
@pelesh
Copy link
Collaborator

pelesh commented Nov 30, 2023

@pelesh I think this is good to go with the merge. Then I will open a new pr with all the precommit suggested code changes. The precommit ci fails currently because it thinks the code is not format correctly so it is doing it jobs correctly.

Let's review. I propose we merge it after #83 and #86 are merged.

Copy link
Collaborator

@cameronrutherford cameronrutherford left a comment

Choose a reason for hiding this comment

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

A few changes, but as well we should verify this auto-fixes changes before merging. Your pipelines are failing, and they should be abl to fix themselves.

Comment on lines +21 to +28
# - uses: EndBug/add-and-commit@v9.1.3
# # Only need to try and commit if the action failed
# if: failure()
# with:
# fetch: false
# committer_name: GitHub Actions
# committer_email: actions@github.com
# message: Apply pre-commmit fixes
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we want pre-commit to automatically apply fixes, so lets comment this back in

Comment on lines +5 to +9
workflow_dispatch:
inputs:
branch:
description: 'The branch to build'
required: true
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
workflow_dispatch:
inputs:
branch:
description: 'The branch to build'
required: true

If we just run on pull_request, doesn't that generate the desired behavior?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was trying to set it to manual so that people could start the workflow as needed. This is in reference to #82 (comment).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Well I suggest maybe deferring the implementation of that new feature into a different PR since it doesn't seem to work here, and is unclear at the moment.

Maybe instead you could also code a GitHub bot that can run the fixes for us automatically if you really want to over-engineer this...

Copy link
Collaborator

Choose a reason for hiding this comment

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

I still don't get this. Why not just on pull_request... Your code seems like it's non-functional as I have never seen manual pipelines before

Comment on lines 1 to 11
ci:
autofix_commit_msg: |
[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
autofix_prs: true
autoupdate_branch: ''
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
autoupdate_schedule: weekly
skip: []
submodules: false
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not familiar with this configuration section. Shouldn't we just use what's in the GitHub action to autofix, and then customize the commit message there?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I still don't think this configuration section is necessary at all. The commit message is controlled by the GitHub action, and this does nothing.

@ryandanehy
Copy link
Collaborator Author

@cameronrutherford I commented out the auto fixes per slaven request for this PR. See #82 (comment)

The pipelines fail because it wants to autofix but I am not letting it.

@cameronrutherford
Copy link
Collaborator

@cameronrutherford I commented out the auto fixes per slaven request for this PR. See #82 (comment)

The pipelines fail because it wants to autofix but I am not letting it.

I guess we merge this with failing pipelines then :(

@pelesh
Copy link
Collaborator

pelesh commented Nov 30, 2023

@cameronrutherford I commented out the auto fixes per slaven request for this PR. See #82 (comment)
The pipelines fail because it wants to autofix but I am not letting it.

I guess we merge this with failing pipelines then :(

The other option is to enable auto checks and we merge this PR last thing before the release. Once we turn on style auto-correction all rebasing and merging will turn into a nightmare.

@cameronrutherford
Copy link
Collaborator

@cameronrutherford I commented out the auto fixes per slaven request for this PR. See #82 (comment)

The pipelines fail because it wants to autofix but I am not letting it.

I guess we merge this with failing pipelines then :(

The other option is to enable auto checks and we merge this PR last thing before the release. Once we turn on style auto-correction all rebasing and merging will turn into a nightmare.

Since you can now rebase automatically with buttons, it's not so bad. I do agree though that with PRs in motion it would be easier to merge this after those.

Copy link
Collaborator

@pelesh pelesh left a comment

Choose a reason for hiding this comment

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

Is it possible to run pre-commit locally or it runs only on GitHub?

We need at least minimal documentation in the top-level README file on how to use pre-commit before this can get merged.

Also, some tweaks to the configuration options are needed. For example, I noticed pre-commit tries to sort include directives alphabetically what is not something we really want.

@ryandanehy
Copy link
Collaborator Author

@pelesh I rebased, added some instructions in the main readme.md, and fixed pre-commit so that it does not sort includes. Let me your thoughts so we can get this merged.

Copy link
Collaborator

@cameronrutherford cameronrutherford left a comment

Choose a reason for hiding this comment

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

Getting there

Comment on lines +5 to +9
workflow_dispatch:
inputs:
branch:
description: 'The branch to build'
required: true
Copy link
Collaborator

Choose a reason for hiding this comment

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

I still don't get this. Why not just on pull_request... Your code seems like it's non-functional as I have never seen manual pipelines before

Comment on lines 1 to 11
ci:
autofix_commit_msg: |
[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
autofix_prs: true
autoupdate_branch: ''
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
autoupdate_schedule: weekly
skip: []
submodules: false
Copy link
Collaborator

Choose a reason for hiding this comment

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

I still don't think this configuration section is necessary at all. The commit message is controlled by the GitHub action, and this does nothing.

README.md Outdated
Comment on lines 61 to 81
### Running Pre-commit locally
To run pre-commit locally you first must install pre-commit. It can be installed via
```shell
pip install pre-commit
```

Copy link
Collaborator

Choose a reason for hiding this comment

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

How do I install pip? What about Python? What if I am on a linux vs mac?

README.md Outdated

To install the hooks and have pre-commit run automatically before every commit run
```shell
pre-commit install
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
pre-commit install
pre-commit install --install-hooks

```shell
pre-commit run --all-files
```
To learn more about pre-commit usuage check out https://pre-commit.com/#usage.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe add some more information here about:

  • Rebasing against auto-fixes in PRs
  • Understanding git-flow in this context
    • What do I do when pre-commit fails?
    • Why does all this new stuff appear when I run git commit?

@pelesh
Copy link
Collaborator

pelesh commented Dec 28, 2023

I believe the failed test on Ascent is due to issue fixed in #109. Perhaps a good idea would be rebasing to develop to make sure this test passes?

more docs on pre-commit
@ryandanehy
Copy link
Collaborator Author

I believe the failed test on Ascent is due to issue fixed in #109. Perhaps a good idea would be rebasing to develop to make sure this test passes?

Just rebased.

@cameronrutherford
Copy link
Collaborator

pre-commit tests are still failing and no auto-fix is being applied

@pelesh pelesh assigned stonecoldhughes and unassigned ryandanehy Sep 20, 2024
@pelesh pelesh added enhancement New feature or request testing labels Sep 20, 2024
@pelesh pelesh reopened this Sep 20, 2024
@pelesh pelesh marked this pull request as draft September 20, 2024 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add pre-commit configuration + GitHub Actions Define a Clang-format txt file
4 participants