-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Use pre-commit for CI tests, add black hook #2163
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
Conversation
.circleci/config.yml
Outdated
black --check ml-agents | ||
black --check ml-agents-envs | ||
black --check gym-unity | ||
git ls-files ml-agents | xargs pre-commit run --show-diff-on-failure --files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't love this because it makes it harder to run the same checks on CI and locally. After mypy checks are running (in another PR) I'll revisit this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Figured out how to get mypy working with a single invocation, so can do this in one call now.
@@ -24,7 +24,7 @@ jobs: | |||
pip install --upgrade setuptools | |||
cd ml-agents-envs && pip install -e . | |||
cd ../ml-agents && pip install -e . | |||
pip install black pytest-cov==2.6.1 codacy-coverage==1.3.11 | |||
pip install pre-commit pytest-cov==2.6.1 codacy-coverage==1.3.11 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pre-commit will install all the corresponding hooks that it needs, so we don't need to install black directly anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, this is much cleaner than black
Set up pre-commit (https://pre-commit.com/hooks.html) with a single hook to run
black
. This is a no-op for now, but we can add other checks like mypy soon.You can see the output from a failed CI run here: https://circleci.com/gh/Unity-Technologies/ml-agents/873?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link It's slightly nicer (IMHO) since it shows the diff of applying the linter, so you have a better idea of where the failure is.