Created
October 13, 2021 08:02
-
-
Save sh0rtcircuit/de50745c660fead9975f16ea2b0654f6 to your computer and use it in GitHub Desktop.
Example pipeline for python CI pipeline caching in Azure DevOps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variables: | |
CONDA_ENV_NAME: "unit_test" | |
# set $(CONDA) environment variable to your conda path (pre-populated on 'ubuntu-latest' VMs) | |
CONDA_ENV_DIR: $(CONDA)/envs/$(CONDA_ENV_NAME) | |
steps: | |
- script: echo "##vso[task.prependpath]$CONDA/bin" | |
displayName: Add conda to PATH | |
- task: Cache@2 | |
displayName: Use cached Anaconda environment | |
inputs: | |
key: 'conda | "$(Agent.OS)" | requirements.txt' | |
path: $(CONDA_ENV_DIR) | |
cacheHitVar: CONDA_CACHE_RESTORED | |
- bash: conda create --yes --quiet --name $(CONDA_ENV_NAME) | |
displayName: Create Anaconda environment | |
condition: eq(variables.CONDA_CACHE_RESTORED, 'false') | |
- bash: | | |
source activate $(CONDA_ENV_NAME) | |
pip install -r requirements.txt | |
displayName: Install dependencies | |
condition: eq(variables.CONDA_CACHE_RESTORED, 'false') | |
# Optional step here: Install your package (do not cache this step) | |
- bash: | | |
source activate $(CONDA_ENV_NAME) | |
pip install --no-deps . | |
pytest . | |
displayName: Install package and execute unit tests |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment