forked from awslabs/serverless-automated-ui-testing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildspec-phantomjs.yml
46 lines (44 loc) · 1.64 KB
/
buildspec-phantomjs.yml
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
version: 0.2
env:
variables:
BROWSER: "phantomjs"
WebURL: "https://sampletestweb.s3-eu-west-1.amazonaws.com/website/index.html"
ArtifactBucket: "codebuild-demo-artifact-repository"
MODULES: "mod1"
ModuleTable: "test-modules"
StatusTable: "blog-test-status"
LambdaRole: "arn:aws:iam::account-id:role/role-name"
phases:
install:
commands:
- apt-get update
- apt-get -y upgrade
- apt-get install python python-pip build-essential -y
- apt-get install zip unzip -y
- pip install --upgrade pip
- pip install selenium
- pip install awscli
- pip install requests
- pip install boto3
pre_build:
commands:
- python prepare_test.py
build:
commands:
- cd lambda_function
- echo "Packaging Lambda Function..."
- zip -r /tmp/lambda_function.zip ./*
- func_name=`echo $CODEBUILD_BUILD_ID | awk -F ':' '{print $1}'`-phantomjs
- echo "Creating Lambda Function..."
- chmod 777 phantomjs
- |
func_list=`aws lambda list-functions | grep FunctionName | awk -F':' '{print $2}' | tr -d ', "'`
if echo "$func_list" | grep -qw $func_name
then
echo "Lambda function already exists."
else
aws lambda create-function --function-name $func_name --runtime "python2.7" --role $LambdaRole --handler "testsuite.lambda_handler" --zip-file fileb:///tmp/lambda_function.zip --timeout 150 --memory-size 1024 --environment Variables="{WebURL=$WebURL, StatusTable=$StatusTable}" --tags Name=$func_name
fi
- export PhantomJSFunction=$func_name
- cd ../tests/
- python testsuite.py