# Copyright the Hyperledger Fabric contributors. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0

name: $(SourceBranchName)-$(Date:yyyyMMdd)$(Rev:.rrr)
trigger: none
pr:
- release-1.4

variables:
  GOPATH: $(Agent.BuildDirectory)/go
  PATH: $(Agent.BuildDirectory)/go/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin
  GOVER: 1.14.12

jobs:
  - job: VerifyBuild
    pool:
      vmImage: ubuntu-18.04
    steps:
      - template: install_deps.yml
      - checkout: self
        path: 'go/src/github.com/hyperledger/fabric'
        displayName: Checkout Fabric Code
      - script: make basic-checks native
        displayName: Run Basic Checks
      - script: ./ci/scripts/evaluate_commits.sh
        name: SetJobTriggers

  - job: DocBuild
    condition: eq(dependencies.VerifyBuild.outputs['SetJobTriggers.buildDoc'], 'true')
    dependsOn: VerifyBuild
    pool:
      vmImage: ubuntu-18.04
    container:
      image: n42org/tox:3.4.0
    steps:
      - checkout: self
        path: 'go/src/github.com/hyperledger/fabric'
        displayName: Checkout Fabric Code
      - script: tox -edocs
        displayName: Build Documentation
      - publish: 'docs/_build/html'
        displayName: Publish Documentation Artifacts

  - job: UnitTests
    condition: eq(dependencies.VerifyBuild.outputs['SetJobTriggers.runTests'], 'true')
    dependsOn: VerifyBuild
    pool:
      vmImage: ubuntu-18.04
    steps:
      - template: install_deps.yml
      - checkout: self
        path: 'go/src/github.com/hyperledger/fabric'
        displayName: Checkout Fabric Code
      - script: ./ci/scripts/setup_hsm.sh
        displayName: Install SoftHSM
      - script: make unit-test
        displayName: Run Unit Tests

  - job: IntegrationTests
    condition: eq(dependencies.VerifyBuild.outputs['SetJobTriggers.runTests'], 'true')
    dependsOn: VerifyBuild
    pool:
      vmImage: ubuntu-18.04
    strategy:
      parallel: 5
    timeoutInMinutes: 90
    steps:
      - template: install_deps.yml
      - checkout: self
        path: 'go/src/github.com/hyperledger/fabric'
        displayName: Checkout Fabric Code
      - script: make integration-test
        displayName: Run Integration Tests

