2020-05-28 17:57:48 +01:00
|
|
|
trigger:
|
2020-05-28 18:15:18 +01:00
|
|
|
- master
|
2020-05-28 17:57:48 +01:00
|
|
|
|
|
|
|
resources:
|
2020-05-28 18:15:18 +01:00
|
|
|
- repo: self
|
2020-05-28 17:57:48 +01:00
|
|
|
|
|
|
|
variables:
|
2020-05-28 18:15:18 +01:00
|
|
|
POSTGRES_DB: passbook
|
|
|
|
POSTGRES_USER: passbook
|
|
|
|
POSTGRES_PASSWORD: "EK-5jnKfjrGRm<77"
|
2020-05-28 17:57:48 +01:00
|
|
|
|
|
|
|
stages:
|
2020-05-28 18:15:18 +01:00
|
|
|
- stage: Lint
|
|
|
|
jobs:
|
|
|
|
- job: pylint
|
|
|
|
pool:
|
|
|
|
vmImage: 'ubuntu-latest'
|
|
|
|
steps:
|
|
|
|
- task: UsePythonVersion@0
|
|
|
|
inputs:
|
|
|
|
versionSpec: '3.8'
|
|
|
|
- task: CmdLine@2
|
|
|
|
inputs:
|
|
|
|
script: |
|
|
|
|
sudo pip install -U wheel pipenv
|
|
|
|
pipenv install --dev
|
|
|
|
- task: CmdLine@2
|
|
|
|
inputs:
|
|
|
|
script: pipenv run pylint passbook
|
|
|
|
- job: black
|
|
|
|
pool:
|
|
|
|
vmImage: 'ubuntu-latest'
|
|
|
|
steps:
|
|
|
|
- task: UsePythonVersion@0
|
|
|
|
inputs:
|
|
|
|
versionSpec: '3.8'
|
|
|
|
- task: CmdLine@2
|
|
|
|
inputs:
|
|
|
|
script: |
|
|
|
|
sudo pip install -U wheel pipenv
|
|
|
|
pipenv install --dev
|
|
|
|
- task: CmdLine@2
|
|
|
|
inputs:
|
|
|
|
script: pipenv run black --check passbook
|
|
|
|
- job: prospector
|
|
|
|
pool:
|
|
|
|
vmImage: 'ubuntu-latest'
|
|
|
|
steps:
|
|
|
|
- task: UsePythonVersion@0
|
|
|
|
inputs:
|
|
|
|
versionSpec: '3.8'
|
|
|
|
- task: CmdLine@2
|
|
|
|
inputs:
|
|
|
|
script: |
|
|
|
|
sudo pip install -U wheel pipenv
|
|
|
|
pipenv install --dev
|
|
|
|
pipenv install --dev prospector --skip-lock
|
|
|
|
- task: CmdLine@2
|
|
|
|
inputs:
|
2020-05-28 18:29:28 +01:00
|
|
|
script: pipenv run prospector passbook
|
2020-05-28 18:15:18 +01:00
|
|
|
- job: bandit
|
|
|
|
pool:
|
|
|
|
vmImage: 'ubuntu-latest'
|
|
|
|
steps:
|
|
|
|
- task: UsePythonVersion@0
|
|
|
|
inputs:
|
|
|
|
versionSpec: '3.8'
|
|
|
|
- task: CmdLine@2
|
|
|
|
inputs:
|
|
|
|
script: |
|
|
|
|
sudo pip install -U wheel pipenv
|
|
|
|
pipenv install --dev
|
|
|
|
- task: CmdLine@2
|
|
|
|
inputs:
|
|
|
|
script: pipenv run bandit -r passbook
|
|
|
|
- job: pyright
|
|
|
|
pool:
|
|
|
|
vmImage: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- task: UseNode@1
|
2020-07-03 08:39:23 +01:00
|
|
|
inputs:
|
|
|
|
version: '12.x'
|
2020-05-28 18:15:18 +01:00
|
|
|
- task: UsePythonVersion@0
|
|
|
|
inputs:
|
|
|
|
versionSpec: '3.8'
|
|
|
|
- task: CmdLine@2
|
|
|
|
inputs:
|
|
|
|
script: npm install -g pyright
|
|
|
|
- task: CmdLine@2
|
|
|
|
inputs:
|
|
|
|
script: |
|
|
|
|
sudo pip install -U wheel pipenv
|
|
|
|
pipenv install --dev
|
|
|
|
- task: CmdLine@2
|
|
|
|
inputs:
|
|
|
|
script: pipenv run pyright
|
2020-05-28 18:29:28 +01:00
|
|
|
- stage: Test
|
|
|
|
jobs:
|
|
|
|
- job: migrations
|
|
|
|
pool:
|
|
|
|
vmImage: 'ubuntu-latest'
|
|
|
|
steps:
|
|
|
|
- task: UsePythonVersion@0
|
|
|
|
inputs:
|
|
|
|
versionSpec: '3.8'
|
|
|
|
- task: DockerCompose@0
|
|
|
|
displayName: Run services
|
|
|
|
inputs:
|
|
|
|
dockerComposeFile: 'scripts/docker-compose.yml'
|
|
|
|
action: 'Run services'
|
|
|
|
buildImages: false
|
|
|
|
- task: CmdLine@2
|
|
|
|
inputs:
|
|
|
|
script: |
|
|
|
|
sudo pip install -U wheel pipenv
|
|
|
|
pipenv install --dev
|
|
|
|
- task: CmdLine@2
|
|
|
|
inputs:
|
|
|
|
script: pipenv run ./manage.py migrate
|
2020-07-10 16:25:19 +01:00
|
|
|
- job: coverage_unittest
|
2020-07-10 16:12:37 +01:00
|
|
|
pool:
|
|
|
|
vmImage: 'ubuntu-latest'
|
|
|
|
steps:
|
|
|
|
- task: UsePythonVersion@0
|
|
|
|
inputs:
|
|
|
|
versionSpec: '3.8'
|
|
|
|
- task: DockerCompose@0
|
|
|
|
displayName: Run services
|
|
|
|
inputs:
|
|
|
|
dockerComposeFile: 'scripts/docker-compose.yml'
|
|
|
|
action: 'Run services'
|
|
|
|
buildImages: false
|
|
|
|
- task: CmdLine@2
|
|
|
|
inputs:
|
|
|
|
script: |
|
|
|
|
sudo pip install -U wheel pipenv
|
|
|
|
pipenv install --dev
|
|
|
|
- task: CmdLine@2
|
|
|
|
displayName: Run full test suite
|
|
|
|
inputs:
|
|
|
|
script: |
|
|
|
|
pipenv run coverage run ./manage.py test --failfast passbook
|
|
|
|
mkdir output-unittest
|
|
|
|
mv unittest.xml output-unittest/unittest.xml
|
|
|
|
mv .coverage output-unittest/coverage
|
|
|
|
- task: PublishPipelineArtifact@1
|
|
|
|
inputs:
|
|
|
|
targetPath: 'coverage-unittest'
|
|
|
|
artifact: 'output-unittest/'
|
|
|
|
publishLocation: 'pipeline'
|
2020-07-10 16:25:19 +01:00
|
|
|
- job: coverage_e2e
|
2020-05-28 18:29:28 +01:00
|
|
|
pool:
|
|
|
|
vmImage: 'ubuntu-latest'
|
|
|
|
steps:
|
|
|
|
- task: UsePythonVersion@0
|
|
|
|
inputs:
|
|
|
|
versionSpec: '3.8'
|
|
|
|
- task: DockerCompose@0
|
|
|
|
displayName: Run services
|
|
|
|
inputs:
|
|
|
|
dockerComposeFile: 'scripts/docker-compose.yml'
|
|
|
|
action: 'Run services'
|
|
|
|
buildImages: false
|
|
|
|
- task: CmdLine@2
|
|
|
|
inputs:
|
|
|
|
script: |
|
|
|
|
sudo pip install -U wheel pipenv
|
|
|
|
pipenv install --dev
|
2020-07-03 08:54:25 +01:00
|
|
|
- task: DockerCompose@0
|
|
|
|
displayName: Run ChromeDriver
|
2020-05-28 18:29:28 +01:00
|
|
|
inputs:
|
2020-07-10 14:37:10 +01:00
|
|
|
dockerComposeFile: 'e2e/ci.docker-compose.yml'
|
2020-07-03 08:54:25 +01:00
|
|
|
action: 'Run a specific service'
|
|
|
|
serviceName: 'chrome'
|
2020-07-03 08:25:13 +01:00
|
|
|
- task: CmdLine@2
|
2020-07-03 08:54:25 +01:00
|
|
|
displayName: Build static files for e2e
|
2020-07-03 08:25:13 +01:00
|
|
|
inputs:
|
|
|
|
script: |
|
|
|
|
cd passbook/static/static
|
|
|
|
yarn
|
|
|
|
- task: CmdLine@2
|
2020-07-03 08:54:25 +01:00
|
|
|
displayName: Run full test suite
|
2020-07-03 08:25:13 +01:00
|
|
|
inputs:
|
2020-07-10 16:12:37 +01:00
|
|
|
script: |
|
|
|
|
pipenv run coverage run ./manage.py test --failfast e2e
|
|
|
|
mkdir output-e2e
|
|
|
|
mv unittest.xml output-e2e/unittest.xml
|
|
|
|
mv .coverage output-e2e/coverage
|
|
|
|
- task: PublishPipelineArtifact@1
|
2020-07-03 08:54:25 +01:00
|
|
|
condition: failed()
|
|
|
|
displayName: Upload screenshots if selenium tests fail
|
2020-07-03 08:25:13 +01:00
|
|
|
inputs:
|
2020-07-10 16:12:37 +01:00
|
|
|
targetPath: 'selenium_screenshots/'
|
|
|
|
artifact: 'selenium screenshots'
|
|
|
|
publishLocation: 'pipeline'
|
|
|
|
- task: PublishPipelineArtifact@1
|
|
|
|
inputs:
|
|
|
|
targetPath: 'coverage-e2e'
|
|
|
|
artifact: 'output-e2e/'
|
|
|
|
publishLocation: 'pipeline'
|
2020-07-10 16:25:19 +01:00
|
|
|
- stage: test_combine
|
2020-07-10 16:12:37 +01:00
|
|
|
jobs:
|
|
|
|
- job: test_coverage_combine
|
|
|
|
pool:
|
|
|
|
vmImage: 'ubuntu-latest'
|
|
|
|
steps:
|
|
|
|
- task: DownloadPipelineArtifact@2
|
|
|
|
inputs:
|
|
|
|
buildType: 'current'
|
|
|
|
artifactName: 'coverage-e2e'
|
|
|
|
- task: DownloadPipelineArtifact@2
|
|
|
|
inputs:
|
|
|
|
buildType: 'current'
|
|
|
|
artifactName: 'coverage-unittest'
|
|
|
|
- task: UsePythonVersion@0
|
|
|
|
inputs:
|
|
|
|
versionSpec: '3.8'
|
2020-05-28 18:29:28 +01:00
|
|
|
- task: CmdLine@2
|
|
|
|
inputs:
|
2020-07-03 08:54:25 +01:00
|
|
|
script: |
|
2020-07-10 16:12:37 +01:00
|
|
|
sudo pip install -U wheel pipenv
|
|
|
|
pipenv install --dev
|
|
|
|
pipenv run combine coverage-e2e/coverage coverage-unittest/coverage
|
2020-07-03 08:54:25 +01:00
|
|
|
pipenv run coverage xml
|
|
|
|
pipenv run coverage html
|
|
|
|
- task: PublishCodeCoverageResults@1
|
|
|
|
inputs:
|
|
|
|
codeCoverageTool: Cobertura
|
|
|
|
summaryFileLocation: 'coverage.xml'
|
|
|
|
- task: PublishTestResults@2
|
|
|
|
condition: succeededOrFailed()
|
|
|
|
inputs:
|
|
|
|
testRunTitle: 'Publish test results for Python $(python.version)'
|
2020-07-10 16:12:37 +01:00
|
|
|
testResultsFiles: 'coverage-e2e/unittest.xml:coverage-unittest/unittest.xml'
|
2020-05-28 18:29:28 +01:00
|
|
|
- task: CmdLine@2
|
2020-05-29 08:18:17 +01:00
|
|
|
env:
|
|
|
|
CODECOV_TOKEN: $(CODECOV_TOKEN)
|
2020-05-28 18:29:28 +01:00
|
|
|
inputs:
|
|
|
|
script: bash <(curl -s https://codecov.io/bash)
|
2020-05-28 18:44:25 +01:00
|
|
|
- stage: Build
|
|
|
|
jobs:
|
2020-05-28 18:46:10 +01:00
|
|
|
- job: build_server
|
2020-05-28 18:44:25 +01:00
|
|
|
pool:
|
|
|
|
vmImage: 'ubuntu-latest'
|
2020-05-28 20:00:30 +01:00
|
|
|
steps:
|
|
|
|
- task: Docker@2
|
|
|
|
inputs:
|
|
|
|
containerRegistry: 'dockerhub'
|
|
|
|
repository: 'beryju/passbook'
|
|
|
|
command: 'buildAndPush'
|
|
|
|
Dockerfile: 'Dockerfile'
|
2020-07-03 08:25:13 +01:00
|
|
|
tags: 'gh-$(Build.SourceBranchName)'
|
2020-05-28 18:46:10 +01:00
|
|
|
- job: build_gatekeeper
|
2020-05-28 18:44:25 +01:00
|
|
|
pool:
|
|
|
|
vmImage: 'ubuntu-latest'
|
2020-05-28 20:00:30 +01:00
|
|
|
steps:
|
|
|
|
- task: Docker@2
|
|
|
|
inputs:
|
|
|
|
containerRegistry: 'dockerhub'
|
|
|
|
repository: 'beryju/passbook-gatekeeper'
|
|
|
|
command: 'buildAndPush'
|
2020-07-07 17:48:24 +01:00
|
|
|
Dockerfile: 'gatekeeper/Dockerfile'
|
2020-07-07 17:23:15 +01:00
|
|
|
buildContext: 'gatekeeper/'
|
2020-07-03 08:25:13 +01:00
|
|
|
tags: 'gh-$(Build.SourceBranchName)'
|
2020-05-28 18:46:10 +01:00
|
|
|
- job: build_static
|
2020-05-28 18:44:25 +01:00
|
|
|
pool:
|
|
|
|
vmImage: 'ubuntu-latest'
|
2020-05-28 20:00:30 +01:00
|
|
|
steps:
|
|
|
|
- task: DockerCompose@0
|
|
|
|
displayName: Run services
|
|
|
|
inputs:
|
|
|
|
dockerComposeFile: 'scripts/docker-compose.yml'
|
|
|
|
action: 'Run services'
|
|
|
|
buildImages: false
|
|
|
|
- task: Docker@2
|
|
|
|
inputs:
|
|
|
|
containerRegistry: 'dockerhub'
|
|
|
|
repository: 'beryju/passbook-static'
|
2020-05-29 08:43:00 +01:00
|
|
|
command: 'build'
|
2020-05-28 20:19:06 +01:00
|
|
|
Dockerfile: 'static.Dockerfile'
|
2020-07-03 08:25:13 +01:00
|
|
|
tags: 'gh-$(Build.SourceBranchName)'
|
2020-05-29 09:04:23 +01:00
|
|
|
arguments: "--network=beryjupassbook_default"
|
2020-05-29 08:43:00 +01:00
|
|
|
- task: Docker@2
|
|
|
|
inputs:
|
|
|
|
containerRegistry: 'dockerhub'
|
|
|
|
repository: 'beryju/passbook-static'
|
|
|
|
command: 'push'
|
2020-07-03 08:25:13 +01:00
|
|
|
tags: 'gh-$(Build.SourceBranchName)'
|