parameters:
  name: ''
  vmImage: ''

jobs:
- job: ${{ parameters.name }}
  pool:
    vmImage: ${{ parameters.vmImage }}
  strategy:
    matrix:
      node8:
        nodeVersion: 8.x
      node10:
        nodeVersion: 10.x
      node11:
        nodeVersion: 11.x
  steps:
  - task: NodeTool@0
    displayName: Use Node
    inputs:
      versionSpec: $(nodeVersion)
      checkLatest: true

  - ${{ if eq(parameters.name, 'Windows') }}:
    - task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@2
      displayName: 'Run CredScan'
      inputs:
        verboseOutput: true
        debugMode: false
      continueOnError: true

  - task: Npm@1
    displayName: npm install
    inputs:
      command: custom
      customCommand: install --unsafe-perms
      verbose: false

  - ${{ if eq(parameters.name, 'Linux') }}:
    - script: |
        cd '$(Build.SourcesDirectory)'

        export npm_package_engines_vscode='^1.19.0'
        node ./node_modules/vscode/bin/install

  - task: Npm@1
    displayName: npm build
    inputs:
      command: custom
      customCommand: run build
      verbose: false

  - task: Npm@1
    displayName: npm test
    inputs:
      command: custom
      verbose: false
      customCommand: test

  - task: Npm@1
    displayName: npm tslint
    inputs:
      command: custom
      verbose: false
      customCommand: 'run tslint'

  - task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0
    displayName: 'Component Detection'
    inputs:
      ignoreDirectories: 'testdata'

  - task: Npm@1
    displayName: npm package
    inputs:
      command: custom
      verbose: false
      customCommand: 'run package -- --packagePath="$(Build.BinariesDirectory)/vscode-node-debug2.vsix"'

  - task: ArchiveFiles@2
    displayName: Archive files
    inputs:
      includeRootFolder: false

  - task: PublishBuildArtifacts@1
    displayName: 'Publish Artifacts: drop'
    inputs:
      PathtoPublish: '$(Build.ArtifactStagingDirectory)'
      ArtifactName: drop
      publishLocation: Container

  - ${{ if eq(parameters.name, 'Windows') }}:
    - task: securedevelopmentteam.vss-secure-development-tools.build-task-uploadtotsa.TSAUpload@1
      displayName: 'TSA upload to Codebase: vscode-node-debug2_master Version: TsaV2'
      inputs:
        tsaVersion: TsaV2
        codebase: NewOrUpdate
        codeBaseName: 'vscode-node-debug2_master'
        notificationAlias: 'webdiag-extensions@microsoft.com'
        instanceUrlForTsaV2: DEVDIV
        projectNameDEVDIV: DevDiv
        areaPath: 'DevDiv\TypeScript\HTML Experiences\Diagnostics\Debugger'
        uploadAPIScan: false
        uploadBinSkim: false
        uploadFortifySCA: false
        uploadFxCop: false
        uploadModernCop: false
        uploadPoliCheck: false
        uploadPREfast: false
        uploadRoslyn: false
        uploadTSLint: false

  - ${{ if eq(parameters.name, 'Windows') }}:
    - task: securedevelopmentteam.vss-secure-development-tools.build-task-publishsecurityanalysislogs.PublishSecurityAnalysisLogs@2
      displayName: 'Publish Security Analysis Logs'
