-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathbuildspec.yml
More file actions
108 lines (103 loc) · 7.39 KB
/
buildspec.yml
File metadata and controls
108 lines (103 loc) · 7.39 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
version: 0.2
phases:
install:
runtime-versions:
python: 3.9
nodejs: 18
golang: 1.21
java: corretto17
commands:
- yum update -y
- pip install --upgrade pip
- if [[ "$BUILD_TYPE" == *"lambda-extension"* || "$BUILD_TYPE" == *"rust"* ]]; then curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y; fi
- if [[ "$BUILD_TYPE" == *"lambda-extension"* || "$BUILD_TYPE" == *"rust"* ]]; then source $HOME/.cargo/env; fi
- if [[ "$BUILD_TYPE" == *"lambda-extension"* || "$BUILD_TYPE" == *"rust"* ]]; then yum install -y zip cmake gcc gcc-c++ make openssl-devel; fi
- if [[ "$BUILD_TYPE" == *"lambda-extension"* || "$BUILD_TYPE" == *"rust"* ]]; then pip install cargo-lambda; fi
- if [[ "$BUILD_TYPE" == *"lambda-extension"* || "$BUILD_TYPE" == *"rust"* ]]; then rustup target add aarch64-unknown-linux-musl; fi
- if [[ "$BUILD_TYPE" == *"lambda-extension"* || "$BUILD_TYPE" == *"rust"* ]]; then rustup target add x86_64-unknown-linux-musl; fi
- pip install aws-sam-cli
- if [[ "$BUILD_TYPE" == *"-stack"* ]]; then pip install -r requirements.txt; fi
- if [[ "$BUILD_TYPE" == *"-stack"* ]]; then npm install -g aws-cdk; fi
- if [[ "$BUILD_TYPE" == *"-stack"* ]]; then node --version; npm --version; cdk --version; fi
build:
commands:
- echo Starting build for ${BUILD_TYPE}
- if [ "$BUILD_TYPE" = "sql-stack" ]; then echo Building SQL Agent Stack; fi
- if [ "$BUILD_TYPE" = "sql-stack" ]; then cdk synth SQLAgentStack --output cdk-templates; fi
- if [ "$BUILD_TYPE" = "sql-stack" ]; then ls -la cdk-templates; fi
- if [ "$BUILD_TYPE" = "lambda-extension" ]; then echo Building Lambda Extension; fi
- if [ "$BUILD_TYPE" = "lambda-extension" ]; then cd lambda/extensions/long-content; fi
- if [ "$BUILD_TYPE" = "lambda-extension" ]; then sed -i 's/^.*strip.*$/\t@echo Skipping strip command for cross-compiled binaries.../' Makefile; fi
- if [ "$BUILD_TYPE" = "lambda-extension" ]; then make build; fi
- if [ "$BUILD_TYPE" = "lambda-extension" ]; then cd ../../..; fi
- if [ "$BUILD_TYPE" = "web-scraper" ]; then echo Building Web Scraper Lambda; fi
- if [ "$BUILD_TYPE" = "web-scraper" ]; then cd lambda/tools/web-scraper; fi
- if [ "$BUILD_TYPE" = "web-scraper" ]; then npm install; fi
- if [ "$BUILD_TYPE" = "web-scraper" ]; then npm run build; fi
- if [ "$BUILD_TYPE" = "web-scraper" ]; then cd ../../..; fi
- if [ "$BUILD_TYPE" = "db-interface" ]; then echo Building DB Interface Lambda; fi
- if [ "$BUILD_TYPE" = "db-interface" ]; then cd lambda/tools/db-interface; fi
- if [ "$BUILD_TYPE" = "db-interface" ]; then pip install -r requirements.txt; fi
- if [ "$BUILD_TYPE" = "db-interface" ]; then cd ../../..; fi
- if [ "$BUILD_TYPE" = "web-scraper-memory" ]; then echo Building WebScraperMemory Lambda; fi
- if [ "$BUILD_TYPE" = "web-scraper-memory" ]; then cd lambda/tools/WebScraperMemory; fi
- if [ "$BUILD_TYPE" = "web-scraper-memory" ]; then cargo lambda build --release --arm64; fi
- if [ "$BUILD_TYPE" = "web-scraper-memory" ]; then cd ../../..; fi
post_build:
commands:
- echo Post-build phase
- AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
- AWS_REGION=$AWS_DEFAULT_REGION
- echo ${AWS_REGION}
- S3_BUCKET="step-functions-agent-artifacts-${AWS_REGION}-${AWS_ACCOUNT_ID}"
- echo ${S3_BUCKET}
- export AWS_ACCOUNT_ID AWS_REGION S3_BUCKET
- echo Checking if bucket exists
- if aws s3 ls "s3://$S3_BUCKET" >/dev/null 2>&1; then echo Bucket exists; else echo Creating bucket; aws s3 mb "s3://$S3_BUCKET" || echo Bucket may already exist; fi
- if [ "$BUILD_TYPE" = "sql-stack" ]; then aws s3api put-object --bucket $S3_BUCKET --key cloudformation/sql-agent/ --content-length 0 || true; fi
- if [ "$BUILD_TYPE" = "sql-stack" ] && [ -d "cdk-templates" ]; then echo Uploading CloudFormation template; aws s3 cp cdk-templates/ s3://${S3_BUCKET}/cloudformation/sql-agent/ --recursive; else if [ "$BUILD_TYPE" = "sql-stack" ]; then echo Template not found; exit 1; fi; fi
- if [ "$BUILD_TYPE" = "sql-stack" ]; then echo CloudFormation template available; fi
- if [ "$BUILD_TYPE" = "lambda-extension" ]; then aws s3api put-object --bucket $S3_BUCKET --key lambda-layers/ --content-length 0 || true; fi
- if [ "$BUILD_TYPE" = "lambda-extension" ]; then cd lambda/extensions/long-content; fi
- if [ "$BUILD_TYPE" = "lambda-extension" ] && [ -f extension-arm.zip ]; then echo Uploading ARM extension; aws s3 cp extension-arm.zip s3://${S3_BUCKET}/lambda-layers/; else if [ "$BUILD_TYPE" = "lambda-extension" ]; then echo ARM zip not found; fi; fi
- if [ "$BUILD_TYPE" = "lambda-extension" ] && [ -f extension-x86.zip ]; then echo Uploading x86 extension; aws s3 cp extension-x86.zip s3://${S3_BUCKET}/lambda-layers/; else if [ "$BUILD_TYPE" = "lambda-extension" ]; then echo x86 zip not found; fi; fi
- if [ "$BUILD_TYPE" = "lambda-extension" ]; then cd ../../..; fi
- if [ "$BUILD_TYPE" = "lambda-extension" ]; then echo Lambda extensions available; fi
- if [ "$BUILD_TYPE" = "web-scraper" ]; then aws s3api put-object --bucket $S3_BUCKET --key lambda/web-scraper/ --content-length 0 || true; fi
- if [ "$BUILD_TYPE" = "web-scraper" ]; then cd lambda/tools/web-scraper; fi
- if [ "$BUILD_TYPE" = "web-scraper" ]; then zip -r lambda.zip dist/; fi
- if [ "$BUILD_TYPE" = "web-scraper" ]; then aws s3 cp lambda.zip s3://${S3_BUCKET}/lambda/web-scraper/lambda.zip; fi
- if [ "$BUILD_TYPE" = "web-scraper" ]; then cd ../../..; fi
- if [ "$BUILD_TYPE" = "web-scraper" ]; then echo Lambda code available; fi
- if [ "$BUILD_TYPE" = "db-interface" ]; then aws s3api put-object --bucket $S3_BUCKET --key lambda/db-interface/ --content-length 0 || true; fi
- if [ "$BUILD_TYPE" = "db-interface" ]; then cd lambda/tools/db-interface; fi
- if [ "$BUILD_TYPE" = "db-interface" ]; then zip -r lambda.zip *.py; fi
- if [ "$BUILD_TYPE" = "db-interface" ]; then aws s3 cp lambda.zip s3://${S3_BUCKET}/lambda/db-interface/lambda.zip; fi
- if [ "$BUILD_TYPE" = "db-interface" ]; then cd ../../..; fi
- if [ "$BUILD_TYPE" = "db-interface" ]; then echo DB interface Lambda code available; fi
- if [ "$BUILD_TYPE" = "web-scraper-memory" ]; then aws s3api put-object --bucket $S3_BUCKET --key lambda/web-scraper-memory/ --content-length 0 || true; fi
- if [ "$BUILD_TYPE" = "web-scraper-memory" ]; then cd lambda/tools/WebScraperMemory; fi
- if [ "$BUILD_TYPE" = "web-scraper-memory" ]; then zip -j lambda.zip target/lambda/release/bootstrap; fi
- if [ "$BUILD_TYPE" = "web-scraper-memory" ]; then aws s3 cp lambda.zip s3://${S3_BUCKET}/lambda/web-scraper-memory/lambda.zip; fi
- if [ "$BUILD_TYPE" = "web-scraper-memory" ]; then cd ../../..; fi
- if [ "$BUILD_TYPE" = "web-scraper-memory" ]; then echo WebScraperMemory code available; fi
artifacts:
files:
- cdk-templates/**/*
- lambda/extensions/long-content/extension-arm.zip
- lambda/extensions/long-content/extension-x86.zip
- lambda/tools/web-scraper/dist/**/*
- lambda/tools/web-scraper/lambda.zip
- lambda/tools/db-interface/lambda.zip
- lambda/tools/WebScraperMemory/lambda.zip
discard-paths: no
base-directory: "."
cache:
paths:
- "/root/.cargo/registry/**/*"
- "/root/.cargo/git/**/*"
- "/root/.cache/pip/**/*"
- "lambda/tools/web-scraper/node_modules/**/*"
- "/root/.cache/go-build/**/*"
- "/go/pkg/mod/**/*"
- "/root/.m2/**/*"