-
Notifications
You must be signed in to change notification settings - Fork 3
/
azure-pipelines.yml
205 lines (198 loc) · 7.29 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
trigger:
batch: true
branches:
include:
- main
- develop
- rc/*
- patch/*
pr:
branches:
include:
- main
- develop
- rc/*
- patch/*
variables:
tag: "$(Build.BuildId)"
containerRegistry: "uchimera"
branch_name: "$(Build.SourceBranchName)"
git_branch: $(Build.SourceBranch)
pr_branch: $(System.PullRequest.targetBranchName)
repoName: "howler-api"
isMaster: $[eq(variables['Build.SourceBranch'], 'refs/heads/master')]
isPrBranch: $[eq(variables['Build.SourceBranchName'], 'merge')]
dockerfilePath: "$(Build.SourcesDirectory)/docker/Dockerfile"
pool:
vmImage: "ubuntu-24.04"
resources:
containers:
- container: redis
image: bitnami/redis:7.0.5-debian-11-r7
ports:
- 6379:6379
env:
ALLOW_EMPTY_PASSWORD: yes
- container: elasticsearch39
image: docker.elastic.co/elasticsearch/elasticsearch:8.5.2
env:
ES_JAVA_OPTS: "-Xms256m -Xmx512m"
discovery.type: "single-node"
ELASTIC_PASSWORD: "devpass"
xpack.security.enabled: "false"
ports:
- 9200:9200
- container: elasticsearch312
image: docker.elastic.co/elasticsearch/elasticsearch:8.5.2
env:
ES_JAVA_OPTS: "-Xms256m -Xmx512m"
discovery.type: "single-node"
ELASTIC_PASSWORD: "devpass"
xpack.security.enabled: "false"
ports:
- 9200:9200
- container: minio
image: bitnami/minio:2022.10.8-debian-11-r0
env:
MINIO_ROOT_USER: hwl_storage_key
MINIO_ROOT_PASSWORD: Ch@ngeTh!sPa33w0rd
ports:
- 9000:9000
- container: keycloak
image: uchimera.azurecr.io/cccs/ap-mini/keycloak:1.0.1
ports:
- 9100:8080
registry: $(containerRegistry)
endpoint: uchimera
stages:
- stage: run_qa_and_test
displayName: Quality Assurance and Tests
jobs:
- job: run_qa
displayName: Check Code Quality Standards
steps:
- checkout: self
fetchDepth: 100
persistCredentials: true
- script: |
python --version
pipx install poetry
displayName: Install poetry
- script: |
poetry --version
poetry check
poetry env info
displayName: Check for poetry config integrity
- script: |
poetry install --verbose --with test
displayName: Install dependencies
workingDirectory: $(Pipeline.Workspace)/s
- script: |
poetry run python build_scripts/run_wrapped.py ruff format howler --check
displayName: Run ruff formatter checks
workingDirectory: $(Pipeline.Workspace)/s
- script: |
poetry run python build_scripts/run_wrapped.py ruff check howler --output-format concise
displayName: Run ruff linter checks
workingDirectory: $(Pipeline.Workspace)/s
- script: |
poetry run type_check
displayName: Run type checking
workingDirectory: $(Pipeline.Workspace)/s
- task: GithubComment@0
condition: and(eq(variables.isPrBranch, true), and(failed(), ne(variables.error_result, '')))
inputs:
githubConnection: Howler Github PAT
repositoryName: "$(Build.Repository.Name)"
comment: $(error_result)
- job: run_test
dependsOn: run_qa
displayName: Unit and Integration Testing
strategy:
matrix:
"(Python 3.9)":
python.version: "3.9"
elasticInstance: elasticsearch39
"(Python 3.12)":
python.version: "3.12"
elasticInstance: elasticsearch312
maxParallel: 2
timeoutInMinutes: 20
services:
elasticsearch: $[ variables['elasticInstance'] ]
redis: redis
minio: minio
keycloak: keycloak
steps:
- checkout: self
fetchDepth: 100
persistCredentials: true
- script: |
git fetch --force --tags --prune --prune-tags --progress --no-recurse-submodules origin --depth=1 $PR_BRANCH
displayName: Fetch target branch for diff coverage
condition: eq(variables.isPrBranch, true)
- script: |
sudo apt install -yy software-properties-common
sudo add-apt-repository -y ppa:deadsnakes/ppa
sudo apt install -yy python$(python.version) python$(python.version)-dev python$(python.version)-venv
displayName: Install Python
- script: |
pipx install poetry
displayName: Install Poetry
- script: |
poetry --version
poetry env use $(python.version)
poetry check
poetry env info
displayName: Check for poetry config integrity
- script: |
sudo mkdir -p /var/log/howler/
sudo mkdir -p /var/cache/howler/
sudo mkdir -p /var/lib/howler/
sudo mkdir -p /etc/howler/conf/
sudo mkdir -p /etc/howler/lookups/
sudo chmod a+rw /var/log/howler/
sudo chmod a+rw /var/cache/howler/
sudo chmod a+rw /var/lib/howler/
sudo chmod a+rw /etc/howler/conf/
sudo chmod a+rw /etc/howler/lookups/
cp build_scripts/classification.yml /etc/howler/conf/classification.yml
cp test/unit/config.yml /etc/howler/conf/config.yml
displayName: Setup Environment
workingDirectory: $(Pipeline.Workspace)/s
- script: |
poetry install --verbose --with test
poetry run mitre /etc/howler/lookups
poetry run sigma
displayName: Install howler-api
workingDirectory: $(Pipeline.Workspace)/s
- script: |
poetry run test
workingDirectory: $(Pipeline.Workspace)/s
displayName: Test
- script: |
poetry run coverage_report
workingDirectory: $(Pipeline.Workspace)/s
displayName: Coverage Results
condition: and(eq(variables.isPrBranch, true), eq(variables['python.version'], '3.12'))
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testResultsFiles: "$(Pipeline.Workspace)/s/**/test-*.xml"
testRunTitle: "Publish test results for Python $(python.version)"
- task: PublishCodeCoverageResults@2
condition: succeededOrFailed()
inputs:
summaryFileLocation: "$(Pipeline.Workspace)/s/**/coverage.xml"
- task: GithubComment@0
condition: and(and(eq(variables.isPrBranch, true), succeeded()), eq(variables['python.version'], '3.12'))
inputs:
githubConnection: Howler Github PAT
repositoryName: "$(Build.Repository.Name)"
comment: $(coverage_result)
- task: GithubComment@0
condition: and(eq(variables.isPrBranch, true), and(failed(), ne(variables.error_result, '')))
inputs:
githubConnection: Howler Github PAT
repositoryName: "$(Build.Repository.Name)"
comment: $(error_result)