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

Replace (part of) pretest of CI with Pre-commit equivalent #918

Merged
merged 29 commits into from
Jul 6, 2022

Conversation

lebrice
Copy link
Collaborator

@lebrice lebrice commented May 18, 2022

Addresses #918

Also applies the formatting, spelling mistakes, and python upgrade hooks to all files.

@lebrice lebrice marked this pull request as ready for review May 18, 2022 23:57
@lebrice
Copy link
Collaborator Author

lebrice commented May 19, 2022

Hmm this doesnt quite work: seems like it's only running the pre-commit workflow at the moment.

@bouthilx
Copy link
Member

Is there a corrector is the pre-commit? 😯 That's great!

It seems the pre-commit is missing the doc compilation. That's to long to be included in the pre-commit indeed but should still be part of the pre-tests.

@bouthilx
Copy link
Member

There also seems to be no equivalent for pylint in the pre-commit.

@lebrice
Copy link
Collaborator Author

lebrice commented May 19, 2022

Ok @bouthilx I left the doc and pylint steps as part of pre-test, and moved the rest to pre-commit. Pylint is a bit annoying to use as a pre-commit hook, since it requires having pylint installed locally. It also seems to take a really long time, from my limited experience.

@lebrice lebrice changed the title Replace pretest of CI with Pre-commit equivalent Replace (part of) pretest of CI with Pre-commit equivalent May 19, 2022
pretest:
needs: pre-commit
Copy link
Member

Choose a reason for hiding this comment

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

Can we not wait for pre-commit? If we could set the execution of pre-commit in tox we could have toxenv: [pylint, docs, pre-commit] so that the main tests still depends on the same pretests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The main tests still depend on the same pretests though, right?
I dont quite understand.

Copy link
Collaborator Author

@lebrice lebrice May 26, 2022

Choose a reason for hiding this comment

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

What would be the advantage of running pre-commit through tox vs running pre-commit as a github action with the same jobs?

Copy link
Member

Choose a reason for hiding this comment

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

Running them through tox would make it possible to include the pre-commit tests in the current pre-test matrix. Having the pre-commit tests available in the tox config would also make it possible to run these tests locally if necessary outside of the pre-commit hook.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note: The tests can be run locally with pre-commit run <hook_name>, and either --all-files, or --files <files>.

@bouthilx
Copy link
Member

What is blocking this PR at the moment?

@lebrice
Copy link
Collaborator Author

lebrice commented Jun 28, 2022

As far as I recall, I need to basically fix a few tests that got broken by removing unused imports in all modules.

lebrice and others added 21 commits July 4, 2022 17:58
Signed-off-by: Fabrice Normandin <normandf@mila.quebec>
Signed-off-by: Fabrice Normandin <normandf@mila.quebec>
Signed-off-by: Fabrice Normandin <normandf@mila.quebec>
Signed-off-by: Fabrice Normandin <normandf@mila.quebec>
Signed-off-by: Fabrice Normandin <normandf@mila.quebec>
Signed-off-by: Fabrice Normandin <normandf@mila.quebec>
Signed-off-by: Fabrice Normandin <normandf@mila.quebec>
I was previously adding some more hooks. I'll instead keep those
locally, but only replicate the current CI setup with pre-commit.

Signed-off-by: Fabrice Normandin <normandf@mila.quebec>
This removes the need to import fixtures as unused variables in the
other test packages. The autoflake hook removed those unused imports,
and with this, we don't need to import them in the first place.

Signed-off-by: Fabrice Normandin <normandf@mila.quebec>
Signed-off-by: Fabrice Normandin <normandf@mila.quebec>
Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
lebrice added 6 commits July 4, 2022 18:16
Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
@@ -219,7 +219,7 @@ def load_data(
raise RuntimeError(
f"Download finished, but file {file} still doesn't exist!"
)
with open(file, "r") as f:
with open(file) as f:
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't pylint complain about not specifying the encoding? 🤔

Copy link
Member

@bouthilx bouthilx left a comment

Choose a reason for hiding this comment

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

This will be awesome to use, thanks a lot!

@lebrice lebrice merged commit 5fb2b4e into Epistimio:develop Jul 6, 2022
@lebrice lebrice deleted the pre-commit-ci branch July 6, 2022 18:51
@bouthilx bouthilx added the ci label Jul 6, 2022
@notoraptor notoraptor mentioned this pull request Aug 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants