aboutsummaryrefslogtreecommitdiffstats
path: root/azure-pipelines.yml
diff options
context:
space:
mode:
Diffstat (limited to 'azure-pipelines.yml')
-rw-r--r--azure-pipelines.yml24
1 files changed, 22 insertions, 2 deletions
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 35dea089a..280f11a36 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -13,10 +13,12 @@ jobs:
variables:
PIP_CACHE_DIR: ".cache/pip"
+ PRE_COMMIT_HOME: $(Pipeline.Workspace)/pre-commit-cache
steps:
- task: UsePythonVersion@0
displayName: 'Set Python version'
+ name: PythonVersion
inputs:
versionSpec: '3.8.x'
addToPath: true
@@ -27,8 +29,26 @@ jobs:
- script: pipenv install --dev --deploy --system
displayName: 'Install project using pipenv'
- - script: python -m flake8
- displayName: 'Run linter'
+ # Create an executable shell script which replaces the original pipenv binary.
+ # The shell script ignores the first argument and executes the rest of the args as a command.
+ # It makes the `pipenv run flake8` command in the pre-commit hook work by circumventing
+ # pipenv entirely, which is too dumb to know it should use the system interpreter rather than
+ # creating a new venv.
+ - script: |
+ printf '%s\n%s' '#!/bin/bash' '"${@:2}"' > $(PythonVersion.pythonLocation)/bin/pipenv \
+ && chmod +x $(PythonVersion.pythonLocation)/bin/pipenv
+ displayName: 'Mock pipenv binary'
+
+ - task: Cache@2
+ displayName: 'Restore pre-commit environment'
+ inputs:
+ key: pre-commit | "$(PythonVersion.pythonLocation)" | .pre-commit-config.yaml
+ restoreKeys: |
+ pre-commit | "$(PythonVersion.pythonLocation)"
+ path: $(PRE_COMMIT_HOME)
+
+ - script: pre-commit run --all-files --show-diff-on-failure
+ displayName: 'Run pre-commit hooks'
- script: BOT_API_KEY=foo BOT_SENTRY_DSN=blah BOT_TOKEN=bar WOLFRAM_API_KEY=baz REDDIT_CLIENT_ID=spam REDDIT_SECRET=ham coverage run -m xmlrunner
displayName: Run tests