-
Notifications
You must be signed in to change notification settings - Fork 62
/
azure-pipelines.yml
161 lines (150 loc) · 5.09 KB
/
azure-pipelines.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# Copyright (c) 2014 - 2023 UNICEF. All rights reserved.
trigger:
branches:
exclude:
- maint*
tags:
include:
- v2.*
resources:
- repo: self
variables:
# Container registry service connection established during pipeline creation
vmImageName: 'Ubuntu-22.04'
latestBranch: main
jobs:
- job: Test
displayName: 'Run tests'
pool: primerox-azdo-a-ms
steps:
- bash: ./bin/install_local_test_solr.sh
- bash: |
set -e
mkdir -p log
cp config/azure-devops/database.yml config/
cp config/azure-devops/sunspot.yml config/
cp config/azure-devops/mailers.yml config/
displayName: 'Make required directories and copy files'
- task: NodeTool@0
inputs:
versionSpec: '20.14.0'
displayName: 'Install node'
- bash: npm config set legacy-peer-deps true && npm ci
displayName: 'Install npm packages'
- bash: |
apt-get update
apt-get install -y libpq-dev unzip libsodium-dev
displayName: 'Install dependencies'
- bash: |
. ~/.bash_env
rbenv global 3.3.5
bundle install --without production --path=${BUNDLE_PATH:-vendor/bundle}
displayName: 'Bundle install'
env:
RAILS_ENV: test
- bash: |
. ~/.bash_env
bundle exec rails db:drop
bundle exec rails db:create
bundle exec rails db:migrate
bundle exec rspec spec
displayName: 'Run Rspec test'
env:
RAILS_ENV: test
DEVISE_JWT_SECRET_KEY: $(DEVISE_JWT_SECRET_KEY)
DEVISE_SECRET_KEY: $(DEVISE_SECRET_KEY)
SOLR_ENABLED: true
- bash: |
npm run test
displayName: 'Run Integration test'
- bash: |
npm run test:components -- --maxWorkers=2
displayName: 'Run Integration test (Components)'
- job: Build
displayName: 'Build and push'
dependsOn: Test
pool:
vmImage: $(vmImageName)
steps:
- bash: echo "##vso[task.setvariable variable=tag]$(docker/git-to-docker-tag.sh ${BUILD_SOURCEBRANCH} ${BUILD_SOURCEVERSION})"
- bash: echo "##vso[task.setvariable variable=dash_el]$([[ ${BUILD_SOURCEBRANCH} == *${LATESTBRANCH} ]] && echo '-l')"
- bash: echo "##vso[task.setvariable variable=latest]$([[ ${BUILD_SOURCEBRANCH} == *${LATESTBRANCH} ]] && echo 'latest')"
- bash: echo "##vso[task.setvariable variable=latestpg14]$([[ ${BUILD_SOURCEBRANCH} == *${LATESTBRANCH} ]] && echo 'latest-pg14')"
- bash: echo "##vso[task.setvariable variable=latestpg15]$([[ ${BUILD_SOURCEBRANCH} == *${LATESTBRANCH} ]] && echo 'latest-pg15')"
- task: CmdLine@2
displayName: 'Build Primero Docker images'
inputs:
script: './build.sh all -t $(tag) -r $(containerRegistry) $(dash_el)'
workingDirectory: 'docker/'
- task: Docker@2
displayName: 'Application Push an image to UNICEF ACR'
inputs:
containerRegistry: '$(dockerRegistryServiceConnection)'
repository: 'primero/application'
command: 'push'
tags: |
$(tag)
$(latest)
- task: Docker@2
displayName: 'Solr - Push an image to UNICEF ACR'
inputs:
containerRegistry: '$(dockerRegistryServiceConnection)'
repository: 'primero/solr'
command: 'push'
tags: |
$(tag)
$(latest)
- task: Docker@2
displayName: 'Migration - Push an image to UNICEF ACR'
inputs:
containerRegistry: '$(dockerRegistryServiceConnection)'
repository: 'primero/migration'
command: 'push'
tags: |
$(tag)
$(latest)
- task: Docker@2
displayName: 'Application Push an image to Dockerhub'
inputs:
containerRegistry: 'dockerhub-primeroims'
repository: 'primeroims/application'
command: 'push'
tags: |
$(tag)
$(latest)
- task: Docker@2
displayName: 'Solr - Push an image to Dockerhub'
inputs:
containerRegistry: 'dockerhub-primeroims'
repository: 'primeroims/solr'
command: 'push'
tags: |
$(tag)
$(latest)
- task: Docker@2
displayName: 'Nginx - Push an image to Dockerhub'
inputs:
containerRegistry: 'dockerhub-primeroims'
repository: 'primeroims/nginx'
command: 'push'
tags: |
$(tag)
$(latest)
- task: Docker@2
displayName: 'Postgres - Push an image to Dockerhub'
inputs:
containerRegistry: 'dockerhub-primeroims'
repository: 'primeroims/postgres'
command: 'push'
tags: |
$(tag)-pg14
$(latestpg14)
- task: Docker@2
displayName: 'Postgres - Push an image to Dockerhub'
inputs:
containerRegistry: 'dockerhub-primeroims'
repository: 'primeroims/postgres'
command: 'push'
tags: |
$(tag)-pg15
$(latestpg15)