-
Notifications
You must be signed in to change notification settings - Fork 51
209 lines (184 loc) · 6.75 KB
/
nucliadb.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
name: nucliadb (py)
env:
COMPONENT: nucliadb
CONTAINER_REGISTRY: eu.gcr.io/${{ secrets.PROJECT_ID }}
TESTING_TIKV_LOCAL: "true"
permissions:
contents: write
on:
pull_request:
branches:
- main
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
pre-checks:
uses: ./.github/workflows/_component_prechecks.yml
with:
component: "nucliadb"
python_version: "3.11"
# Job to run Python tests
tests:
name: NucliaDBTests
runs-on: ubuntu-latest
strategy:
max-parallel: 6
matrix:
python-version: ["3.11"]
maindb_driver: ["tikv", "tikv_2", "tikv_3", "pg", "pg_2", "pg_3"]
steps:
- name: Checkout the repository
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install the package
run: make -C nucliadb/ install-dev
- name: Install tikv
if: matrix.maindb_driver == 'tikv' || matrix.maindb_driver == 'tikv_2' || matrix.maindb_driver == 'tikv_3'
run: ./scripts/run-tikv.sh
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
workflows:
- 'nucliadb_node/**'
- 'nucliadb_texts/**'
- 'nucliadb_texts2/**'
- 'nucliadb_paragraphs/**'
- 'nucliadb_vectors/**'
- 'nucliadb_relations/**'
- 'nucliadb_relations2/**'
- name: Calc git info
id: git
run: |-
BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
- name: Install rust binding for testing
if: steps.filter.outputs.workflows == 'true'
env:
SECRET_KEY: ${{ secrets.RUST_BUILD_SERVER_SECRET }}
COMMIT_HASH: ${{ github.event.pull_request.head.sha || github.sha }}
BRANCH: ${{ steps.git.outputs.branch }}
MATURIN: "true"
ENV: '{"RUSTFLAGS": "--cfg tokio_unstable"}'
run: |
./scripts/download-build.sh && pip install builds/wheels/*_x86_64.whl || (
echo "Failed building from the build server." && make build-node-binding-debug
)
- name: Run PG tests 1/3
# These tests can be flaky, let's retry them...
uses: nick-fields/retry@v2
if: matrix.maindb_driver == 'pg'
env:
TESTING_MAINDB_DRIVERS: pg
with:
max_attempts: 2
retry_on: error
timeout_minutes: 10
command: |
pytest -rfE --cov=nucliadb -s --tb=native -v --cov-report xml --cov-append --benchmark-json benchmarks.json --shard-id=0 --num-shards=3 nucliadb/nucliadb/tests
- name: Run PG tests 2/3
# These tests can be flaky, let's retry them...
uses: nick-fields/retry@v2
if: matrix.maindb_driver == 'pg_2'
env:
TESTING_MAINDB_DRIVERS: pg
with:
max_attempts: 2
retry_on: error
timeout_minutes: 10
command: |
pytest -rfE --cov=nucliadb -s --tb=native -v --cov-report xml --cov-append --benchmark-json benchmarks.json --shard-id=1 --num-shards=3 nucliadb/nucliadb/tests
- name: Run PG tests 2/3
# These tests can be flaky, let's retry them...
uses: nick-fields/retry@v2
if: matrix.maindb_driver == 'pg_3'
env:
TESTING_MAINDB_DRIVERS: pg
with:
max_attempts: 2
retry_on: error
timeout_minutes: 10
command: |
pytest -rfE --cov=nucliadb -s --tb=native -v --cov-report xml --cov-append --benchmark-json benchmarks.json --shard-id=2 --num-shards=3 nucliadb/nucliadb/tests
- name: Run Tikv tests 1/2
# These tests can be flaky, let's retry them...
uses: nick-fields/retry@v2
if: matrix.maindb_driver == 'tikv'
env:
TESTING_MAINDB_DRIVERS: tikv
with:
max_attempts: 2
retry_on: error
timeout_minutes: 10
command: |
pytest -rfE --cov=nucliadb -s --tb=native -v --cov-report xml --cov-append --benchmark-json benchmarks.json --shard-id=0 --num-shards=3 nucliadb/nucliadb/tests
- name: Run Tikv tests 2/3
# These tests can be flaky, let's retry them...
uses: nick-fields/retry@v2
if: matrix.maindb_driver == 'tikv_2'
env:
TESTING_MAINDB_DRIVERS: "tikv"
with:
max_attempts: 2
retry_on: error
timeout_minutes: 10
command: |
pytest -rfE --cov=nucliadb -s --tb=native -v --cov-report xml --cov-append --benchmark-json benchmarks.json --shard-id=1 --num-shards=3 nucliadb/nucliadb/tests
- name: Run Tikv tests 3/3
# These tests can be flaky, let's retry them...
uses: nick-fields/retry@v2
if: matrix.maindb_driver == 'tikv_3'
env:
TESTING_MAINDB_DRIVERS: "tikv"
with:
max_attempts: 2
retry_on: error
timeout_minutes: 10
command: |
pytest -rfE --cov=nucliadb -s --tb=native -v --cov-report xml --cov-append --benchmark-json benchmarks.json --shard-id=2 --num-shards=3 nucliadb/nucliadb/tests
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: nucliadb
push-dev:
name: Build dev image and push
runs-on: ubuntu-latest
needs: tests
if: github.event_name == 'pull_request'
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Get safe branch name
id: branch_name
run: |-
BRANCH_NAME=`echo $GITHUB_HEAD_REF | sed 's$/$-$g'`
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
- name: Setup gcloud CLI
uses: google-github-actions/auth@v1
with:
credentials_json: "${{ secrets.GCP_CREDENTIALS }}"
- name: "Set up Cloud SDK"
uses: "google-github-actions/setup-gcloud@v1"
- name: Configure Docker
run: docker login -u oauth2accesstoken -p "$(gcloud auth application-default print-access-token)" https://eu.gcr.io
# We need to setup buildx to be able to cache with gha
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.CONTAINER_REGISTRY }}/${{ env.COMPONENT }}:${{ steps.branch_name.outputs.branch_name }}
cache-from: type=gha
cache-to: type=gha,mode=min