Skip to content

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

Merged
merged 9 commits into from
Jun 25, 2019

Conversation

chriselion
Copy link
Contributor

@chriselion chriselion commented Jun 21, 2019

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.

@chriselion chriselion changed the title Develop precommit black Use pre-commit for CI tests, add black hook Jun 21, 2019
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
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 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.

Copy link
Contributor Author

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
Copy link
Contributor Author

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.

@chriselion chriselion requested a review from xiaomaogy June 24, 2019 16:42
Copy link
Contributor

@xiaomaogy xiaomaogy left a 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

@chriselion chriselion merged commit d767905 into develop Jun 25, 2019
@chriselion chriselion deleted the develop-precommit-black branch July 11, 2019 22:26
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants