Skip to content
Closed
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
29 changes: 29 additions & 0 deletions .github/workflows/code-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Code Analysis

on:
pull_request:

jobs:
static_analysis:
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Set Up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build Docker Image
run: docker build -t code-analysis -f Dockerfile.analysis .

- name: Run Code Analysis
run: |
mkdir -p reports
docker run --rm -v $(pwd)/reports:/app/reports code-analysis

- name: Upload Reports
uses: actions/upload-artifact@v4
with:
name: code-analysis-reports
path: reports/
25 changes: 25 additions & 0 deletions Dockerfile.analysis
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use the base Ruby 3.4 image
FROM ruby:3.4

# Set working directory
WORKDIR /app

# Install dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
&& rm -rf /var/lib/apt/lists/*

# Install Bundler (latest version compatible with Ruby 3.4)
RUN gem install rubycritic skunk

# Copy the entrypoint script
COPY entrypoint.rb /entrypoint.rb

# Set execute permissions
RUN chmod +x /entrypoint.rb

VOLUME ["/app"]

# Set the Ruby script as the entrypoint
ENTRYPOINT ["ruby", "/entrypoint.rb"]
36 changes: 36 additions & 0 deletions entrypoint.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env ruby

# Get arguments passed to the container
commands = ARGV

def run_rubycritic
system("rubycritic -p reports/rubycritic")
end

def run_skunk
system("skunk -o reports/skunk.txt")
end

# Default behavior: Run both tools if no args are provided
if commands.empty?
puts "No arguments provided. Running both RubyCritic and Skunk..."
run_rubycritic
run_skunk
exit 0
end

# Execute based on provided arguments
commands.each do |command|
case command
when "rubycritic"
puts "Running RubyCritic..."
run_rubycritic
when "skunk"
puts "Running Skunk..."
run_skunk
else
puts "Invalid argument: #{command}"
puts "Usage: docker run --rm <image> [rubycritic] [skunk]"
exit 1
end
end
Loading