<commit_before>trigger:
  branches:
    include:
    - master
    - refs/tags/*

jobs:
  - job: test_typescript
    pool:
      vmImage: ubuntu-latest
    steps:
      - task: NodeTool@0
        inputs:
          versionSpec: 14.x
        displayName: Install Node.js

      - script: npm install
        displayName: Install dependencies

      - script: npm run lint
        displayName: Run linting

      - script: npm run test:cover
        displayName: Run tests

      - script: npm run build
        displayName: Build package

      - script: npm run docs
        displayName: Build docs

      - script: bash <(curl -s https://codecov.io/bash) -cF ts
        condition: succeeded()
        displayName: Upload coverage

  - job: test_python
    pool:
      vmImage: ubuntu-latest
    steps:
      - task: UsePythonVersion@0
        inputs:
          versionSpec: 3.8
        displayName: Install Python

      - script: make -C py setup
        displayName: Install dependencies

      - script: make -C py lint
        displayName: Run linting

      - script: make -C py test
        displayName: Run tests

      - script: make -C py build
        displayName: Build package

      - script: make -C py docs
        displayName: Build docs

      - script: bash <(curl -s https://codecov.io/bash) -cF py
        condition: succeeded()
        displayName: Upload coverage

  - job: test_r
    pool:
      vmImage: ubuntu-20.04
    container: rstudio/r-base:4.0-focal
    variables:
      CRAN: 'https://demo.rstudiopm.com/all/__linux__/focal/latest'
      R_LIBS_USER: '$(Agent.BuildDirectory)/R/library'
      TZ: UTC
      CI: true
    steps:
      # From https://stackoverflow.com/a/57374105
      - script: |
          echo 'options(repos = "$(CRAN)")' > ~/.Rprofile
          echo ".libPaths(c('$R_LIBS_USER', .libPaths()))" >> ~/.Rprofile
          mkdir -p $(R_LIBS_USER)
        displayName: Setup R library directory

      - script: make -C r setup
        displayName: Install dependencies

      - script: make -C r lint
        displayName: Run linting

# Skip tests until able to fix https://github.com/stencila/schema/issues/229
#      - script: make -C r test
#        displayName: Run tests

      - script: make -C r build
        displayName: Build package

      - script: make -C r docs
        displayName: Build docs

#      - script: cd r && Rscript -e 'covr::codecov()'
#        condition: succeeded()
#        displayName: Upload coverage

  - job: deploy_typescript
    dependsOn: [test_typescript, test_python, test_r]
    condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
    pool:
      vmImage: ubuntu-latest
    steps:
      - task: NodeTool@0
        inputs:
          versionSpec: 14.x
        displayName: Install Node.js

      - script: npm run build
        displayName: Build package

      - script: npm run docs
        displayName: Build docs

      # Deploy a new version of NPM package and create a Github release
      # This creates a new version tag, which will then trigger the
      # following deploy jobs for other language packages.
      - script: npx semantic-release
        displayName: Release package

      - script: bash ci.sh deploy_typescript_docs_to_pages
        displayName: Release docs

  - job: deploy_python<commit_msg>ci(Typescript): Install deps<commit_after>trigger:
  branches:
    include:
    - master
    - refs/tags/*

jobs:
  - job: test_typescript
    pool:
      vmImage: ubuntu-latest
    steps:
      - task: NodeTool@0
        inputs:
          versionSpec: 14.x
        displayName: Install Node.js

      - script: npm install
        displayName: Install dependencies

      - script: npm run lint
        displayName: Run linting

      - script: npm run test:cover
        displayName: Run tests

      - script: npm run build
        displayName: Build package

      - script: npm run docs
        displayName: Build docs

      - script: bash <(curl -s https://codecov.io/bash) -cF ts
        condition: succeeded()
        displayName: Upload coverage

  - job: test_python
    pool:
      vmImage: ubuntu-latest
    steps:
      - task: UsePythonVersion@0
        inputs:
          versionSpec: 3.8
        displayName: Install Python

      - script: make -C py setup
        displayName: Install dependencies

      - script: make -C py lint
        displayName: Run linting

      - script: make -C py test
        displayName: Run tests

      - script: make -C py build
        displayName: Build package

      - script: make -C py docs
        displayName: Build docs

      - script: bash <(curl -s https://codecov.io/bash) -cF py
        condition: succeeded()
        displayName: Upload coverage

  - job: test_r
    pool:
      vmImage: ubuntu-20.04
    container: rstudio/r-base:4.0-focal
    variables:
      CRAN: 'https://demo.rstudiopm.com/all/__linux__/focal/latest'
      R_LIBS_USER: '$(Agent.BuildDirectory)/R/library'
      TZ: UTC
      CI: true
    steps:
      # From https://stackoverflow.com/a/57374105
      - script: |
          echo 'options(repos = "$(CRAN)")' > ~/.Rprofile
          echo ".libPaths(c('$R_LIBS_USER', .libPaths()))" >> ~/.Rprofile
          mkdir -p $(R_LIBS_USER)
        displayName: Setup R library directory

      - script: make -C r setup
        displayName: Install dependencies

      - script: make -C r lint
        displayName: Run linting

# Skip tests until able to fix https://github.com/stencila/schema/issues/229
#      - script: make -C r test
#        displayName: Run tests

      - script: make -C r build
        displayName: Build package

      - script: make -C r docs
        displayName: Build docs

#      - script: cd r && Rscript -e 'covr::codecov()'
#        condition: succeeded()
#        displayName: Upload coverage

  - job: deploy_typescript
    dependsOn: [test_typescript, test_python, test_r]
    condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
    pool:
      vmImage: ubuntu-latest
    steps:
      - task: NodeTool@0
        inputs:
          versionSpec: 14.x
        displayName: Install Node.js

      - script: npm install
        displayName: Install dependencies

      - script: npm run build
        displayName: Build package

      - script: npm run docs
        displayName: Build docs

      # Deploy a new version of NPM package and create a Github release
      # This creates a new version tag, which will then trigger the
      # following deploy jobs for other language packages.
      - script: npx semantic-release
        displayName: Release package

      - script: bash ci.sh deploy_typescript_docs_to_pages
        displayName: Release docs

  - job: deploy_python
{'fraction_non_alphanumeric': 0.0893491124260355, 'fraction_numerical': 0.007692307692307693, 'mean_word_length': 2.0372866127583107, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '765119', 'n_tokens_mistral': 2100, 'n_tokens_neox': 1941, 'n_words': 621}