diff options
author | 2020-03-04 18:25:04 -0800 | |
---|---|---|
committer | 2020-03-04 19:46:47 -0800 | |
commit | b785d46996440c9320c96a9ad757f222f6b51bfc (patch) | |
tree | a3ee6fb6422e501eb5dcd9b89b668ac745975fcb /bot/utils/persist.py | |
parent | Add more pre-commit hooks (diff) |
CI: run pre-commit hooks in CI
Pre-commit creates its own environment in which it installs hooks. To
speed up runs, the pipeline will cache this for use with future jobs.
The cache will update if .pre-commit-config.yaml changes.
The flake8 pre-commit hook invokes flake8 via `pipenv run flake8`. It's
normally useful to use pipenv here cause it ensures flake8 is invoked
within the context of the venv. However, in CI, there is no venv -
dependencies are installed directly to the system site-packages.
`pipenv run` does not work in such case because it tries to create a new
venv if one doesn't exist (it doesn't consider the system interpreter to
be a venv).
This workaround (okay, it's a hack) creates an executable shell script
which replaces the original pipenv binary. The shell script simply
ignores the first argument (i.e. ignores `run` in `pipenv run`) and
executes the rest of the arguments as a command. It essentially makes
`pipenv run flake8` equivalent to just having ran `flake8`. When
pre-commit executes pipenv, the aforementioned script is what will run.
* Re-format indentation of azure-pipelines.yml
Diffstat (limited to 'bot/utils/persist.py')
0 files changed, 0 insertions, 0 deletions