|
| 1 | +# Template workflow (Azure Pipelines). VT example. |
| 2 | + |
| 3 | +# Build and test a project in all available setup configurations provided by DARMA-taking/workflows. |
| 4 | +# See also: Github version at .github/workflows/build-and-test.yml |
| 5 | + |
| 6 | +name: PR tests (project test example) |
| 7 | + |
| 8 | +trigger: |
| 9 | + branches: |
| 10 | + include: |
| 11 | + - master |
| 12 | + |
| 13 | +pr: |
| 14 | + drafts: false |
| 15 | + autoCancel: true |
| 16 | + branches: |
| 17 | + include: |
| 18 | + - '*' |
| 19 | + |
| 20 | +variables: |
| 21 | + CI_REPO: DARMA-tasking/workflows |
| 22 | + CI_BRANCH: master |
| 23 | + |
| 24 | +jobs: |
| 25 | +- job: getMatrix |
| 26 | + pool: |
| 27 | + vmImage: 'ubuntu-latest' |
| 28 | + displayName: 'Get matrix' |
| 29 | + steps: |
| 30 | + - bash: | |
| 31 | + wget https://raw.githubusercontent.com/${{ variables.CI_REPO }}/refs/heads/${{ variables.CI_BRANCH }}/ci/shared/matrix/azure.json |
| 32 | + matrix=$(cat azure.json | jq -c '.matrix') |
| 33 | + echo "##vso[task.setvariable variable=matrix;isOutput=true]$matrix" |
| 34 | + displayName: 'Get matrix' |
| 35 | + name: getMatrixStep |
| 36 | +
|
| 37 | +- job: run |
| 38 | + displayName: 'Run' |
| 39 | + dependsOn: getMatrix |
| 40 | + strategy: |
| 41 | + matrix: $[ dependencies.getMatrix.outputs['getMatrixStep.matrix'] ] |
| 42 | + # displayName: ${{ label }} # contrary to github cannot get a way to inject label from matrix. azure just appends the item key automatically |
| 43 | + pool: |
| 44 | + vmImage: $(vmImage) |
| 45 | + timeoutInMinutes: 180 |
| 46 | + steps: |
| 47 | + - bash: | |
| 48 | + echo "Environment=$(label)" |
| 49 | + echo "Runner=$(vmImage)" |
| 50 | + if [ "$(image)" != "" ] |
| 51 | + then |
| 52 | + echo "> With Docker Image=$(image)" |
| 53 | + else |
| 54 | + echo "> With Runner Setup=$(setup)" |
| 55 | + fi |
| 56 | + displayName: Display configuration |
| 57 | +
|
| 58 | + - bash: | |
| 59 | + if [[ "$(image)" == "" ]]; then |
| 60 | + echo "::group::Setup in runner" |
| 61 | + echo "Set setup permissions..." |
| 62 | + sudo mkdir -p /opt |
| 63 | + sudo chown $(whoami) /opt |
| 64 | + wget -O setup.sh https://raw.githubusercontent.com/${{ variables.CI_REPO }}/refs/heads/${{ variables.CI_BRANCH }}/ci/shared/scripts/setup-$(setup).sh |
| 65 | + chmod +x setup.sh |
| 66 | + export WF_SETUP_ID=$(setup) |
| 67 | + ./setup.sh |
| 68 | + echo "::endgroup::" |
| 69 | + elif [[ "$(image)" != "" ]]; then |
| 70 | + echo "::group::Pull Docker image" |
| 71 | + docker image pull $(image) |
| 72 | + echo "::endgroup::" |
| 73 | + fi |
| 74 | + displayName: Set up dependencies |
| 75 | +
|
| 76 | +
|
| 77 | + - bash: | |
| 78 | + CMD="uname -a" |
| 79 | + if [[ "$(image)" == "" ]] |
| 80 | + then |
| 81 | + $CMD |
| 82 | + else |
| 83 | + docker run $(image) $CMD |
| 84 | + fi |
| 85 | + displayName: Run (example) |
| 86 | +
|
| 87 | + - bash: | |
| 88 | + mkdir -p /opt/scripts |
| 89 | + cd /opt/scripts |
| 90 | + wget https://raw.githubusercontent.com/${{ variables.CI_REPO }}/refs/heads/${{ variables.CI_BRANCH }}/ci/shared/scripts/runner/set-variable.sh && chmod +x set-variable.sh |
| 91 | + wget https://raw.githubusercontent.com/${{ variables.CI_REPO }}/refs/heads/${{ variables.CI_BRANCH }}/ci/shared/scripts/runner/set-timestamps.sh && chmod +x set-timestamps.sh |
| 92 | + ./set-timestamps.sh |
| 93 | + displayName: Extract timestamps for caching |
| 94 | +
|
| 95 | + - bash: | |
| 96 | + echo "TODO: implement cache usage if required by your project" |
| 97 | + displayName: Setup build cache (vt) |
| 98 | +
|
| 99 | + - bash: | |
| 100 | + CMD='mkdir -p "/opt/vt/src" "/opt/vt/build/vt" ; \ |
| 101 | + git clone https://github.com/DARMA-tasking/vt /opt/vt/src ; \ |
| 102 | + cd /opt/vt/src ; \ |
| 103 | + bash ci/build_cpp.sh /opt/vt/src /opt/vt/build ; \ |
| 104 | + bash ci/test_cpp.sh /opt/vt/src /opt/vt/build ; \ |
| 105 | + bash ci/build_vt_sample.sh /opt/vt/src /opt/vt/build ; |
| 106 | + rm -rf "/opt/vt/src" "/opt/vt/build"' |
| 107 | +
|
| 108 | + echo "Running ${CMD}" |
| 109 | +
|
| 110 | + if [[ "$(image)" == "" ]]; then |
| 111 | + bash -c "$CMD"; |
| 112 | + else |
| 113 | + docker run \ |
| 114 | + --name test-container \ |
| 115 | + -e CI="1" \ |
| 116 | + -e CMAKE_CXX_STANDARD="17" \ |
| 117 | + -e CMAKE_BUILD_TYPE="Release" \ |
| 118 | + $(image) \ |
| 119 | + bash -c "$CMD" |
| 120 | + exit $(docker container inspect --format '{{.State.ExitCode}}' test-container) |
| 121 | + fi |
| 122 | + displayName: PR tests (vt) |
| 123 | + condition: or( contains(variables['label'], 'mpich'), contains(variables['label'], 'openmpi') ) |
0 commit comments