File tree Expand file tree Collapse file tree 3 files changed +82
-0
lines changed
Expand file tree Collapse file tree 3 files changed +82
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Code Analysis
2+
3+ on :
4+ pull_request :
5+
6+ jobs :
7+ static_analysis :
8+ runs-on : ubuntu-latest
9+
10+ steps :
11+ - name : Checkout Code
12+ uses : actions/checkout@v3
13+
14+ - name : Set Up Docker Buildx
15+ uses : docker/setup-buildx-action@v2
16+
17+ - name : Build Docker Image
18+ run : docker build -t code-analysis -f Dockerfile .
19+
20+ - name : Run Code Analysis
21+ run : |
22+ mkdir -p reports
23+ docker run --rm -v $(pwd)/reports:/app/reports code-analysis
24+
25+ - name : Upload Reports
26+ uses : actions/upload-artifact@v3
27+ with :
28+ name : code-analysis-reports
29+ path : reports/
Original file line number Diff line number Diff line change 1+ # Use the base Ruby 3.4 image
2+ FROM ruby:3.4
3+
4+ # Set working directory
5+ WORKDIR /app
6+
7+ # Install dependencies
8+ RUN apt-get update && apt-get install -y \
9+ git \
10+ curl \
11+ && rm -rf /var/lib/apt/lists/*
12+
13+ # Install Bundler (latest version compatible with Ruby 3.4)
14+ RUN gem install rubycritic skunk
15+
16+ # Copy the entrypoint script
17+ COPY entrypoint.rb /entrypoint.rb
18+
19+ # Set execute permissions
20+ RUN chmod +x /entrypoint.rb
21+
22+ VOLUME ["/app"]
23+
24+ # Set the Ruby script as the entrypoint
25+ ENTRYPOINT ["ruby", "/entrypoint.rb"]
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env ruby
2+
3+ # Get arguments passed to the container
4+ commands = ARGV
5+
6+ # Default behavior: Run both tools if no args are provided
7+ if commands . empty?
8+ puts "No arguments provided. Running both RubyCritic and Skunk..."
9+ system ( "rubycritic" )
10+ system ( "skunk -o skunk.txt" )
11+ exit 0
12+ end
13+
14+ # Execute based on provided arguments
15+ commands . each do |command |
16+ case command
17+ when "rubycritic"
18+ puts "Running RubyCritic..."
19+ system ( "rubycritic" )
20+ when "skunk"
21+ puts "Running Skunk..."
22+ system ( "skunk -o skunk.txt" )
23+ else
24+ puts "Invalid argument: #{ command } "
25+ puts "Usage: docker run --rm <image> [rubycritic] [skunk]"
26+ exit 1
27+ end
28+ end
You can’t perform that action at this time.
0 commit comments