name: $(Date:yyyyMMdd)$(Rev:.r)

trigger:
  branches:
    include:
      - main
pr: none

resources:
  repositories:
    - repository: templates
      type: github
      name: microsoft/vscode-engineering
      ref: main
      endpoint: Monaco

parameters:
  - name: publishPackage
    displayName: 🚀 Publish test-electron
    type: boolean
    default: false

extends:
  template: azure-pipelines/npm-package/pipeline.yml@templates
  parameters:
    npmPackages:
      - name: test-electron
        ghCreateTag: false
        buildSteps:
          - script: yarn --frozen-lockfile
            displayName: Install dependencies

        testPlatforms:
          - name: Linux
            nodeVersions:
              - 16.x

        testSteps:
          - script: yarn --frozen-lockfile
            displayName: Install dependencies

          - script: yarn --cwd=sample --frozen-lockfile
            displayName: Install dependencies (fs-provider)

          - bash: |
              /usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
              echo ">>> Started xvfb"
            displayName: Start xvfb
            condition: eq(variables['Agent.OS'], 'Linux')

          - script: yarn --cwd=sample test
            displayName: Test package
            env:
              DISPLAY: ':99.0'

        publishPackage: ${{ parameters.publishPackage }}
