-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathazure-pipelines.yml
118 lines (112 loc) · 4.04 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
trigger:
branches:
exclude:
- maint*
tags:
include:
- v2.*
resources:
- repo: self
variables:
# Container registry service connection established during pipeline creation
vmImageName: 'Ubuntu-18.04'
latestBranch: development_v2
jobs:
- job: Test
displayName: 'Run tests'
pool:
vmImage: $(vmImageName)
steps:
- 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/
mkdir -p solr/data/test
mkdir -p solr/cores/test
cp config/azure-devops/core.properties solr/cores/test/
displayName: 'Make required directories and copy files'
- task: NodeTool@0
inputs:
versionSpec: '11.15.0'
displayName: 'Install node'
- bash: npm install
displayName: 'Install npm packages'
- task: UseRubyVersion@0
inputs:
versionSpec: '= 2.6.6'
addToPath: true
displayName: 'Install ruby'
- bash: |
sudo apt-get update
sudo apt-get install -y libpq-dev
gem install bundler
displayName: 'Install bundler and its dependencies'
- bash: |
sudo apt-get update
sudo apt-get install -y libsodium-dev
displayName: 'Install native dependencies'
- bash: bundle install --without production --path=${BUNDLE_PATH:-vendor/bundle}
displayName: 'Bundle install'
- bash: sudo apt-get install -y postgresql-client-10
displayName: 'Install postgres client'
- bash: docker run --rm -d -p 5432:5432 postgres:10@sha256:2aef165ab4f30fbb109e88959271d8b57489790ea13a77d27c02d8adb8feb20f
displayName: 'Start postgres'
- bash: |
bundle exec rake sunspot:solr:start
bundle exec rails db:drop
bundle exec rails db:create
bundle exec rails db:migrate
status=0
bundle exec rspec spec
status=$((${status} + $?))
npm run test:all
status=$((${status} + $?))
exit ${status}
displayName: 'Run tests'
env:
DEVISE_JWT_SECRET_KEY: $(DEVISE_JWT_SECRET_KEY)
DEVISE_SECRET_KEY: $(DEVISE_SECRET_KEY)
- job: Build
displayName: 'Build and push'
dependsOn: Test
condition: and(succeeded(), or(startsWith(variables['Build.SourceBranch'], 'refs/tags/v2'), in(variables['Build.SourceBranch'], 'refs/heads/development_v2', 'refs/heads/master')))
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')"
- 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 container registry'
inputs:
containerRegistry: '$(dockerRegistryServiceConnection)'
repository: 'primero/application'
command: 'push'
tags: |
$(tag)
$(latest)
- task: Docker@2
displayName: 'Beanstalkd Push an image to container registry'
inputs:
containerRegistry: '$(dockerRegistryServiceConnection)'
repository: 'primero/beanstalkd'
command: 'push'
tags: |
$(tag)
$(latest)
- task: Docker@2
displayName: 'Solr - Push an image to container registry'
inputs:
containerRegistry: '$(dockerRegistryServiceConnection)'
repository: 'primero/solr'
command: 'push'
tags: |
$(tag)
$(latest)