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

ci: Run pre-commit checks in CI #176

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

russellb
Copy link
Contributor

@russellb russellb commented Oct 3, 2024

Closes #172

e6c3a4b ci: Run pre-commit checks in CI
adeee1e flake8: Fix config formatting error

commit e6c3a4b
Author: Russell Bryant rbryant@redhat.com
Date: Thu Oct 3 13:52:24 2024 +0000

ci: Run pre-commit checks in CI

Run the pre-commit checks in a github workflow to validate that a PR
or a direct push to the repo does not introduce new errors.

Signed-off-by: Russell Bryant <rbryant@redhat.com>

commit adeee1e
Author: Russell Bryant rbryant@redhat.com
Date: Thu Oct 3 14:00:20 2024 +0000

flake8: Fix config formatting error

The list of paths under `exclude` had a formatting error. Entries must
be separated by commas.

Signed-off-by: Russell Bryant <rbryant@redhat.com>

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 3, 2024
@russellb russellb marked this pull request as ready for review October 3, 2024 14:19
@russellb
Copy link
Contributor Author

russellb commented Oct 3, 2024

You can find a passing test run of this here: https://github.com/russellb/llama-stack/actions/runs/11163763978

Copy link
Contributor

@ashwinb ashwinb left a comment

Choose a reason for hiding this comment

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

nice! I have one comment amount about not running it on all files in the repository.

@@ -21,11 +21,11 @@ ignore =
optional-ascii-coding = True
exclude =
./.git,
./docs
./build
./docs/*,
Copy link
Contributor

Choose a reason for hiding this comment

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

wow good catch

pip install pre-commit

- name: Run pre-commit
run: pre-commit run --all-files
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should run it on all files because this means people will get stopped if someone committed something outside of this hook and now their PR will have to mirror all the fixes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That shouldn't happen, right? I think it's a fair expectation that anyone pushing directly to the repo is using the pre-commit hook.

If that were to happen anyway, they should get an email that this job failed because it will run any time commits are pushed, as well.

With that said, if you still want it to only apply to the diff instead of the full tree, I'll make the change. Just let me know.

Copy link
Contributor

Choose a reason for hiding this comment

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

That shouldn't happen, right? I think it's a fair expectation that anyone pushing directly to the repo is using the pre-commit hook.

Yes that's the expectation but this happens for a bunch of reasons right now. Not everyone has the hooks set up and we are sort of slowly becoming more disciplined about every thing. Adding this right now might stop a bunch of folks in the tracks so to speak.

But I agree with you that this should be the norm. And we should make this happen sooner than later. For now though, let's make it only run on the files in the diff.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sounds good! will update and comment again when it's done

Copy link
Contributor Author

Choose a reason for hiding this comment

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

took a bit, but i got it working -- passing run on a test PR here: https://github.com/russellb/llama-stack/actions/runs/11168500406/job/31047043034?pr=1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nevermind, it's failing here on this PR ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

... ok, working for real this time

@russellb russellb marked this pull request as draft October 3, 2024 19:11
@russellb russellb force-pushed the pre-commit-ci branch 6 times, most recently from bcc8d09 to 37a7a02 Compare October 3, 2024 19:32
Run the pre-commit checks in a github workflow to validate that a PR
or a direct push to the repo does not introduce new errors.

Signed-off-by: Russell Bryant <rbryant@redhat.com>
The list of paths under `exclude` had a formatting error. Entries must
be separated by commas.

Signed-off-by: Russell Bryant <rbryant@redhat.com>
Signed-off-by: Russell Bryant <rbryant@redhat.com>
@russellb russellb force-pushed the pre-commit-ci branch 4 times, most recently from c5a7628 to 98f404a Compare October 3, 2024 19:42
Signed-off-by: Russell Bryant <rbryant@redhat.com>
@russellb russellb marked this pull request as ready for review October 3, 2024 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Meta Open Source bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add checks from pre-commit to CI
3 participants