2020-05-28 16:57:48 +00:00
|
|
|
trigger:
|
2020-05-28 17:15:18 +00:00
|
|
|
- master
|
2020-05-28 16:57:48 +00:00
|
|
|
|
|
|
|
resources:
|
2020-05-28 17:15:18 +00:00
|
|
|
- repo: self
|
2020-05-28 16:57:48 +00:00
|
|
|
|
|
|
|
variables:
|
2020-05-28 17:15:18 +00:00
|
|
|
POSTGRES_DB: passbook
|
|
|
|
POSTGRES_USER: passbook
|
|
|
|
POSTGRES_PASSWORD: "EK-5jnKfjrGRm<77"
|
2020-09-21 15:55:57 +00:00
|
|
|
${{ if startsWith(variables['Build.SourceBranch'], 'refs/heads/') }}:
|
|
|
|
branchName: ${{ replace(variables['Build.SourceBranchName'], 'refs/heads/', '') }}
|
|
|
|
${{ if startsWith(variables['Build.SourceBranch'], 'refs/pull/') }}:
|
|
|
|
branchName: ${{ replace(variables['System.PullRequest.SourceBranch'], 'refs/heads/', '') }}
|
2020-05-28 16:57:48 +00:00
|
|
|
|
|
|
|
stages:
|
2020-05-28 17:15:18 +00:00
|
|
|
- stage: Lint
|
|
|
|
jobs:
|
|
|
|
- job: pylint
|
|
|
|
pool:
|
|
|
|
vmImage: 'ubuntu-latest'
|
|
|
|
steps:
|
|
|
|
- task: UsePythonVersion@0
|
|
|
|
inputs:
|
|
|
|
versionSpec: '3.8'
|
|
|
|
- task: CmdLine@2
|
|
|
|
inputs:
|
|
|
|
script: |
|
2020-11-15 00:05:20 +00:00
|
|
|
sudo apt install -y libxmlsec1-dev pkg-config
|
2020-05-28 17:15:18 +00:00
|
|
|
sudo pip install -U wheel pipenv
|
|
|
|
pipenv install --dev
|
|
|
|
- task: CmdLine@2
|
|
|
|
inputs:
|
2020-09-26 17:08:37 +00:00
|
|
|
script: pipenv run pylint passbook e2e lifecycle
|
2020-05-28 17:15:18 +00:00
|
|
|
- job: black
|
|
|
|
pool:
|
|
|
|
vmImage: 'ubuntu-latest'
|
|
|
|
steps:
|
|
|
|
- task: UsePythonVersion@0
|
|
|
|
inputs:
|
|
|
|
versionSpec: '3.8'
|
|
|
|
- task: CmdLine@2
|
|
|
|
inputs:
|
|
|
|
script: |
|
2020-11-15 00:05:20 +00:00
|
|
|
sudo apt install -y libxmlsec1-dev pkg-config
|
2020-05-28 17:15:18 +00:00
|
|
|
sudo pip install -U wheel pipenv
|
|
|
|
pipenv install --dev
|
|
|
|
- task: CmdLine@2
|
|
|
|
inputs:
|
2020-09-26 17:08:37 +00:00
|
|
|
script: pipenv run black --check passbook e2e lifecycle
|
2020-05-28 17:15:18 +00:00
|
|
|
- job: prospector
|
|
|
|
pool:
|
|
|
|
vmImage: 'ubuntu-latest'
|
|
|
|
steps:
|
|
|
|
- task: UsePythonVersion@0
|
|
|
|
inputs:
|
|
|
|
versionSpec: '3.8'
|
|
|
|
- task: CmdLine@2
|
|
|
|
inputs:
|
|
|
|
script: |
|
2020-11-15 00:05:20 +00:00
|
|
|
sudo apt install -y libxmlsec1-dev pkg-config
|
2020-05-28 17:15:18 +00:00
|
|
|
sudo pip install -U wheel pipenv
|
|
|
|
pipenv install --dev
|
|
|
|
pipenv install --dev prospector --skip-lock
|
|
|
|
- task: CmdLine@2
|
|
|
|
inputs:
|
2020-09-26 17:17:42 +00:00
|
|
|
script: pipenv run prospector
|
2020-05-28 17:15:18 +00:00
|
|
|
- job: bandit
|
|
|
|
pool:
|
|
|
|
vmImage: 'ubuntu-latest'
|
|
|
|
steps:
|
|
|
|
- task: UsePythonVersion@0
|
|
|
|
inputs:
|
|
|
|
versionSpec: '3.8'
|
|
|
|
- task: CmdLine@2
|
|
|
|
inputs:
|
|
|
|
script: |
|
2020-11-15 00:05:20 +00:00
|
|
|
sudo apt install -y libxmlsec1-dev pkg-config
|
2020-05-28 17:15:18 +00:00
|
|
|
sudo pip install -U wheel pipenv
|
|
|
|
pipenv install --dev
|
|
|
|
- task: CmdLine@2
|
|
|
|
inputs:
|
2020-09-26 17:08:37 +00:00
|
|
|
script: pipenv run bandit -r passbook e2e lifecycle
|
2020-05-28 17:15:18 +00:00
|
|
|
- job: pyright
|
|
|
|
pool:
|
|
|
|
vmImage: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- task: UseNode@1
|
2020-07-03 07:39:23 +00:00
|
|
|
inputs:
|
|
|
|
version: '12.x'
|
2020-05-28 17:15:18 +00:00
|
|
|
- task: UsePythonVersion@0
|
|
|
|
inputs:
|
|
|
|
versionSpec: '3.8'
|
|
|
|
- task: CmdLine@2
|
|
|
|
inputs:
|
2020-10-16 20:29:59 +00:00
|
|
|
script: npm install -g pyright@1.1.79
|
2020-05-28 17:15:18 +00:00
|
|
|
- task: CmdLine@2
|
|
|
|
inputs:
|
|
|
|
script: |
|
2020-11-15 00:05:20 +00:00
|
|
|
sudo apt install -y libxmlsec1-dev pkg-config
|
2020-05-28 17:15:18 +00:00
|
|
|
sudo pip install -U wheel pipenv
|
|
|
|
pipenv install --dev
|
|
|
|
- task: CmdLine@2
|
|
|
|
inputs:
|
2020-09-26 17:08:37 +00:00
|
|
|
script: pipenv run pyright e2e lifecycle
|
2020-05-28 17:29:28 +00: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:
|
2020-07-14 20:55:30 +00:00
|
|
|
dockerComposeFile: 'scripts/ci.docker-compose.yml'
|
2020-05-28 17:29:28 +00:00
|
|
|
action: 'Run services'
|
|
|
|
buildImages: false
|
|
|
|
- task: CmdLine@2
|
|
|
|
inputs:
|
|
|
|
script: |
|
2020-11-15 00:05:20 +00:00
|
|
|
sudo apt install -y libxmlsec1-dev pkg-config
|
2020-05-28 17:29:28 +00:00
|
|
|
sudo pip install -U wheel pipenv
|
|
|
|
pipenv install --dev
|
|
|
|
- task: CmdLine@2
|
|
|
|
inputs:
|
|
|
|
script: pipenv run ./manage.py migrate
|
2020-09-21 15:55:57 +00:00
|
|
|
- job: migrations_from_previous_release
|
|
|
|
pool:
|
|
|
|
vmImage: 'ubuntu-latest'
|
|
|
|
steps:
|
|
|
|
- task: UsePythonVersion@0
|
|
|
|
inputs:
|
|
|
|
versionSpec: '3.8'
|
|
|
|
- task: DockerCompose@0
|
|
|
|
displayName: Run services
|
|
|
|
inputs:
|
|
|
|
dockerComposeFile: 'scripts/ci.docker-compose.yml'
|
|
|
|
action: 'Run services'
|
|
|
|
buildImages: false
|
|
|
|
- task: CmdLine@2
|
|
|
|
displayName: Prepare Last tagged release
|
|
|
|
inputs:
|
|
|
|
script: |
|
|
|
|
git checkout $(git describe --abbrev=0 --match 'version/*')
|
2020-11-15 00:05:20 +00:00
|
|
|
sudo apt install -y libxmlsec1-dev pkg-config
|
2020-09-21 15:55:57 +00:00
|
|
|
sudo pip install -U wheel pipenv
|
|
|
|
pipenv install --dev
|
|
|
|
- task: CmdLine@2
|
|
|
|
displayName: Migrate to last tagged release
|
|
|
|
inputs:
|
|
|
|
script: pipenv run ./manage.py migrate
|
|
|
|
- task: CmdLine@2
|
|
|
|
displayName: Install current branch
|
|
|
|
inputs:
|
|
|
|
script: |
|
|
|
|
set -x
|
|
|
|
git checkout ${{ variables.branchName }}
|
|
|
|
pipenv sync --dev
|
|
|
|
- task: CmdLine@2
|
|
|
|
displayName: Migrate to current branch
|
|
|
|
inputs:
|
|
|
|
script: pipenv run ./manage.py migrate
|
2020-07-10 15:25:19 +00:00
|
|
|
- job: coverage_unittest
|
2020-07-10 15:12:37 +00:00
|
|
|
pool:
|
|
|
|
vmImage: 'ubuntu-latest'
|
|
|
|
steps:
|
|
|
|
- task: UsePythonVersion@0
|
|
|
|
inputs:
|
|
|
|
versionSpec: '3.8'
|
|
|
|
- task: DockerCompose@0
|
|
|
|
displayName: Run services
|
|
|
|
inputs:
|
2020-07-14 20:55:30 +00:00
|
|
|
dockerComposeFile: 'scripts/ci.docker-compose.yml'
|
2020-07-10 15:12:37 +00:00
|
|
|
action: 'Run services'
|
|
|
|
buildImages: false
|
2020-10-14 18:21:36 +00:00
|
|
|
- task: CmdLine@2
|
|
|
|
displayName: Install K3d and prepare
|
2020-10-14 18:28:24 +00:00
|
|
|
inputs:
|
2020-10-14 18:21:36 +00:00
|
|
|
script: |
|
|
|
|
wget -q -O - https://raw.githubusercontent.com/rancher/k3d/main/install.sh | bash
|
|
|
|
k3d cluster create
|
|
|
|
k3d kubeconfig write -o ~/.kube/config --overwrite
|
2020-07-10 15:12:37 +00:00
|
|
|
- task: CmdLine@2
|
|
|
|
inputs:
|
|
|
|
script: |
|
2020-11-15 00:05:20 +00:00
|
|
|
sudo apt install -y libxmlsec1-dev pkg-config
|
2020-07-10 15:12:37 +00:00
|
|
|
sudo pip install -U wheel pipenv
|
|
|
|
pipenv install --dev
|
|
|
|
- task: CmdLine@2
|
|
|
|
displayName: Run full test suite
|
|
|
|
inputs:
|
|
|
|
script: |
|
2020-10-19 12:55:25 +00:00
|
|
|
export PB_TEST_K8S=true
|
2020-09-14 15:37:06 +00:00
|
|
|
pipenv run coverage run ./manage.py test passbook -v 3
|
2020-09-26 12:55:50 +00:00
|
|
|
- task: CmdLine@2
|
|
|
|
inputs:
|
|
|
|
script: |
|
2020-07-10 15:12:37 +00:00
|
|
|
mkdir output-unittest
|
|
|
|
mv unittest.xml output-unittest/unittest.xml
|
|
|
|
mv .coverage output-unittest/coverage
|
|
|
|
- task: PublishPipelineArtifact@1
|
|
|
|
inputs:
|
2020-07-10 15:43:16 +00:00
|
|
|
targetPath: 'output-unittest/'
|
|
|
|
artifact: 'coverage-unittest'
|
2020-07-10 15:12:37 +00:00
|
|
|
publishLocation: 'pipeline'
|
2020-07-10 15:25:19 +00:00
|
|
|
- job: coverage_e2e
|
2020-05-28 17:29:28 +00:00
|
|
|
pool:
|
2020-09-13 17:49:13 +00:00
|
|
|
name: coventry
|
2020-05-28 17:29:28 +00:00
|
|
|
steps:
|
|
|
|
- task: UsePythonVersion@0
|
|
|
|
inputs:
|
|
|
|
versionSpec: '3.8'
|
|
|
|
- task: DockerCompose@0
|
|
|
|
displayName: Run services
|
|
|
|
inputs:
|
2020-07-14 20:55:30 +00:00
|
|
|
dockerComposeFile: 'scripts/ci.docker-compose.yml'
|
2020-05-28 17:29:28 +00:00
|
|
|
action: 'Run services'
|
|
|
|
buildImages: false
|
2020-10-14 18:21:36 +00:00
|
|
|
- task: CmdLine@2
|
|
|
|
displayName: Install K3d and prepare
|
2020-10-14 18:28:24 +00:00
|
|
|
inputs:
|
2020-10-14 18:21:36 +00:00
|
|
|
script: |
|
|
|
|
wget -q -O - https://raw.githubusercontent.com/rancher/k3d/main/install.sh | bash
|
|
|
|
k3d cluster create
|
|
|
|
k3d kubeconfig write -o ~/.kube/config --overwrite
|
2020-05-28 17:29:28 +00:00
|
|
|
- task: CmdLine@2
|
|
|
|
inputs:
|
|
|
|
script: |
|
2020-11-15 00:05:20 +00:00
|
|
|
sudo apt install -y libxmlsec1-dev pkg-config
|
2020-05-28 17:29:28 +00:00
|
|
|
sudo pip install -U wheel pipenv
|
|
|
|
pipenv install --dev
|
2020-07-03 07:54:25 +00:00
|
|
|
- task: DockerCompose@0
|
|
|
|
displayName: Run ChromeDriver
|
2020-05-28 17:29:28 +00:00
|
|
|
inputs:
|
2020-07-10 13:37:10 +00:00
|
|
|
dockerComposeFile: 'e2e/ci.docker-compose.yml'
|
2020-07-03 07:54:25 +00:00
|
|
|
action: 'Run a specific service'
|
|
|
|
serviceName: 'chrome'
|
2020-07-03 07:25:13 +00:00
|
|
|
- task: CmdLine@2
|
2020-07-03 07:54:25 +00:00
|
|
|
displayName: Build static files for e2e
|
2020-07-03 07:25:13 +00:00
|
|
|
inputs:
|
|
|
|
script: |
|
|
|
|
cd passbook/static/static
|
2020-10-09 09:33:02 +00:00
|
|
|
npm i
|
|
|
|
npm run build
|
2020-07-03 07:25:13 +00:00
|
|
|
- task: CmdLine@2
|
2020-07-03 07:54:25 +00:00
|
|
|
displayName: Run full test suite
|
2020-07-14 19:36:40 +00:00
|
|
|
inputs:
|
2020-09-16 07:08:10 +00:00
|
|
|
script: |
|
2020-10-19 12:55:25 +00:00
|
|
|
export PB_TEST_K8S=true
|
2020-09-25 20:17:04 +00:00
|
|
|
pipenv run coverage run ./manage.py test e2e -v 3 --failfast
|
2020-09-16 07:08:10 +00:00
|
|
|
- task: CmdLine@2
|
|
|
|
condition: always()
|
|
|
|
displayName: Cleanup
|
|
|
|
inputs:
|
|
|
|
script: |
|
|
|
|
docker stop $(docker ps -aq)
|
2020-10-18 13:14:00 +00:00
|
|
|
docker container prune -f
|
2020-07-14 19:36:40 +00:00
|
|
|
- task: CmdLine@2
|
|
|
|
displayName: Prepare unittests and coverage for upload
|
2020-07-03 07:25:13 +00:00
|
|
|
inputs:
|
2020-07-10 15:12:37 +00:00
|
|
|
script: |
|
|
|
|
mkdir output-e2e
|
|
|
|
mv unittest.xml output-e2e/unittest.xml
|
|
|
|
mv .coverage output-e2e/coverage
|
|
|
|
- task: PublishPipelineArtifact@1
|
2020-07-03 07:54:25 +00:00
|
|
|
condition: failed()
|
|
|
|
displayName: Upload screenshots if selenium tests fail
|
2020-07-03 07:25:13 +00:00
|
|
|
inputs:
|
2020-07-10 15:12:37 +00:00
|
|
|
targetPath: 'selenium_screenshots/'
|
|
|
|
artifact: 'selenium screenshots'
|
|
|
|
publishLocation: 'pipeline'
|
|
|
|
- task: PublishPipelineArtifact@1
|
|
|
|
inputs:
|
2020-07-10 15:43:16 +00:00
|
|
|
targetPath: 'output-e2e/'
|
|
|
|
artifact: 'coverage-e2e'
|
2020-07-10 15:12:37 +00:00
|
|
|
publishLocation: 'pipeline'
|
2020-07-10 15:25:19 +00:00
|
|
|
- stage: test_combine
|
2020-07-10 15:12:37 +00:00
|
|
|
jobs:
|
|
|
|
- job: test_coverage_combine
|
|
|
|
pool:
|
|
|
|
vmImage: 'ubuntu-latest'
|
|
|
|
steps:
|
|
|
|
- task: DownloadPipelineArtifact@2
|
|
|
|
inputs:
|
|
|
|
buildType: 'current'
|
|
|
|
artifactName: 'coverage-e2e'
|
2020-07-10 16:39:16 +00:00
|
|
|
path: "coverage-e2e/"
|
2020-07-10 15:12:37 +00:00
|
|
|
- task: DownloadPipelineArtifact@2
|
|
|
|
inputs:
|
|
|
|
buildType: 'current'
|
|
|
|
artifactName: 'coverage-unittest'
|
2020-07-10 16:39:16 +00:00
|
|
|
path: "coverage-unittest/"
|
2020-07-10 15:12:37 +00:00
|
|
|
- task: UsePythonVersion@0
|
|
|
|
inputs:
|
|
|
|
versionSpec: '3.8'
|
2020-05-28 17:29:28 +00:00
|
|
|
- task: CmdLine@2
|
|
|
|
inputs:
|
2020-07-03 07:54:25 +00:00
|
|
|
script: |
|
2020-11-15 00:05:20 +00:00
|
|
|
sudo apt install -y libxmlsec1-dev pkg-config
|
2020-07-10 15:12:37 +00:00
|
|
|
sudo pip install -U wheel pipenv
|
|
|
|
pipenv install --dev
|
2020-07-10 16:07:18 +00:00
|
|
|
pipenv run coverage combine coverage-e2e/coverage coverage-unittest/coverage
|
2020-07-03 07:54:25 +00:00
|
|
|
pipenv run coverage xml
|
|
|
|
pipenv run coverage html
|
|
|
|
- task: PublishCodeCoverageResults@1
|
|
|
|
inputs:
|
2020-07-10 17:11:36 +00:00
|
|
|
codeCoverageTool: 'Cobertura'
|
2020-07-03 07:54:25 +00:00
|
|
|
summaryFileLocation: 'coverage.xml'
|
2020-07-10 17:11:36 +00:00
|
|
|
pathToSources: '$(System.DefaultWorkingDirectory)'
|
2020-07-03 07:54:25 +00:00
|
|
|
- task: PublishTestResults@2
|
|
|
|
condition: succeededOrFailed()
|
|
|
|
inputs:
|
2020-07-10 17:11:36 +00:00
|
|
|
testResultsFormat: 'JUnit'
|
|
|
|
testResultsFiles: |
|
|
|
|
coverage-e2e/unittest.xml
|
|
|
|
coverage-unittest/unittest.xml
|
|
|
|
mergeTestResults: true
|
2020-05-28 17:29:28 +00:00
|
|
|
- task: CmdLine@2
|
2020-05-29 07:18:17 +00:00
|
|
|
env:
|
|
|
|
CODECOV_TOKEN: $(CODECOV_TOKEN)
|
2020-05-28 17:29:28 +00:00
|
|
|
inputs:
|
|
|
|
script: bash <(curl -s https://codecov.io/bash)
|
2020-05-28 17:44:25 +00:00
|
|
|
- stage: Build
|
|
|
|
jobs:
|
2020-05-28 17:46:10 +00:00
|
|
|
- job: build_server
|
2020-05-28 17:44:25 +00:00
|
|
|
pool:
|
|
|
|
vmImage: 'ubuntu-latest'
|
2020-05-28 19:00:30 +00:00
|
|
|
steps:
|
|
|
|
- task: Docker@2
|
|
|
|
inputs:
|
|
|
|
containerRegistry: 'dockerhub'
|
|
|
|
repository: 'beryju/passbook'
|
|
|
|
command: 'buildAndPush'
|
|
|
|
Dockerfile: 'Dockerfile'
|
2020-09-21 15:55:57 +00:00
|
|
|
tags: "gh-${{ variables.branchName }}"
|
2020-05-28 17:46:10 +00:00
|
|
|
- job: build_static
|
2020-05-28 17:44:25 +00:00
|
|
|
pool:
|
|
|
|
vmImage: 'ubuntu-latest'
|
2020-05-28 19:00:30 +00:00
|
|
|
steps:
|
|
|
|
- task: DockerCompose@0
|
|
|
|
displayName: Run services
|
|
|
|
inputs:
|
2020-07-14 20:55:30 +00:00
|
|
|
dockerComposeFile: 'scripts/ci.docker-compose.yml'
|
2020-05-28 19:00:30 +00:00
|
|
|
action: 'Run services'
|
|
|
|
buildImages: false
|
|
|
|
- task: Docker@2
|
|
|
|
inputs:
|
|
|
|
containerRegistry: 'dockerhub'
|
|
|
|
repository: 'beryju/passbook-static'
|
2020-05-29 07:43:00 +00:00
|
|
|
command: 'build'
|
2020-05-28 19:19:06 +00:00
|
|
|
Dockerfile: 'static.Dockerfile'
|
2020-09-21 15:55:57 +00:00
|
|
|
tags: "gh-${{ variables.branchName }}"
|
2020-05-29 08:04:23 +00:00
|
|
|
arguments: "--network=beryjupassbook_default"
|
2020-05-29 07:43:00 +00:00
|
|
|
- task: Docker@2
|
|
|
|
inputs:
|
|
|
|
containerRegistry: 'dockerhub'
|
|
|
|
repository: 'beryju/passbook-static'
|
|
|
|
command: 'push'
|
2020-09-21 15:55:57 +00:00
|
|
|
tags: "gh-${{ variables.branchName }}"
|