trigger:
  branches:
    include:
      - master
      - features/*
      - releases/*
      - renovate/*
  tags:
    include:
      - '*'

stages:
  - stage: checks
    displayName: Static checks
    jobs:
      - template: .ci/templates/docker-jobs.yml
        parameters:
          jobs:
            - job: lint
              displayName: Run ESLint
              steps:
                - script: yarn install && yarn run lint
            - job: types
              displayName: Run Typing Checks
              steps:
                - script: yarn install && yarn run types
            - job: audit
              displayName: Run Yarn Audit
              continueOnError: true
              steps:
                - script: yarn install && yarn audit
                - script: cd docs && yarn install && yarn audit
  - stage: tests
    displayName: Run tests
    jobs:
      - template: .ci/templates/docker-jobs.yml
        parameters:
          jobs:
            - job: test
              displayName: Run tests suite
              strategy:
                matrix:
                  node10:
                    container: 'node:10'
                  node12:
                    container: 'node:12'
                  node13:
                    container: 'node:13'
              steps:
                - script: >
                    curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
                    && chmod +x ./cc-test-reporter
                - script: yarn install
                - script: >
                    ./cc-test-reporter before-build
                    && yarn run test --coverage
                    && ./cc-test-reporter after-build --exit-code $?
                  env:
                    CC_TEST_REPORTER_ID: $(codeclimate.token)
                    GIT_BRANCH: $(Build.SourceBranchName)
                    GIT_COMMIT_SHA: $(Build.SourceVersion)
  - stage: build
    displayName: Build Project
    jobs:
      - template: .ci/templates/docker-jobs.yml
        parameters:
          jobs:
            - job: build
              displayName: Build
              steps:
              - script: yarn install && yarn run build
              - task: PublishPipelineArtifact@0
                inputs:
                  targetPath: lib/
                  artifactName: babel-plugin-i18next-extract

