jobs-template.yml 6.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

parameters:
  test_pool_definition: # defines the hardware pool for compilation and unit test execution.
  e2e_pool_definion: # defines the hardware pool for end-to-end test execution
  stage_name: # defines a unique identifier for all jobs in a stage (in case the jobs are added multiple times to a stage)
  environment: # defines environment variables for downstream scripts
21 22
  run_end_to_end: # if set to 'true', the end to end tests will be executed
  container: # the container name for the build
23
  jdk: # the jdk version to use
24 25 26 27 28

jobs:
- job: compile_${{parameters.stage_name}}
  condition: not(eq(variables['MODE'], 'e2e'))
  pool: ${{parameters.test_pool_definition}}
29
  container: ${{parameters.container}}
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
  timeoutInMinutes: 240
  cancelTimeoutInMinutes: 1
  workspace:
    clean: all # this cleans the entire workspace directory before running a new job
    # It is necessary because the custom build machines are reused for tests.
    # See also https://docs.microsoft.com/en-us/azure/devops/pipelines/process/phases?view=azure-devops&tabs=yaml#workspace 

  steps:
  # The cache task is persisting the .m2 directory between builds, so that
  # we do not have to re-download all dependencies from maven central for 
  # each build. The hope is that downloading the cache is faster than
  # all dependencies individually.
  # In this configuration, we use a hash over all committed (not generated) .pom files 
  # as a key for the build cache (CACHE_KEY). If we have a cache miss on the hash
  # (usually because a pom file has changed), we'll fall back to a key without
  # the pom files (CACHE_FALLBACK_KEY).
  # Offical documentation of the Cache task: https://docs.microsoft.com/en-us/azure/devops/pipelines/caching/?view=azure-devops
  - task: Cache@2
    inputs:
      key: $(CACHE_KEY)
      restoreKeys: $(CACHE_FALLBACK_KEY)
      path: $(MAVEN_CACHE_FOLDER)
    continueOnError: true # continue the build even if the cache fails.
    displayName: Cache Maven local repo
54 55 56 57 58
  - script: |
      echo "##vso[task.setvariable variable=JAVA_HOME]$JAVA_HOME_11_X64"
      echo "##vso[task.setvariable variable=PATH]$JAVA_HOME_11_X64/bin;$PATH"
    displayName: "Set to jdk11"
    condition: eq('${{parameters.jdk}}', 'jdk11')
59 60 61 62 63 64 65 66 67 68 69 70
  # Compile
  - script: STAGE=compile ${{parameters.environment}} ./tools/azure_controller.sh compile
    displayName: Build

  # upload artifacts for next stage
  - task: PublishPipelineArtifact@1
    inputs:
      path: $(CACHE_FLINK_DIR)
      artifact: FlinkCompileCacheDir-${{parameters.stage_name}}

- job: test_${{parameters.stage_name}}
  dependsOn: compile_${{parameters.stage_name}}
71
  condition: and(succeeded(), not(eq(variables['MODE'], 'e2e')))
72
  pool: ${{parameters.test_pool_definition}}
73
  container: ${{parameters.container}}
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
  timeoutInMinutes: 240
  cancelTimeoutInMinutes: 1
  workspace:
    clean: all
  strategy:
    matrix:
      core:
        module: core
      python:
        module: python
      libraries:
        module: libraries
      blink_planner:
        module: blink_planner
      connectors:
        module: connectors
      kafka_gelly:
        module: kafka/gelly
      tests:
        module: tests
      legacy_scheduler_core:
        module: legacy_scheduler_core
      legacy_scheduler_tests:
        module: legacy_scheduler_tests
      misc:
        module: misc
  steps:

  # download artifacts
  - task: DownloadPipelineArtifact@2
    inputs:
      path: $(CACHE_FLINK_DIR)
      artifact: FlinkCompileCacheDir-${{parameters.stage_name}}

R
Robert Metzger 已提交
108 109 110 111 112 113 114 115 116
  # only for the python stage (which runs a full mvn install), download the cache
  - task: Cache@2
    condition: eq(variables['module'], 'python')
    inputs:
      key: $(CACHE_KEY)
      restoreKeys: $(CACHE_FALLBACK_KEY)
      path: $(MAVEN_CACHE_FOLDER)
    continueOnError: true # continue the build even if the cache fails.
    displayName: Cache Maven local repo
117 118 119 120 121
  - script: |
      echo "##vso[task.setvariable variable=JAVA_HOME]$JAVA_HOME_11_X64"
      echo "##vso[task.setvariable variable=PATH]$JAVA_HOME_11_X64/bin;$PATH"
    displayName: "Set to jdk11"
    condition: eq('${{parameters.jdk}}', 'jdk11')  
122 123 124 125 126 127 128 129 130 131
  # Test
  - script: STAGE=test ${{parameters.environment}} ./tools/azure_controller.sh $(module)
    displayName: Test - $(module)

  - task: PublishTestResults@2
    inputs:
      testResultsFormat: 'JUnit'


- job: e2e_${{parameters.stage_name}}
132 133 134
  # uncomment below condition to run the e2e tests only on request.
  #condition: or(eq(variables['MODE'], 'e2e'), eq(${{parameters.run_end_to_end}}, 'true'))
  # We are running this in a separate pool
135
  pool: ${{parameters.e2e_pool_definition}}
136
  timeoutInMinutes: 200
137 138 139 140 141 142 143 144 145 146
  cancelTimeoutInMinutes: 1
  workspace:
    clean: all
  steps:
    - task: Cache@2
      inputs:
        key: $(CACHE_KEY)
        restoreKeys: $(CACHE_FALLBACK_KEY)
        path: $(MAVEN_CACHE_FOLDER)
      displayName: Cache Maven local repo
147 148
      continueOnError: true
    - script: |
149 150
        echo "##vso[task.setvariable variable=JAVA_HOME]$JAVA_HOME_11_X64"
        echo "##vso[task.setvariable variable=PATH]$JAVA_HOME_11_X64/bin;$PATH"
151
      displayName: "Set to jdk11"
152
      condition: eq('${{parameters.jdk}}', 'jdk11')
153
    - script: ./tools/travis/setup_maven.sh
154 155 156 157 158
      displayName: Setup Maven 3.2.5
    - script: ./tools/azure-pipelines/setup_docker.sh
      displayName: Setup Docker
    - script: ./tools/azure-pipelines/free_disk_space.sh
      displayName: Free up disk space
159
    - script: M2_HOME=/home/vsts/maven_cache/apache-maven-3.2.5/ PATH=/home/vsts/maven_cache/apache-maven-3.2.5/bin:$PATH ${{parameters.environment}} STAGE=compile ./tools/azure_controller.sh compile
160
      displayName: Build Flink
161
    # TODO remove pre-commit tests script by adding the tests to the nightly script
162 163
#    - script: FLINK_DIR=build-target ./flink-end-to-end-tests/run-pre-commit-tests.sh
#      displayName: Test - precommit 
164
    - script: FLINK_DIR=`pwd`/build-target flink-end-to-end-tests/run-nightly-tests.sh
165
      displayName: Run e2e tests
166