forked from dvla/lab-gen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
143 lines (133 loc) · 3.98 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
trigger:
batch: true
branches:
include:
- main
- feature/*
- fix/*
exclude:
- releases/*
variables:
- name: dockerRegistryServiceConnection
value: '$(registryConnection)'
- name: dockerfilePath
value: '$(Build.SourcesDirectory)/Dockerfile'
- name: tag
value: '$(Build.BuildId)'
- name: buildNumber
value: '$(Build.BuildNumber)'
- name: isMain
value: $[eq(variables['Build.SourceBranch'], 'refs/heads/main')]
- name: 'System.Debug'
value: true
- name: slot
${{ if eq(variables['Build.SourceBranch'], 'refs/heads/main') }}:
value: 'dev'
${{ if ne(variables['Build.SourceBranch'], 'refs/heads/main') }}:
value: 'build'
- name: vmImageName
value: 'ubuntu-latest'
pool:
vmImage: $(vmImageName)
stages:
- stage: BuildTest
displayName: Build and test project
jobs:
- job: "LabGenerative"
displayName: "Build Tech Lab Generative"
strategy:
matrix:
# Python310:
# python.version: '3.10'
Python311:
python.version: "3.11"
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: "$(python.version)"
displayName: "Use Python $(python.version)"
- script: |
pipx install poetry
poetry install --with=dev,test
poetry show --outdated --with=dev,test
displayName: "Install dependencies"
- script: |
poetry run ruff check lab_gen
displayName: "pylint"
- script: |
poetry run pre-commit run --all-files
displayName: "Check All Files"
- script: |
cp example.env .env
mkdir secrets
poetry run pytest -vv
displayName: "pytest"
- task: PublishCodeCoverageResults@2
inputs:
summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/*coverage.xml'
- stage: Package
displayName: Build and package docker image
dependsOn: BuildTest
jobs:
- job: Build
displayName: Build
steps:
- task: Docker@2
displayName: Build and push an image to Azure container registry
inputs:
command: buildAndPush
repository: $(imageRepository)
dockerfile: $(dockerfilePath)
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
- deployment: DeployToStagingEnvironment
displayName: Publish
dependsOn: Build
environment: '$(slot)'
pool:
vmImage: $(vmImageName)
strategy:
runOnce:
deploy:
steps:
- task: AzureRmWebAppDeployment@4
displayName: Deploy the docker image to the Web App
inputs:
ConnectionType: "AzureRM"
appType: "webAppContainer"
deployToSlotOrASE: true
azureSubscription: $(azureSubscription)
WebAppName: $(webAppName)
ResourceGroupName: $(resourceGroupName)
SlotName: '$(slot)'
DockerNamespace: $(containerNamespace)
DockerRepository: $(imageRepository)
DockerImageTag: $(tag)
AppSettings: '-LAB_GEN_VERSION "$(buildNumber) $(tag)"'
- stage: ProdDeploy
displayName: Deploy docker image to production
dependsOn: Package
condition: and(succeeded(), eq(variables.isMain, true))
jobs:
- deployment: DeployToProduction
displayName: Production
environment: production
strategy:
runOnce:
deploy:
steps:
- task: AzureRmWebAppDeployment@4
displayName: Deploy the docker image to the production Web App
inputs:
ConnectionType: "AzureRM"
appType: "webAppContainer"
deployToSlotOrASE: true
azureSubscription: $(azureSubscription)
WebAppName: $(webAppName)
ResourceGroupName: $(resourceGroupName)
SlotName: production
DockerNamespace: $(containerNamespace)
DockerRepository: $(imageRepository)
DockerImageTag: $(tag)
AppSettings: '-LAB_GEN_VERSION "$(buildNumber) $(tag)"'