-
Notifications
You must be signed in to change notification settings - Fork 9
251 lines (229 loc) · 6.75 KB
/
xp.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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
name: CI
on:
# Automatically run CI on Release and Pre-Release tags and main branch
# (except changes to non-relevant paths)
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'
branches:
- main
paths-ignore:
- "plugins/**"
- ".github/workflows/plugins.yml"
# Automatically run CI on branches, that have active PR opened
pull_request:
branches:
- main
paths-ignore:
- "plugins/**"
- ".github/workflows/plugins.yml"
# To make it possible to trigger e2e CI workflow for any arbitrary git ref
workflow_dispatch:
env:
ARTIFACT_RETENTION_DAYS: 7
GO_VERSION: 1.21
GO_LINT_VERSION: v1.56.2
jobs:
lint-python:
runs-on: ubuntu-latest
env:
PYTHON: 3.7
steps:
- uses: actions/checkout@v4
- name: Setup Python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: "3.10"
architecture: x64
- name: Install dependencies
run: make install-python-ci-dependencies
- name: Lint python
run: make lint-python
lint-go:
runs-on: ubuntu-latest
steps:
- name: Set up Go
id: setup-go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- uses: actions/checkout@v4
- name: Lint Common module
uses: golangci/golangci-lint-action@v3
with:
version: ${{ env.GO_LINT_VERSION }}
working-directory: common
args: --timeout 3m --verbose --skip-files=testutils/mocks/ManagementClientInterface.go
- name: Lint Management Service module
uses: golangci/golangci-lint-action@v3
with:
version: ${{ env.GO_LINT_VERSION }}
working-directory: management-service
skip-pkg-cache: true
skip-build-cache: true
args: --timeout 3m --verbose
- name: Lint Treatment Service module
uses: golangci/golangci-lint-action@v3
with:
version: ${{ env.GO_LINT_VERSION }}
working-directory: treatment-service
skip-pkg-cache: true
skip-build-cache: true
args: --timeout 3m --verbose
unit-tests-management:
runs-on: ubuntu-latest
env:
GOPATH: ${{ github.workspace }}/api/.go
services:
postgres:
image: postgres:13-alpine
env:
POSTGRES_DB: xp
POSTGRES_USER: xp
POSTGRES_PASSWORD: xp
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Test Dependencies
uses: ./.github/actions/setup-tests
with:
go-version: ${{ env.GO_VERSION }}
- name: Run Management Service test
env:
DATABASE_HOST: localhost
DATABASE_NAME: xp
DATABASE_USER: xp
DATABASE_PASSWORD: xp
run: make test-management-service
unit-tests-treatment:
runs-on: ubuntu-latest
env:
GOPATH: ${{ github.workspace }}/api/.go
services:
postgres:
image: postgres:13-alpine
env:
POSTGRES_DB: xp
POSTGRES_USER: xp
POSTGRES_PASSWORD: xp
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Test Dependencies
uses: ./.github/actions/setup-tests
with:
go-version: ${{ env.GO_VERSION }}
- name: Run Treatment Service test
env:
DATABASE_HOST: localhost
DATABASE_NAME: xp
DATABASE_USER: xp
DATABASE_PASSWORD: xp
run: make test-treatment-service
e2e-tests:
runs-on: ubuntu-latest
env:
GOPATH: ${{ github.workspace }}/api/.go
services:
postgres:
image: postgres:13-alpine
env:
POSTGRES_DB: xp
POSTGRES_USER: xp
POSTGRES_PASSWORD: xp
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Test Dependencies
uses: ./.github/actions/setup-tests
with:
go-version: ${{ env.GO_VERSION }}
- name: Setup Python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: "3.10"
architecture: x64
- name: Install dependencies
run: make install-python-ci-dependencies
- name: Build binaries
run: make build
- name: Publish Management Service Artifact
uses: actions/upload-artifact@v4
with:
name: management-service-binary
path: management-service/bin/
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
- name: Publish Treatment Service Artifact
uses: actions/upload-artifact@v4
with:
name: treatment-service-binary
path: treatment-service/bin/
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
- name: Run E2E tests
env:
DATABASE_HOST: localhost
DATABASE_NAME: xp
DATABASE_USER: xp
DATABASE_PASSWORD: xp
run: make e2e-ci
release-rules:
runs-on: ubuntu-latest
outputs:
release-type: ${{ steps.release-rules.outputs.release-type }}
steps:
- uses: actions/checkout@v4
- id: release-rules
uses: ./.github/actions/release-rules
release:
# Automatically publish release and pre-release artifacts.
#
# As for dev releases, make it possible to publish artifacts
# manually by approving 'deployment' in the 'manual' environment.
#
# Dev build can be released either from the 'main' branch or
# by running this workflow manually with `workflow_dispatch` event.
if: >-
contains('release,pre-release', needs.release-rules.outputs.release-type)
|| ( github.event_name != 'pull_request' )
|| ( github.event.pull_request.head.repo.full_name == github.repository )
needs:
- lint-python
- lint-go
- unit-tests-management
- unit-tests-treatment
- e2e-tests
- release-rules
uses: ./.github/workflows/release.yml
with:
environment: ${{ needs.release-rules.outputs.release-type == 'dev' && 'manual' || '' }}
secrets:
ghcr_token: ${{ secrets.GITHUB_TOKEN }}