-
Notifications
You must be signed in to change notification settings - Fork 1
265 lines (256 loc) · 8.66 KB
/
main.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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
name: Github Datamimic CE CI
run-name: ${{ github.run_actor }} is running ${{ github.workflow }} on ${{ github.repository }}
on:
push:
branches:
- development
tags:
- '[0-9]+.[0-9]+.[0-9]+'
pull_request:
branches:
- development
env:
DATAMIMIC_LIB_ENVIRONMENT: lib_staging
jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Export latest tag
run: |
export RD_PROJECT_LATEST_TAG=${GITHUB_REF#refs/*/}
echo "RD_PROJECT_LATEST_TAG=$RD_PROJECT_LATEST_TAG"
echo "RD_PROJECT_LATEST_TAG=$RD_PROJECT_LATEST_TAG" >> build.env
- name: Export lib version without patch
run: |
export LIB_VERSION_WITHOUT_PATCH=$(echo "$RD_PROJECT_LATEST_TAG" | sed 's/\.[^.]*$//')
echo "LIB_VERSION_WITHOUT_PATCH=$LIB_VERSION_WITHOUT_PATCH"
echo "LIB_VERSION_WITHOUT_PATCH=$LIB_VERSION_WITHOUT_PATCH" >> build.env
- name: Upload build.env
uses: actions/upload-artifact@v4
with:
name: setup
path: build.env
if-no-files-found: error
retention-days: 1
install_dependencies:
runs-on: ubuntu-latest
container: python:3.11-slim-buster
needs: setup
permissions:
contents: read
steps:
- name: Install dependencies os packages
run: |
apt-get update
apt-get install -y libpq-dev curl build-essential git
curl -LsSf https://astral.sh/uv/install.sh | sh
git config --global --add safe.directory $(realpath .)
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Cache python venv
uses: actions/cache@v4
with:
path: .venv
key: ${{ runner.os }}-python-${{ hashFiles('./pyproject.toml') }}
- name: Check version
run: |
uv --version
echo testdb=${DB_HOST}:${DB_PORT}/${DB_DATABASE} with user=${DB_USER} password=${DB_PASSWORD}
echo MINIO_CONSUMER_HOST=${MINIO_CONSUMER_HOST} with MINIO_CONSUMER_ACCESS_KEY=${MINIO_CONSUMER_ACCESS_KEY} MINIO_CONSUMER_SECRET_KEY=${MINIO_CONSUMER_SECRET_KEY}
echo redis=${REDIS_HOST}:${REDIS_PORT} with password=${REDIS_PASSWORD}
echo logger_redis=${LOGGER_REDIS_HOST}:${LOGGER_REDIS_PORT} with password=${LOGGER_REDIS_PASSWORD}
shell: bash
- name: Create virtual env
run: |
uv venv .venv --python 3.11
. .venv/bin/activate
- name: Install dependencies
run: |
uv sync --all-extras
shell: bash
unit_test:
runs-on: ubuntu-latest
needs: install_dependencies
container: python:3.11-slim-buster
steps:
- name: Setup git
run: |
apt-get update
apt-get install -y git
git config --global --add safe.directory $(realpath .)
- name: Checkout repository
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Load venv cache
uses: actions/cache/restore@v4
with:
path: .venv
key: ${{ runner.os }}-python-${{ hashFiles('./pyproject.toml') }}
- name: Run unit tests
run: |
. .venv/bin/activate
which pytest
uv run pytest tests_ce/unit_tests/ -n auto
shell: bash
functional_test:
runs-on: ubuntu-latest
needs: install_dependencies
container: python:3.11-slim-buster
services:
postgres:
image: postgres:13
env:
POSTGRES_USER: datamimic
POSTGRES_PASSWORD: datamimic
POSTGRES_DB: rd-datamimic
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
mongo:
image: mongo:4.4
env:
MONGO_INITDB_ROOT_USERNAME: datamimic
MONGO_INITDB_ROOT_PASSWORD: datamimic
ports:
- 27017:27017
options: --health-cmd "mongo --eval 'db.stats().ok'" --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Setup git
run: |
apt-get update
apt-get install -y git
git config --global --add safe.directory $(realpath .)
- name: Checkout repository
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Load venv cache
uses: actions/cache/restore@v4
with:
path: .venv
key: ${{ runner.os }}-python-${{ hashFiles('./pyproject.toml') }}
- name: Run functional tests
run: |
. .venv/bin/activate
uv run pytest tests_ce/functional_tests/ -n auto
shell: bash
integration_test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:13
env:
POSTGRES_USER: datamimic
POSTGRES_PASSWORD: datamimic
POSTGRES_DB: rd-datamimic
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
mongo:
image: mongo:4.4
env:
MONGO_INITDB_ROOT_USERNAME: datamimic
MONGO_INITDB_ROOT_PASSWORD: datamimic
ports:
- 27017:27017
options: --health-cmd "mongo --eval 'db.stats().ok'" --health-interval 10s --health-timeout 5s --health-retries 5
container: python:3.11-slim-buster
needs: install_dependencies
steps:
- name: Setup git
run: |
apt-get update
apt-get install -y git
git config --global --add safe.directory $(realpath .)
- name: Checkout repository
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Load venv cache
uses: actions/cache/restore@v4
with:
path: .venv
key: ${{ runner.os }}-python-${{ hashFiles('./pyproject.toml') }}
- name: Run integration tests
run: |
. .venv/bin/activate
uv run pytest tests_ce/integration_tests/ -n auto
shell: bash
publish_dev:
if: github.ref == 'refs/heads/development'
runs-on: ubuntu-latest
needs: [ unit_test, functional_test, integration_test ]
environment:
name: testpypi
url: https://test.pypi.org/p/datamimic_ce
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Package
# IMPORTANT: Use "pip install build" instead of "uv add" to avoid updating pyproject.toml, which accidentally create dirty package version
run: |
uv venv .venv --python 3.11
. .venv/bin/activate
which python
uv pip install build
python -m build
shell: bash
- name: Publish distribution to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
# verbose: true
release:
if: startsWith(github.ref, 'refs/tags/')
needs: [ unit_test, functional_test, integration_test ]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/datamimic_ce
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Package
run: |
uv venv .venv --python 3.11
. .venv/bin/activate
which python
uv pip install build
python -m build
shell: bash
# - name: Publish distribution to TestPyPI
# uses: pypa/gh-action-pypi-publish@release/v1
trigger_ee_dev:
if: github.ref == 'refs/heads/development'
runs-on: ubuntu-latest
needs:
- publish_dev
steps:
- name: trigger EE development pipelines
run: curl -X POST --fail -F token=$EE_TOKEN -F ref=development https://gitlab.dwellerlab.com/api/v4/projects/214/trigger/pipeline;
env:
EE_TOKEN: ${{ secrets.EE_TOKEN }}
shell: bash