2026-06-14 15:55:00 -04:00
|
|
|
version: 0.2
|
|
|
|
|
|
|
|
|
|
env:
|
|
|
|
|
variables:
|
2026-06-14 23:56:50 -04:00
|
|
|
# Runtime versions
|
2026-06-14 15:55:00 -04:00
|
|
|
NODE_VERSION: "18"
|
|
|
|
|
PYTHON_VERSION: "3.9"
|
|
|
|
|
GO_VERSION: "1.21"
|
2026-06-14 23:56:50 -04:00
|
|
|
# Build configuration
|
|
|
|
|
BUILD_ENV: "production"
|
|
|
|
|
RUST_BACKTRACE: "1"
|
2026-06-14 15:55:00 -04:00
|
|
|
|
|
|
|
|
phases:
|
|
|
|
|
install:
|
|
|
|
|
runtime-versions:
|
|
|
|
|
nodejs: 18
|
|
|
|
|
python: 3.9
|
|
|
|
|
golang: 1.21
|
|
|
|
|
commands:
|
|
|
|
|
- echo "Installing build dependencies..."
|
|
|
|
|
|
2026-06-14 23:56:50 -04:00
|
|
|
# Install Rust with error handling
|
|
|
|
|
- |
|
|
|
|
|
if ! command -v rustc &> /dev/null; then
|
|
|
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
|
|
|
|
source $HOME/.cargo/env
|
|
|
|
|
rustup update stable
|
|
|
|
|
fi
|
2026-06-14 15:55:00 -04:00
|
|
|
|
|
|
|
|
# Install AWS CDK globally
|
2026-06-14 23:56:50 -04:00
|
|
|
- npm install -g aws-cdk@latest
|
2026-06-14 15:55:00 -04:00
|
|
|
|
2026-06-14 23:56:50 -04:00
|
|
|
# Verify runtime versions
|
|
|
|
|
- echo "=== Runtime Versions ==="
|
2026-06-14 15:55:00 -04:00
|
|
|
- node --version
|
|
|
|
|
- npm --version
|
|
|
|
|
- python3 --version
|
|
|
|
|
- go version
|
2026-06-14 23:56:50 -04:00
|
|
|
- rustc --version || echo "Rust not available"
|
|
|
|
|
- cdk --version
|
2026-06-14 15:55:00 -04:00
|
|
|
|
|
|
|
|
pre_build:
|
|
|
|
|
commands:
|
2026-06-14 23:56:50 -04:00
|
|
|
- echo "Pre-build phase started on $(date)"
|
2026-06-14 15:55:00 -04:00
|
|
|
|
2026-06-14 23:56:50 -04:00
|
|
|
# Install React dependencies with clean install
|
2026-06-14 15:55:00 -04:00
|
|
|
- echo "Installing React dependencies..."
|
2026-06-14 23:56:50 -04:00
|
|
|
- npm ci --prefer-offline --no-audit
|
2026-06-14 15:55:00 -04:00
|
|
|
|
|
|
|
|
# Install Python dependencies for Lambda functions
|
2026-06-14 23:56:50 -04:00
|
|
|
- |
|
|
|
|
|
if [ -d "functions/python" ] && [ -f "functions/python/requirements.txt" ]; then
|
|
|
|
|
echo "Installing Python dependencies..."
|
|
|
|
|
cd functions/python
|
|
|
|
|
pip3 install -r requirements.txt --target . --upgrade --no-cache-dir
|
|
|
|
|
cd ../..
|
|
|
|
|
else
|
|
|
|
|
echo "No Python Lambda function found, skipping..."
|
|
|
|
|
fi
|
2026-06-14 15:55:00 -04:00
|
|
|
|
|
|
|
|
# Download Go dependencies
|
2026-06-14 23:56:50 -04:00
|
|
|
- |
|
|
|
|
|
if [ -d "functions/go" ] && [ -f "functions/go/go.mod" ]; then
|
|
|
|
|
echo "Downloading Go dependencies..."
|
|
|
|
|
cd functions/go
|
|
|
|
|
go mod download
|
|
|
|
|
go mod verify
|
|
|
|
|
cd ../..
|
|
|
|
|
else
|
|
|
|
|
echo "No Go Lambda function found, skipping..."
|
|
|
|
|
fi
|
2026-06-14 15:55:00 -04:00
|
|
|
|
|
|
|
|
# Check Rust dependencies
|
2026-06-14 23:56:50 -04:00
|
|
|
- |
|
|
|
|
|
if [ -d "functions/rust" ] && [ -f "functions/rust/Cargo.toml" ]; then
|
|
|
|
|
echo "Checking Rust dependencies..."
|
|
|
|
|
cd functions/rust
|
|
|
|
|
cargo check --release
|
|
|
|
|
cd ../..
|
|
|
|
|
else
|
|
|
|
|
echo "No Rust Lambda function found, skipping..."
|
|
|
|
|
fi
|
2026-06-14 15:55:00 -04:00
|
|
|
|
|
|
|
|
build:
|
|
|
|
|
commands:
|
2026-06-14 23:56:50 -04:00
|
|
|
- echo "Build phase started on $(date)"
|
|
|
|
|
|
|
|
|
|
# Run linting and code quality checks early
|
|
|
|
|
- |
|
|
|
|
|
if [ -f "package.json" ] && grep -q '"lint"' package.json; then
|
|
|
|
|
echo "Running code quality checks..."
|
|
|
|
|
npm run lint
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Run tests before building
|
|
|
|
|
- |
|
|
|
|
|
if [ -f "package.json" ] && grep -q '"test"' package.json; then
|
|
|
|
|
echo "Running tests..."
|
|
|
|
|
npm test -- --coverage --ci --testResultsProcessor="jest-junit" --watchAll=false
|
|
|
|
|
fi
|
2026-06-14 15:55:00 -04:00
|
|
|
|
|
|
|
|
# Build React application
|
|
|
|
|
- echo "Building React application..."
|
|
|
|
|
- npm run build
|
|
|
|
|
|
2026-06-14 23:56:50 -04:00
|
|
|
# Build Lambda functions in parallel where possible
|
|
|
|
|
- echo "Building Lambda functions..."
|
|
|
|
|
|
2026-06-14 15:55:00 -04:00
|
|
|
# Build Go Lambda function
|
2026-06-14 23:56:50 -04:00
|
|
|
- |
|
|
|
|
|
if [ -d "functions/go" ]; then
|
|
|
|
|
echo "Building Go Lambda function..."
|
|
|
|
|
cd functions/go
|
|
|
|
|
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s -w" -o bootstrap main.go
|
|
|
|
|
zip -9 go-lambda.zip bootstrap
|
|
|
|
|
cd ../..
|
|
|
|
|
fi
|
2026-06-14 15:55:00 -04:00
|
|
|
|
|
|
|
|
# Build Rust Lambda function
|
|
|
|
|
- |
|
2026-06-14 23:56:50 -04:00
|
|
|
if [ -d "functions/rust" ]; then
|
|
|
|
|
echo "Building Rust Lambda function..."
|
|
|
|
|
cd functions/rust
|
|
|
|
|
if command -v cargo-lambda &> /dev/null; then
|
|
|
|
|
cargo lambda build --release
|
|
|
|
|
else
|
|
|
|
|
cargo install cargo-lambda
|
|
|
|
|
cargo lambda build --release
|
|
|
|
|
fi
|
|
|
|
|
cd ../..
|
2026-06-14 15:55:00 -04:00
|
|
|
fi
|
|
|
|
|
|
2026-06-14 23:56:50 -04:00
|
|
|
# Package Python Lambda function
|
2026-06-14 15:55:00 -04:00
|
|
|
- |
|
2026-06-14 23:56:50 -04:00
|
|
|
if [ -d "functions/python" ]; then
|
|
|
|
|
echo "Packaging Python Lambda function..."
|
|
|
|
|
cd functions/python
|
|
|
|
|
zip -r9 ../python-lambda.zip . -x "*.pyc" "__pycache__/*" "*.git*" "*.DS_Store*"
|
|
|
|
|
cd ../..
|
2026-06-14 15:55:00 -04:00
|
|
|
fi
|
2026-06-14 23:56:50 -04:00
|
|
|
|
|
|
|
|
# Build CDK infrastructure
|
|
|
|
|
- echo "Synthesizing CDK infrastructure..."
|
|
|
|
|
- npx cdk synth --all
|
2026-06-14 15:55:00 -04:00
|
|
|
|
|
|
|
|
post_build:
|
|
|
|
|
commands:
|
2026-06-14 23:56:50 -04:00
|
|
|
- echo "Post-build phase started on $(date)"
|
2026-06-14 15:55:00 -04:00
|
|
|
|
|
|
|
|
# Create deployment package structure
|
2026-06-14 23:56:50 -04:00
|
|
|
- mkdir -p dist/{react,lambdas,infrastructure}
|
2026-06-14 15:55:00 -04:00
|
|
|
|
|
|
|
|
# Copy React build artifacts
|
2026-06-14 23:56:50 -04:00
|
|
|
- |
|
|
|
|
|
if [ -d "build" ]; then
|
|
|
|
|
cp -r build/* dist/react/
|
|
|
|
|
else
|
|
|
|
|
echo "No React build directory found"
|
|
|
|
|
fi
|
2026-06-14 15:55:00 -04:00
|
|
|
|
|
|
|
|
# Copy Lambda function packages
|
|
|
|
|
- |
|
2026-06-14 23:56:50 -04:00
|
|
|
[ -f "functions/go/go-lambda.zip" ] && cp functions/go/go-lambda.zip dist/lambdas/
|
|
|
|
|
[ -f "functions/python-lambda.zip" ] && cp functions/python-lambda.zip dist/lambdas/
|
|
|
|
|
[ -f "functions/rust/target/lambda/rust-lambda/bootstrap.zip" ] && cp functions/rust/target/lambda/rust-lambda/bootstrap.zip dist/lambdas/rust-lambda.zip
|
2026-06-14 15:55:00 -04:00
|
|
|
|
|
|
|
|
# Copy CDK synthesized templates
|
2026-06-14 23:56:50 -04:00
|
|
|
- |
|
|
|
|
|
if [ -d "cdk.out" ]; then
|
|
|
|
|
cp -r cdk.out/* dist/infrastructure/
|
|
|
|
|
fi
|
2026-06-14 15:55:00 -04:00
|
|
|
|
2026-06-14 23:56:50 -04:00
|
|
|
# Generate build metadata
|
|
|
|
|
- |
|
|
|
|
|
cat > dist/build-info.json << EOF
|
|
|
|
|
{
|
|
|
|
|
"buildTime": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
|
|
|
|
|
"commitHash": "${CODEBUILD_RESOLVED_SOURCE_VERSION:-unknown}",
|
|
|
|
|
"buildId": "${CODEBUILD_BUILD_ID:-unknown}",
|
|
|
|
|
"projectName": "${CODEBUILD_BUILD_PROJECT_NAME:-unknown}",
|
|
|
|
|
"buildNumber": "${CODEBUILD_BUILD_NUMBER:-unknown}"
|
|
|
|
|
}
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
- echo "Build completed successfully on $(date)"
|
2026-06-14 15:55:00 -04:00
|
|
|
|
|
|
|
|
reports:
|
|
|
|
|
jest_reports:
|
|
|
|
|
files:
|
|
|
|
|
- junit.xml
|
|
|
|
|
base-directory: .
|
|
|
|
|
file-format: JUNITXML
|
|
|
|
|
coverage_reports:
|
|
|
|
|
files:
|
|
|
|
|
- clover.xml
|
|
|
|
|
base-directory: coverage
|
|
|
|
|
file-format: CLOVERXML
|
|
|
|
|
|
|
|
|
|
artifacts:
|
|
|
|
|
files:
|
|
|
|
|
- '**/*'
|
|
|
|
|
base-directory: dist
|
2026-06-14 23:56:50 -04:00
|
|
|
name: personal-site-build-$CODEBUILD_BUILD_NUMBER
|
2026-06-14 15:55:00 -04:00
|
|
|
|
|
|
|
|
cache:
|
|
|
|
|
paths:
|
|
|
|
|
- node_modules/**/*
|
|
|
|
|
- ~/.npm/**/*
|
|
|
|
|
- ~/.cache/pip/**/*
|
2026-06-14 23:56:50 -04:00
|
|
|
- ~/.cargo/**/*
|
|
|
|
|
- functions/go/go.mod
|
|
|
|
|
- functions/go/go.sum
|
|
|
|
|
- functions/rust/target/**/*
|