-
Notifications
You must be signed in to change notification settings - Fork 1
/
azure-pipeline-dev.yml
118 lines (109 loc) · 4 KB
/
azure-pipeline-dev.yml
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
trigger:
branches:
include:
- develop
- staging
tags:
include:
- 'release-*'
name: $(SourceBranchName).$(Build.BuildId).$(Date:yyyyMMdd).$(Rev:r)
pool:
vmImage: 'ubuntu-22.04'
variables:
dockerRegistryServiceConnection: $(DOCKER_SERVICE_CONNECTION)
dockerfilePath: './Dockerfile'
app: $(DOCKER_REPOSITORY)
imageRepositoryDev: 'dev/$(app)'
imageRepositoryStg: 'stg/$(app)'
imageRepositoryProd: 'prod/$(app)'
tag: '$(Build.BuildId)'
pythonVersion: '3.8'
steps:
# Use a specific Python version
- task: UsePythonVersion@0
displayName: Building Razor with $(pythonVersion)
inputs:
versionSpec: $(pythonVersion)
addToPath: true
- task: Bash@3
displayName: Unit Tests
condition: eq(variables['Build.SourceBranch'], 'refs/heads/develop')
inputs:
targetType: 'inline'
script: |
sudo systemctl start postgresql.service
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD 'root';"
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
sudo apt update
sudo apt install postgis postgresql-14-postgis-3
sudo apt-get install redis
sudo apt install binutils libproj-dev gdal-bin
sudo pip install pipenv
pipenv install --ignore-pipfile --dev
./scripts/runtests.sh
continueOnError: true
# Sonar Scan
- task: Bash@3
displayName: Sonar Scan
condition: eq(variables['Build.SourceBranch'], 'refs/heads/develop')
inputs:
targetType: 'inline'
script: |
export SONAR_SCANNER_VERSION=5.0.1.3006
export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
export PATH=$SONAR_SCANNER_HOME/bin:$PATH
export SONAR_SCANNER_OPTS="-server"
export SONAR_TOKEN=$(SONAR_TOKEN)
sonar-scanner \
-Dsonar.projectKey=${{ lower(variables['Build.DefinitionName']) }} \
-Dsonar.sources=proco \
-Dsonar.host.url=$(SONAR_HOST) \
-Dsonar.python.coverage.reportPaths=coverage.xml \
-Dsonar.exclusions=**/migrations/**,**/proco_data_migrations/**,**/tests/**,**/proco/**/admin.py,**/dailycheckapp_contact/**,**/realtime_dailycheckapp/**,**/realtime_unicef/**,**/management/commands/**
# Docker build and push
- task: Docker@2
displayName: Dev - Build and Push image
inputs:
command: buildAndPush
repository: $(imageRepositoryDev)
dockerfile: $(dockerfilePath)
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
- task: Docker@2
displayName: Stg - Build and Push image
condition:
and(
succeeded(),
eq(variables['Build.SourceBranch'], 'refs/heads/staging')
)
inputs:
command: buildAndPush
repository: $(imageRepositoryStg)
dockerfile: $(dockerfilePath)
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
- task: Docker@2
displayName: Prod - Build and Push image
condition:
and(
succeeded(),
startsWith(variables['Build.SourceBranch'], 'refs/tags/release-')
)
inputs:
command: buildAndPush
repository: $(imageRepositoryProd)
dockerfile: $(dockerfilePath)
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)