Skip to content

Commit f4703b8

Browse files
authored
Add GH Action for building and pushing docker images, add new test (#30)
* add CICD pipeline * add shell and python scripts directories, add update stability test * fix error in CODEOWNERS, rename cicd -> ci * fix building and pushing the Docker Image
1 parent e44b64c commit f4703b8

File tree

11 files changed

+126
-3
lines changed

11 files changed

+126
-3
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Ci related folders
2+
/.github/ @weaviate/core
3+
/ci/ @weaviate/core

.github/workflows/main.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Main
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- '**'
9+
paths-ignore:
10+
- README.md
11+
- LICENSE
12+
pull_request:
13+
14+
jobs:
15+
Push-Docker:
16+
name: push-docker
17+
runs-on: ubuntu-latest-8-cores
18+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Login to Docker Hub
22+
uses: docker/login-action@v3
23+
with:
24+
username: ${{secrets.DOCKER_USERNAME}}
25+
password: ${{secrets.DOCKER_PASSWORD}}
26+
- name: Push container
27+
run: ./cicd/push_docker.sh

LICENSE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2020-2022, SeMI Technologies B.V.
1+
Copyright (c) 2020-2024, Weaviate B.V.
22
All rights reserved.
33

44
Redistribution and use in source and binary forms, with or without
@@ -24,4 +24,4 @@ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
2424
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
2525
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2626
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

benchmarker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
FROM golang:alpine
2-
RUN apk add --no-cache hdf5-dev gcc libc-dev python3
2+
RUN apk add --no-cache hdf5-dev gcc libc-dev python3 bash
33
WORKDIR /app
44
COPY . .
55
RUN CGO_ENABLED=1 go build -o benchmarker .
File renamed without changes.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import os
2+
import glob
3+
import json
4+
import unittest
5+
6+
7+
PATH = "./results"
8+
REQUIRED_RECALL = .992
9+
10+
11+
class TestResults(unittest.TestCase):
12+
13+
def setUp(self):
14+
self.datapoints = []
15+
16+
for result_filename in glob.glob(os.path.join(PATH, "*.json")):
17+
with open(os.path.join(os.getcwd(), result_filename), "r") as result_file:
18+
self.datapoints.append(json.load(result_file))
19+
20+
def test_max_recall(self):
21+
22+
rr_env = os.getenv("REQUIRED_RECALL")
23+
24+
if rr_env:
25+
required_recall = float(rr_env)
26+
else:
27+
required_recall = REQUIRED_RECALL
28+
29+
for run_iteration in self.datapoints:
30+
31+
max_recall = max([run_config["recall"] for run_config in run_iteration])
32+
self.assertTrue(
33+
max_recall >= required_recall,
34+
f"need to achieve at least {required_recall} recall, got only {max_recall}",
35+
)
36+
37+
38+
if __name__ == "__main__":
39+
unittest.main()
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
set -eou pipefail
4+
5+
echo "Run benchmark script"
6+
/app/benchmarker ann-benchmark \
7+
-v /app/datasets/${DATASET}.hdf5 \
8+
--distance $DISTANCE \
9+
--indexType $INDEX_TYPE \
10+
--updatePercentage $UPDATE_PERCENTAGE \
11+
--cleanupIntervalSeconds $CLEANUP_INTERVAL_SECONDS \
12+
--updateIterations $UPDATE_ITERATIONS \
13+
--grpcOrigin "${WEAVIATE_URL}:50051" \
14+
--httpOrigin "${WEAVIATE_URL}:8080" \
15+
--updateRandomized
16+
17+
18+
echo "Run complete, now analyze the results"
19+
python3 /app/scripts/python/update_stability.py
20+
21+
echo "Passed!"

ci/push_docker.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
set -eou pipefail
4+
5+
DOCKER_REPO="semitechnologies/weaviate-benchmarker"
6+
7+
function main() {
8+
init
9+
echo "git ref type is \"$GITHUB_REF_TYPE\""
10+
echo "git ref name is \"$GITHUB_REF_NAME\""
11+
build_and_push_tag
12+
}
13+
14+
function init() {
15+
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
16+
docker buildx create --use
17+
}
18+
19+
function build_and_push_tag() {
20+
if [ ! -z "$GITHUB_REF_NAME" ] && [ "$GITHUB_REF_TYPE" == "tag" ]; then
21+
tag_git="$DOCKER_REPO:$GITHUB_REF_NAME"
22+
tag_latest="$DOCKER_REPO:latest"
23+
24+
echo "Tag & Push $tag_latest, $tag_git"
25+
docker buildx build --platform=linux/arm64,linux/amd64 \
26+
--push \
27+
--tag "$tag_git" \
28+
--tag "$tag_latest" \
29+
./benchmarker
30+
fi
31+
}
32+
33+
main

0 commit comments

Comments
 (0)