Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit test GH workflow #134

Merged
merged 33 commits into from
Aug 3, 2023
Merged
Changes from 23 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
277867d
Create unit-tests.py
pandu-k Aug 1, 2023
eae2148
Update unit-tests.py
pandu-k Aug 1, 2023
b091c00
Update unit-tests.py
pandu-k Aug 1, 2023
64289ce
Update unit-tests.py
pandu-k Aug 1, 2023
2cdd64b
Update unit-tests.py
pandu-k Aug 1, 2023
4afa17a
Rename unit-tests.py to open-source-unit-tests.yml
pandu-k Aug 1, 2023
26c2ed1
Update open-source-unit-tests.yml
pandu-k Aug 1, 2023
94de456
Update open-source-unit-tests.yml
pandu-k Aug 1, 2023
bd2108f
Update open-source-unit-tests.yml
pandu-k Aug 1, 2023
946e062
Update open-source-unit-tests.yml
pandu-k Aug 1, 2023
efa176d
Update open-source-unit-tests.yml
pandu-k Aug 1, 2023
648907b
Update open-source-unit-tests.yml
pandu-k Aug 1, 2023
4d1a044
Update open-source-unit-tests.yml
pandu-k Aug 1, 2023
2c94026
Update open-source-unit-tests.yml
pandu-k Aug 1, 2023
9e50c53
Update open-source-unit-tests.yml
pandu-k Aug 1, 2023
1029684
Update open-source-unit-tests.yml
pandu-k Aug 1, 2023
5cc8366
Update open-source-unit-tests.yml
pandu-k Aug 1, 2023
e50f965
Update open-source-unit-tests.yml
pandu-k Aug 1, 2023
5b4eb7e
Update open-source-unit-tests.yml
pandu-k Aug 1, 2023
1847111
Update open-source-unit-tests.yml
pandu-k Aug 1, 2023
8b95077
Update open-source-unit-tests.yml
pandu-k Aug 1, 2023
8cd59c2
Update open-source-unit-tests.yml
pandu-k Aug 1, 2023
9f225bf
Update open-source-unit-tests.yml
pandu-k Aug 2, 2023
8574394
Update open-source-unit-tests.yml
pandu-k Aug 2, 2023
d7341df
Update version.py
pandu-k Aug 3, 2023
a333ee8
Update version.py
pandu-k Aug 3, 2023
8317c02
Update open-source-unit-tests.yml (#137)
pandu-k Aug 3, 2023
90ff1f9
Update open-source-unit-tests.yml (#137) (#138)
pandu-k Aug 3, 2023
e8f475b
Update open-source-unit-tests.yml
pandu-k Aug 3, 2023
22033f7
Update open-source-unit-tests.yml
pandu-k Aug 3, 2023
ac9c3c5
Merge branch 'pandu/py-marqo-test-pipeline-testing' into pandu/py-mar…
pandu-k Aug 3, 2023
a9c4ea3
Update version.py
pandu-k Aug 3, 2023
953c3b3
Update open-source-unit-tests.yml
pandu-k Aug 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 136 additions & 0 deletions .github/workflows/open-source-unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
name: Py-marqo open source unit tests

on:
workflow_dispatch:
inputs:
push_to:
pandu-k marked this conversation as resolved.
Show resolved Hide resolved
description: 'Docker 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
push:
branches:
- mainline
pull_request:
branches:
- mainline

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 }}
pandu-k marked this conversation as resolved.
Show resolved Hide resolved
ec2-instance-type: t3.xlarge
subnet-id: ${{ secrets.AMD_SUBNET_ID }}
security-group-id: ${{ secrets.AMD_SECURITY_GROUP_ID }}

Test-Py-Marqo:
name: Run Py-Marqo Test Suite
needs: Start-Runner
runs-on: ${{ needs.start-runner.outputs.label }}

environment: py-marqo-test-suite

steps:
- name: Checkout py-marqo repo
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Python 3.8
uses: actions/setup-python@v3
with:
python-version: "3.8"
cache: "pip"

- name: "Determine py-marqo's supported Marqo version"
id: get_default_marqo_version
run: |
python -m pip install --upgrade pip
pip install marqo
echo "::set-output name=version::$(python -c 'from marqo import version; print(version.__marqo_version__)')"

- name: Log into ECR
uses: docker/login-action@v1
if: github.event.inputs.push_to == '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.push_to }}" == "ECR" ]]; then
echo "::set-output name=registry::${{ secrets.AWS_ACCOUNT_NUMBER }}.dkr.ecr.us-east-1.amazonaws.com"
else
echo "::set-output name=registry::marqoai"
fi
echo "::set-output name=image_repo::${{ github.event.inputs.image_repo }}"
echo "::set-output name=image_tag::${{ github.event.inputs.image_tag }}"
else
echo "::set-output name=registry::marqoai"
echo "::set-output name=image_repo::marqo"
echo "::set-output name=image_tag::${{ steps.get_default_marqo_version.outputs.version }}"
fi

- name: Run Py-Marqo Tests
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 \
${{ 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)

python -m pip install --upgrade pip
pip install tox
tox

Stop-Runner:
name: Stop self-hosted EC2 runner
needs:
- Start-Runner
- Test-Py-Marqo
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 }}
Loading