#!/bin/bash ###################################################################################################################### # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # # # # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance # # with the License. A copy of the License is located at # # # # http://www.apache.org/licenses/LICENSE-2.0 # # # # or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES # # OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions # # and limitations under the License. # ###################################################################################################################### ############################################################################### # PURPOSE: This script runs our pytest e2e test within the github actions environment. # # USAGE: # ./run_e2e.sh # ############################################################################### # Create and activate a temporary Python environment for this script. echo "------------------------------------------------------------------------------" echo "Creating a temporary Python virtualenv for this script" echo "------------------------------------------------------------------------------" python -c "import os; print (os.getenv('VIRTUAL_ENV'))" | grep -q None if [ $? -ne 0 ]; then echo "ERROR: Do not run this script inside Virtualenv. Type \`deactivate\` and run again."; exit 1; fi which python3 if [ $? -ne 0 ]; then echo "ERROR: install Python3 before running this script" exit 1 fi VENV=$(mktemp -d) python3 -m venv $VENV source $VENV/bin/activate pip install -r requirements.txt if [ $? -ne 0 ]; then echo "ERROR: Failed to install required Python libraries." exit 1 fi echo "------------------------------------------------------------------------------" pytest if [ $? -eq 0 ]; then exit 0 else exit 1 fi echo "------------------------------------------------------------------------------" echo "Cleaning up" echo "------------------------------------------------------------------------------" # Deactivate and remove the temporary python virtualenv used to run this script deactivate rm -rf $VENV rm -rf __pycache__