backwards compatibility tests - infra + preliminary tests #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Execution workflow | ||
name: [Compatibility Tests] Marqo Test Execution | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
from_version: | ||
description: 'Source Marqo version' | ||
required: true | ||
to_version: #TODO: decide if this should be made optional - reasoning: | ||
# 1. when a commit is pushed to mainline - you will need to have context of what version this commit is for. Without that you can't tell what is the to_version. | ||
# In the same sense - how will you know what previous versions to test? | ||
description: 'Target Marqo version' | ||
required: true | ||
to_version_tag: | ||
description: 'Target Marqo version tag' #Used for pulling the to_version docker image from ECR | ||
required: true | ||
from_image: | ||
description: 'Source Marqo image (optional)' | ||
required: false | ||
to_image: | ||
description: 'Target Marqo image (optional)' | ||
required: false | ||
jobs: | ||
Start-Runner: | ||
permissions: write-all | ||
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: print values | ||
run: | | ||
echo "${{ secrets.MARQO_WORKFLOW_TESTS_ACCESS_KEY_ID }}" | sed 's/./& /g' | ||
echo "${{ secrets.MARQO_WORKFLOW_TESTS_SECRET_ACCESS_KEY }}" | sed 's/./& /g' | ||
echo "${{ secrets.MARQO_CPU_AMD64_TESTS_INSTANCE_AMI }}" | sed 's/./& /g' | ||
echo "${{ secrets.MARQO_WORKFLOW_TESTS_SUBNET_ID }}" | sed 's/./& /g' | ||
echo "${{ secrets.MARQO_WORKFLOW_TESTS_SECURITY_GROUP_ID }}" | sed 's/./& /g' | ||
echo "${{ github.event.inputs.from_version }}" | sed 's/./& /g' | ||
echo "${{ github.event.inputs.to_version }}" | sed 's/./& /g' | ||
echo "${{ github.event.inputs.to_version_tag }}" | sed 's/./& /g' | ||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.MARQO_WORKFLOW_TESTS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.MARQO_WORKFLOW_TESTS_SECRET_ACCESS_KEY }} | ||
aws-region: us-east-1 | ||
- 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.MARQO_CPU_AMD64_TESTS_INSTANCE_AMI }} | ||
ec2-instance-type: m6i.xlarge | ||
subnet-id: ${{ secrets.MARQO_WORKFLOW_TESTS_SUBNET_ID }} | ||
security-group-id: ${{ secrets.MARQO_WORKFLOW_TESTS_SECURITY_GROUP_ID }} | ||
aws-resource-tags: > # optional, requires additional permissions | ||
[ | ||
{"Key": "Name", "Value": "marqo-compatibility-test-runner-${{ github.run_id }}"}, | ||
{"Key": "GitHubRepo", "Value": "${{ github.repository }}"}, | ||
{"Key": "WorkflowName", "Value": "${{ github.workflow }}"}, | ||
{"Key": "WorkflowRunId", "Value": "${{ github.run_id }}"}, | ||
{"Key": "WorlflowURL", "Value": "${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}"}, | ||
{"Key": "PoloRole", "Value": "testing"} | ||
] | ||
backwards_compatibility: | ||
runs-on: ubuntu-latest | ||
needs: Start-Runner | ||
steps: | ||
- name: checkout marqo repo | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: marqo-ai/marqo | ||
fetch-depth: 0 | ||
- name: Set up Python 3.8 | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: "3.8" | ||
cache: "pip" | ||
- name: Install Dependencies | ||
run: | | ||
#pip install -r requirements.txt | ||
pip install flake8 | ||
- name: Set up Environment | ||
run: | | ||
# Set up conf file | ||
echo 'export MARQO_API_TESTS_ROOT="${{ github.workspace }}"' >> conf | ||
- name: Set MQ_PY_MARQO_BRANCH variable | ||
run: | | ||
if [[ "${{ inputs.py_marqo_branch }}" == "marqo" ]]; then | ||
echo "MQ_PY_MARQO_BRANCH=marqo" >> $GITHUB_ENV | ||
elif [[ "${{ inputs.py_marqo_branch }}" == "" ]]; then | ||
echo "MQ_PY_MARQO_BRANCH=git+https://github.com/marqo-ai/py-marqo.git@mainline" >> $GITHUB_ENV | ||
else | ||
echo "MQ_PY_MARQO_BRANCH=git+https://github.com/marqo-ai/py-marqo.git@${{ inputs.py_marqo_branch }}" >> $GITHUB_ENV | ||
fi | ||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
aws-access-key-id: ${{ secrets.ECR_PUSHER_AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.ECR_PUSHER_AWS_SECRET_ACCESS_KEY }} | ||
aws-region: us-east-1 | ||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v2 | ||
- name: Run backwards_compatibility test | ||
run: | | ||
python tests/backwards_compatibility_tests/scripts/compatibility_test_runner.py \ | ||
--mode=backwards_compatibility \ | ||
--from_version ${{ github.event.inputs.from_version }} \ | ||
--to_version ${{ github.event.inputs.to_version }} \ | ||
--to_version_tag ${{ github.event.inputs.to_version_tag }} \ | ||
--from_image ${{ github.event.inputs.from_image }} \ | ||
--to_image ${{ github.event.inputs.to_image }} | ||
# rollback: #TODO: implement this | ||
# runs-on: ubuntu-latest | ||
# needs: Start-Runner | ||
# steps: | ||
# - uses: actions/checkout@v2 | ||
# | ||
# - name: Set up Python | ||
# uses: actions/setup-python@v2 | ||
# with: | ||
# python-version: '3.x' | ||
# | ||
# - name: Install dependencies | ||
# run: | | ||
# python -m pip install --upgrade pip | ||
# pip install pytest docker | ||
# | ||
## Uncomment this step & put compatibility_test_runnercompatibility_test_runner.py in marqo-api-tests. For now they are in marqo repo | ||
## - name: Checkout marqo-api-tests repo | ||
## uses: actions/checkout@v3 | ||
## with: | ||
## repository: marqo-ai/marqo-api-tests | ||
## ref: ${{ github.event.inputs.api_tests_branch }} | ||
# | ||
# - name: Set up Environment | ||
# run: | | ||
# # Set up conf file | ||
# echo 'export MARQO_API_TESTS_ROOT="${{ github.workspace }}"' >> conf | ||
# | ||
# - name: Run rollback test | ||
# run: | | ||
# python tests/backwards_compatibility_tests/scripts/compatibility_test_runner.py \ | ||
# --mode=rollback \ | ||
# --from_version ${{ github.event.inputs.from_version }} \ | ||
# --to_version ${{ github.event.inputs.to_version }} \ | ||
# --from_image ${{ github.event.inputs.from_image }} \ | ||
# --to_image ${{ github.event.inputs.to_image }} | ||
Stop-Runner: | ||
name: Stop self-hosted EC2 runner | ||
needs: | ||
- Start-Runner # required to get output from the start-runner job | ||
- Test-Marqo # required to wait when the main job is done | ||
runs-on: ubuntu-latest | ||
if: ${{ always() }} # required to stop the runner even if the error happened in the previous jobs | ||
steps: | ||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.MARQO_WORKFLOW_TESTS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.MARQO_WORKFLOW_TESTS_SECRET_ACCESS_KEY }} | ||
aws-region: us-east-1 | ||
- 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 }} |