aboutsummaryrefslogtreecommitdiffstats
path: root/azure-pipelines.yml
blob: c22bac089b0160d5dc00630b6f2c94c2a31969f6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# https://aka.ms/yaml

variables:
  PIPENV_HIDE_EMOJIS: 1
  PIPENV_IGNORE_VIRTUALENVS: 1
  PIPENV_NOSPIN: 1

jobs:
  - job: test
    displayName: 'Lint & Test'
    pool:
      vmImage: ubuntu-16.04

    variables:
      PIP_CACHE_DIR: ".cache/pip"

    steps:
      - task: UsePythonVersion@0
        displayName: 'Set Python version'
        inputs:
          versionSpec: '3.7.x'
          addToPath: true

      - script: pip install pipenv
        displayName: 'Install pipenv'

      - script: pipenv install --dev --deploy --system
        displayName: 'Install project using pipenv'

      - script: python -m flake8
        displayName: 'Run linter'

      - script: BOT_API_KEY=foo BOT_TOKEN=bar WOLFRAM_API_KEY=baz python -m pytest --junitxml=junit.xml --cov=bot --cov-branch --cov-report=term --cov-report=xml tests
        displayName: Run tests

      - task: PublishCodeCoverageResults@1
        displayName: 'Publish Coverage Results'
        condition: succeededOrFailed()
        inputs:
          codeCoverageTool: Cobertura
          summaryFileLocation: coverage.xml

      - task: PublishTestResults@2
        displayName: 'Publish Test Results'
        condition: succeededOrFailed()
        inputs:
          testResultsFiles: junit.xml
          testRunTitle: 'Bot Test results'

  - job: build
    displayName: 'Build & Push Container'
    dependsOn: 'test'
    condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'), eq(variables['Build.SourceBranch'], 'refs/heads/master'))

    steps:
      - task: Docker@2
        displayName: 'Build & Push Container'
        inputs:
          containerRegistry: 'DockerHub'
          repository: 'pythondiscord/bot'
          command: 'buildAndPush'
          Dockerfile: 'Dockerfile'
          buildContext: '.'
          tags: 'latest'