Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: CI/CD Pipeline

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
lint-and-test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
bundler-cache: true

- name: Install dependencies
run: bundle install

- name: Run linter (Standard Ruby)
run: bundle exec rake standard

- name: Run tests
run: bundle exec rake test

- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results
path: |
coverage/
tmp/
retention-days: 7

validate-sam-template:
runs-on: ubuntu-latest
needs: lint-and-test

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
bundler-cache: true

- name: Set up AWS SAM CLI
uses: aws-actions/setup-sam@v2

- name: Validate SAM template
run: sam validate --template template.yaml

- name: Build SAM application
run: sam build --template template.yaml

- name: Upload SAM build artifacts
uses: actions/upload-artifact@v4
with:
name: sam-build-artifacts
path: .aws-sam/
retention-days: 7

# Deploy job is temporarily disabled for initial testing
# Will be enabled after manual deployment verification
# deploy:
# runs-on: ubuntu-latest
# needs: [lint-and-test, validate-sam-template]
# if: github.ref == 'refs/heads/main' && github.event_name == 'push'
# environment: production
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
# - name: Set up Ruby
# uses: ruby/setup-ruby@v1
# with:
# ruby-version: '3.3'
# bundler-cache: true
# - name: Set up AWS SAM CLI
# uses: aws-actions/setup-sam@v2
# - name: Configure AWS credentials
# uses: aws-actions/configure-aws-credentials@v4
# with:
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# aws-region: ap-northeast-1
# - name: Deploy to AWS
# run: |
# sam deploy \
# --template-file .aws-sam/build/template.yaml \
# --stack-name smalruby-infra-prod \
# --parameter-overrides Stage=prod \
# --capabilities CAPABILITY_IAM \
# --no-confirm-changeset \
# --no-fail-on-empty-changeset
4 changes: 4 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@ end
desc "Run all tests"
RSpec::Core::RakeTask.new(:test) do |t|
t.pattern = "spec/**/*_spec.rb"
# Set CI environment variable to prevent lambda_handler redefinition warnings
ENV["CI"] = "true"
end

desc "Run Lambda function tests only"
RSpec::Core::RakeTask.new("test:lambda") do |t|
t.pattern = "spec/lambda/*_spec.rb"
# Set CI environment variable to prevent lambda_handler redefinition warnings
ENV["CI"] = "true"
end

desc "Run lint and tests"
Expand Down
6 changes: 4 additions & 2 deletions lambda/cors-for-smalruby/lambda_function.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ def self.lambda_handler(event:, context:)
end

# AWS Lambda entry point
def lambda_handler(event:, context:)
CorsForSmalruby.lambda_handler(event: event, context: context)
unless ENV["CI"] == "true"
def lambda_handler(event:, context:)
CorsForSmalruby.lambda_handler(event: event, context: context)
end
end
6 changes: 4 additions & 2 deletions lambda/smalruby-cors-proxy/lambda_function.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ def self.is_binary_content?(content_type)
end

# AWS Lambda entry point
def lambda_handler(event:, context:)
SmalrubyCorsProxy.lambda_handler(event: event, context: context)
unless ENV["CI"] == "true"
def lambda_handler(event:, context:)
SmalrubyCorsProxy.lambda_handler(event: event, context: context)
end
end
6 changes: 4 additions & 2 deletions lambda/smalruby-mesh-zone-get/lambda_function.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def self.lambda_handler(event:, context:)
end

# AWS Lambda entry point
def lambda_handler(event:, context:)
SmalrubyMeshZoneGet.lambda_handler(event: event, context: context)
unless ENV["CI"] == "true"
def lambda_handler(event:, context:)
SmalrubyMeshZoneGet.lambda_handler(event: event, context: context)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ def self.lambda_handler(event:, context:)
end

# AWS Lambda entry point
def lambda_handler(event:, context:)
SmalrubyScratchApiProxyGetProjectInfo.lambda_handler(event: event, context: context)
unless ENV["CI"] == "true"
def lambda_handler(event:, context:)
SmalrubyScratchApiProxyGetProjectInfo.lambda_handler(event: event, context: context)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ def self.lambda_handler(event:, context:)
end

# AWS Lambda entry point
def lambda_handler(event:, context:)
SmalrubyScratchApiProxyTranslate.lambda_handler(event: event, context: context)
unless ENV["CI"] == "true"
def lambda_handler(event:, context:)
SmalrubyScratchApiProxyTranslate.lambda_handler(event: event, context: context)
end
end
4 changes: 2 additions & 2 deletions spec/lambda/smalruby_mesh_zone_get_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
end

it "generates consistent domain for same IP" do
result1 = lambda_handler(event: event, context: context)
result2 = lambda_handler(event: event, context: context)
result1 = SmalrubyMeshZoneGet.lambda_handler(event: event, context: context)
result2 = SmalrubyMeshZoneGet.lambda_handler(event: event, context: context)

body1 = JSON.parse(result1[:body])
body2 = JSON.parse(result2[:body])
Expand Down
Loading