I have a toy C++ cmake project with the following azure-pipelines.yml (see HelloAzure for sources).
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
trigger:
- master
variables:
SOURCE_DIR: '$(System.DefaultWorkingDirectory)'
BUILD_DIR: '$(SOURCE_DIR)/build'
INSTALL_DIR: '$(SOURCE_DIR)/install'
stages:
- stage: Build
displayName: Build
pool:
vmImage: ubuntu-latest
jobs:
- job: BuildLinux
strategy:
matrix:
Release:
BUILD_TYPE: 'Release'
Debug:
BUILD_TYPE: 'Debug'
steps:
- script: |
echo "mkdir BUILD_DIR $(BUILD_DIR)"
mkdir $(BUILD_DIR)
echo "cd build directory "
cd $(BUILD_DIR)
echo " Run configure command"
cmake -DCMAKE_INSTALL_PREFIX=$(INSTALL_DIR)/$(BUILD_TYPE) $(SOURCE_DIR)
echo "running cmake build command"
cmake --build . --target install --config $(BUILD_TYPE) -j 12
- stage: BuildTests
dependsOn: Build
displayName: BuildTests
jobs:
- job: RunCTestLinux
steps:
- script: |
cd $(BUILD_DIR)
ctest
Locally I can do the following:
# download sources
git clone https://github.com/CiaranWelsh/HelloAzure.git
# build
cd HelloAzure
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=../install ..
cmake --build . --target install --config Release -j 12
# test
ctest
I am trying to reproduce this workflow in azure. It is trivial to do using just one stage, but as soon as I try to run the tests in a "test" stage, Azure simply re-downloads the sources and tried to run the tests without first having ran the build command.
So my question, what is the proper mechanism for separating the build and test stages of a project in azure-pipelines?
Aucun commentaire:
Enregistrer un commentaire