-
Notifications
You must be signed in to change notification settings - Fork 6
/
azure-pipelines-prod.yml
143 lines (120 loc) · 4.01 KB
/
azure-pipelines-prod.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: Iaso-backend-prod
trigger:
- main
resources:
containers:
- container: postgis
image: postgis/postgis:12-3.3
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: does_not_matter
ports:
- 5432:5432
# needed because the postgres container does not provide a health check
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
variables:
tag: '$(Build.BuildId)'
pool:
vmImage: ubuntu-20.04
services:
postgres: postgis
steps:
- task: NodeTool@0
inputs:
versionSpec: '20.x'
displayName: 'Install Node.js'
- script: |
npm install -g [email protected]
node -v
npm -v
npm ci
npm test -- --reporter xunit --reporter-option output=npm-test.xml
displayName: 'npm install and run test'
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testResultsFiles: "**/npm-test.xml"
testRunTitle: 'Npm test results'
- task: UsePythonVersion@0
inputs:
versionSpec: '3.9'
addToPath: true
architecture: 'x64'
- script: |
sudo apt update
displayName: 'apt update'
- script: |
sudo apt install gdal-bin
displayName: 'install gdal'
- script: |
python --version
python -m venv ./venv
. ./venv/bin/activate && pip install -U pip
displayName: 'install pip'
- script: |
. ./venv/bin/activate && pip install -r requirements.txt && pip install -r requirements-dev.txt
pip install unittest-xml-reporting
displayName: 'install requirements'
- script: pip list
displayName: 'Environment info'
- script: |
. ./venv/bin/activate && black --check .
displayName: 'Check formatting with black'
# Setting the details for the health page
- task: Bash@3
inputs:
targetType: 'inline'
script: |
./scripts/set_version.sh
displayName: 'Set Version Info for Health'
# The secret key is done with an export because Azure pipelines will
# remove all env variables that start with SECRET_
- script: |
export SECRET_KEY=${SECRETKEY}
export DJANGO_SUPERUSER_PASSWORD=${DJANGO_SUPERUSER_PASSWORD}
export DJANGO_SUPERUSER_USERNAME=${DJANGO_SUPERUSER_USERNAME}
export DJANGO_SUPERUSER_EMAIL=${DJANGO_SUPERUSER_EMAIL}
. ./venv/bin/activate && python manage.py migrate
. ./venv/bin/activate && python manage.py createcachetable
. ./venv/bin/activate && python manage.py test --testrunner xmlrunner.extra.djangotestrunner.XMLTestRunner --no-input
. ./venv/bin/activate && python manage.py makemigrations --check
. ./venv/bin/activate && python manage.py createsuperuser --noinput
displayName: 'Django tests'
condition: succeededOrFailed()
env:
IASO_ENVIRONMENT: development
RDS_DB_NAME: does_not_matter
SECRETKEY: secret-only-used-in-azure-pipeline
DEBUG: true
DJANGO_SETTINGS_MODULE: hat.settings
RDS_PASSWORD: postgres
RDS_HOSTNAME: localhost
RDS_PORT: 5432
RDS_USERNAME: postgres
CACHE: false
DEV_SERVER: true
PLUGINS: polio
DJANGO_SUPERUSER_USERNAME: adm
DJANGO_SUPERUSER_EMAIL: [email protected]
DJANGO_SUPERUSER_PASSWORD: $(DJANGO_SUPERUSER_PASSWORD)
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testResultsFiles: "**/TEST-*.xml"
testRunTitle: 'Python $(PYTHON_VERSION)'
- script: docker build -t prod-coda2 --target prod -f $(Build.SourcesDirectory)/docker/bundle/Dockerfile .
displayName: 'Build docker image'
- script: docker save -o $(Build.ArtifactStagingDirectory)/prod-coda2.tar.gz prod-coda2
displayName: 'Save docker image'
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: prod-coda2
- script: docker run -v $(Build.ArtifactStagingDirectory)/static:/opt/mount --rm --entrypoint bash prod-coda2 -c "cp -R /opt/app/static /opt/mount/"
displayName: 'Copy static files from docker'
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: $(Build.ArtifactStagingDirectory)/static
artifactName: prod-coda2-static
displayName: 'Publish static files'