-
Notifications
You must be signed in to change notification settings - Fork 5
176 lines (159 loc) · 6.98 KB
/
open-source-unit-tests.yml
File metadata and controls
176 lines (159 loc) · 6.98 KB
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
# This workflow will run the py-marqo unit tests using the `tox` command.
# This workflow pulls a Marqo image and runs it. Py-marqo then connects to the
# running container for the tests.
# Unless otherwise specified, the Marqo version that is used for this test will be
# that specified by py-marqo's `marqo.version.__minimum_supported_marqo_version__`
# Uses a specific Python Version
name: Open source unit tests
run-name: Open source unit tests with Python Version ${{ inputs.python_version }} on Marqo tag ${{ inputs.image_tag }}
on:
workflow_dispatch:
inputs:
image_registry_location:
description: 'Marqo docker image registry location. Options: "ECR" or "DockerHub"'
required: true
default: 'DockerHub'
image_repo:
description: 'Marqo docker image repo name'
required: true
default: 'marqo'
image_tag:
description: 'Marqo image tag. Examples: "1.1.0", "test" "latest"'
required: true
default: 'latest'
python_version:
description: 'Python version to run the tests with. Examples: "3.8", "3.10", "3.13"'
required: true
default: '3.13'
# allows other workflows to reuse these unit tests:
workflow_call:
inputs:
image_registry_location:
description: 'Marqo docker image registry location. Options: "ECR" or "DockerHub"'
required: true
type: string
image_repo:
description: 'Marqo docker image repo name'
required: true
type: string
image_tag:
description: 'Marqo image tag. Examples: "1.1.0", "test" "latest"'
required: true
type: string
python_version:
description: 'Python version to run the tests with. Examples: "3.8", "3.10", "3.13"'
required: true
type: string
permissions:
contents: read
jobs:
Start-Runner:
name: Start self-hosted EC2 runner
runs-on: ubuntu-latest
outputs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_EC2_GH_RUNNER_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_EC2_GH_RUNNER_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Start EC2 runner
id: start-ec2-runner
uses: machulav/ec2-github-runner@v2
with:
mode: start
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
ec2-image-id: ${{ secrets.AMD_EC2_IMAGE_ID_200GB }}
ec2-instance-type: t3.xlarge
subnet-id: ${{ secrets.AMD_SUBNET_ID }}
security-group-id: ${{ secrets.AMD_SECURITY_GROUP_ID }}
Run-Py-Marqo-Tests:
name: Run Py-marqo Test Suite with Python ${{ inputs.python_version }}
needs: Start-Runner
runs-on: ${{ needs.start-runner.outputs.label }}
steps:
- name: Checkout py-marqo repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python ${{ inputs.python_version }}
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python_version }}
cache: "pip"
- name: Determine py-marqo's supported Marqo version
id: get_default_marqo_version
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
export PYTHONPATH=$(pwd):$(pwd)/src:$PYTHONPATH
SUPPORTED_MQ_VERSION=$(python -c 'from marqo import version; print(f"{version.__minimum_supported_marqo_version__}-cloud")') || exit 1
# error out if version is empty:
if [ -z "$SUPPORTED_MQ_VERSION" ]; then exit 1; fi
echo "version=$SUPPORTED_MQ_VERSION" >> $GITHUB_OUTPUT
- name: Log into ECR
uses: docker/login-action@v1
if: github.event.inputs.image_registry_location == 'ECR'
with:
registry: ${{ secrets.AWS_ACCOUNT_NUMBER }}.dkr.ecr.us-east-1.amazonaws.com/${{ github.event.inputs.image_repo }}
username: ${{ secrets.ECR_READER_AWS_ACCESS_KEY_ID }}
password: ${{ secrets.ECR_READER_AWS_SECRET_ACCESS_KEY }}
- name: Set registry and image repo
id: prepare
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
if [[ "${{ github.event.inputs.image_registry_location }}" == "ECR" ]]; then
echo "registry=${{ secrets.AWS_ACCOUNT_NUMBER }}.dkr.ecr.us-east-1.amazonaws.com" >> $GITHUB_OUTPUT
else
echo "registry=marqoai" >> $GITHUB_OUTPUT
fi
echo "image_repo=${{ github.event.inputs.image_repo }}" >> $GITHUB_OUTPUT
echo "image_tag=${{ github.event.inputs.image_tag }}" >> $GITHUB_OUTPUT
else
echo "registry=marqoai" >> $GITHUB_OUTPUT
echo "image_repo=marqo" >> $GITHUB_OUTPUT
echo "image_tag=${{ steps.get_default_marqo_version.outputs.version }}" >> $GITHUB_OUTPUT
fi
- name: Pull and Run Marqo Docker Container
run: |
docker pull ${{ steps.prepare.outputs.registry }}/${{ steps.prepare.outputs.image_repo }}:${{ steps.prepare.outputs.image_tag }}
docker run --name marqo -d --privileged -p 8882:8882 --add-host host.docker.internal:host-gateway \
-e MARQO_ENABLE_BATCH_APIS=True \
-e MARQO_MAX_CUDA_MODEL_MEMORY=15 \
-e MARQO_MAX_CPU_MODEL_MEMORY=15 \
${{ steps.prepare.outputs.registry }}/${{ steps.prepare.outputs.image_repo }}:${{ steps.prepare.outputs.image_tag }}
# wait for marqo to start with timeout of 10 minutes
timeout 10m bash -c 'until [[ $(curl -v --silent --insecure http://localhost:8882 2>&1 | grep Marqo) ]]; do sleep 0.1; done;' || (echo "Marqo did not start in time" && exit 1)
- name: Run Py-Marqo Tests
run: |
# show all warnings to capture deprecation warnings when running tests
export PYTHONWARNINGS="default"
python -m pip install --upgrade pip
# Required for Python 3.12 and above
pip install setuptools
pip install tox==3.26
tox
Stop-Runner:
name: Stop self-hosted EC2 runner
needs:
- Start-Runner
- Run-Py-Marqo-Tests
runs-on: ubuntu-latest
if: ${{ always() }}
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_EC2_GH_RUNNER_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_EC2_GH_RUNNER_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Stop EC2 runner
uses: machulav/ec2-github-runner@v2
with:
mode: stop
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
label: ${{ needs.start-runner.outputs.label }}
ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }}