Skip to content
Open
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
23 changes: 20 additions & 3 deletions .github/workflows/TestPR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,25 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Clear Ruby cache
run: |
rm -rf ~/.ruby-version
rm -rf ~/.rbenv
rm -rf ~/.rvm
rm -rf /usr/local/rvm
rm -rf /opt/ruby

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2.7
bundler-cache: true
ruby-version: 3.4.5
bundler-cache: false

- name: Check Ruby Version
run: |
ruby -v
which ruby
gem env

- name: Setup Node.js
uses: actions/setup-node@v3
Expand All @@ -45,7 +59,10 @@ jobs:
run: |
gem update --system
gem install bundler:2.4.7
bundle install
bundle config set --local deployment 'false'
bundle config set --local without ''
bundle config set --local force_ruby_platform true
bundle install --verbose
- name: Setup database
run: |
bundle exec rails db:create RAILS_ENV=test
Expand Down
27 changes: 24 additions & 3 deletions .github/workflows/danger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,36 @@ jobs:
with:
fetch-depth: 0

- name: Clear Ruby cache
run: |
rm -rf ~/.ruby-version
rm -rf ~/.rbenv
rm -rf ~/.rvm
rm -rf /usr/local/rvm
rm -rf /opt/ruby

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2.7'
ruby-version: '3.4.5'
bundler-cache: false

- name: Check Ruby Version
run: |
ruby -v
which ruby
gem env

- name: Install dependencies
run: bundle install
run: |
gem update --system
gem install bundler:2.4.7
bundle config set --local deployment 'false'
bundle config set --local without ''
bundle config set --local force_ruby_platform true
bundle install --verbose

- name: Run Danger
env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: bundle exec danger --verbose
run: bundle exec danger --verbose
24 changes: 19 additions & 5 deletions .github/workflows/danger_target.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,40 @@ name: Danger
on:
pull_request_target:
types: [opened, synchronize, reopened]

jobs:
danger:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: Remove .ruby-version if exists
run: |
if [ -f .ruby-version ]; then
echo "Removing .ruby-version file"
rm .ruby-version
fi

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2.7'

- name: Install dependencies
run: bundle install
ruby-version: '3.4.5'
bundler-cache: true

- name: Verify Ruby Version
run: |
echo "Ruby version:"
ruby -v
echo "Ruby path:"
which ruby
echo "Gem environment:"
gem env

- name: Run Danger
env:
Expand Down
92 changes: 79 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,25 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Clear Ruby cache
run: |
rm -rf ~/.ruby-version
rm -rf ~/.rbenv
rm -rf ~/.rvm
rm -rf /usr/local/rvm
rm -rf /opt/ruby

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2.7
bundler-cache: true
ruby-version: 3.4.5
bundler-cache: false

- name: Check Ruby Version
run: |
ruby -v
which ruby
gem env

- name: Setup Node.js
uses: actions/setup-node@v3
Expand All @@ -47,33 +61,86 @@ jobs:
run: |
gem update --system
gem install bundler:2.4.7
bundle install
bundle config set --local deployment 'false'
bundle config set --local without ''
bundle config set --local force_ruby_platform true
bundle install --verbose

- name: Setup database
run: |
bundle exec rails db:create RAILS_ENV=test
bundle exec rails db:schema:load RAILS_ENV=test

- name: Set up code climate test-reporter
- name: Set up code coverage
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter before-build
echo "SimpleCov coverage reporting is configured in spec_helper.rb"

- name: Run model tests
run: bundle exec rspec spec/models

- name: Run controller tests
run: bundle exec rspec spec/requests/

- name: Format code coverage report
run: ./cc-test-reporter format-coverage -t simplecov -o "coverage/codeclimate.models.json" --debug
- name: Generate coverage report
run: |
echo "Coverage report generated in coverage/index.html"
ls -la coverage/ || echo "No coverage directory found"
if [ -f coverage/index.html ]; then
echo "✅ Coverage report generated successfully"
echo "📊 Coverage percentage:"
grep -o '[0-9]\+\.[0-9]\+%' coverage/index.html | head -1 || echo "Coverage percentage not found"
else
echo "❌ Coverage report not generated"
fi

- name: Upload coverage artifacts
uses: actions/upload-artifact@v4
with:
name: code-coverage-artifacts
path: coverage/

- name: Comment coverage on PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const path = require('path');

try {
// Read coverage data
const coveragePath = 'coverage/coverage.json';
if (fs.existsSync(coveragePath)) {
const coverage = JSON.parse(fs.readFileSync(coveragePath, 'utf8'));
const percentage = coverage.metrics.covered_percent.toFixed(2);

const comment = `## 📊 Code Coverage Report

**Coverage: ${percentage}%**

- **Lines covered:** ${coverage.metrics.covered_lines}/${coverage.metrics.total_lines}
- **Branches covered:** ${coverage.metrics.covered_branches}/${coverage.metrics.total_branches}

📈 Coverage report generated with SimpleCov and Ruby 3.4.5

<details>
<summary>View detailed coverage report</summary>

Coverage artifacts are available in the workflow run.
</details>`;

github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
} else {
console.log('Coverage file not found');
}
} catch (error) {
console.log('Error creating coverage comment:', error.message);
}


publish_code_coverage:
Expand All @@ -91,10 +158,9 @@ jobs:
- name: Upload code-coverage report to code-climate
run: |
export GIT_BRANCH="${GITHUB_REF/refs\/heads\//}"
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter sum-coverage coverage/codeclimate.*.json
./cc-test-reporter after-build -t simplecov -r ${{ secrets.CC_TEST_REPORTER_ID }}
gem install codeclimate-test-reporter
cc-test-reporter sum-coverage coverage/codeclimate.*.json
cc-test-reporter after-build -t simplecov -r ${{ secrets.CC_TEST_REPORTER_ID }}

docker:
needs: test
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby-3.2.7
ruby-3.4.5
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ruby:3.2.7
FROM ruby:3.4.5

LABEL maintainer="Ankur Mundra <[email protected]>"
# Install dependencies
Expand Down
24 changes: 21 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '3.2.7'
ruby '3.4.5'

gem 'mysql2', '~> 0.5.5'
gem 'puma', '~> 5.0'
gem 'mysql2', '~> 0.5.7'
gem 'sqlite3', '~> 1.4' # Alternative for development
gem 'puma', '~> 6.0'
gem 'rails', '~> 8.0', '>= 8.0.1'
gem 'mini_portile2', '~> 2.8' # Helps with native gem compilation
gem 'observer' # Required for Ruby 3.4.5 compatibility with Rails 8.0
gem 'mutex_m' # Required for Ruby 3.4.5 compatibility
gem 'faraday-retry' # Required for Faraday v2.0+ compatibility
gem 'bigdecimal' # Required for Ruby 3.4.5 compatibility
gem 'csv' # Required for Ruby 3.4.5 compatibility
gem 'date' # Required for Ruby 3.4.5 compatibility
gem 'delegate' # Required for Ruby 3.4.5 compatibility
gem 'forwardable' # Required for Ruby 3.4.5 compatibility
gem 'logger' # Required for Ruby 3.4.5 compatibility
gem 'monitor' # Required for Ruby 3.4.5 compatibility
gem 'ostruct' # Required for Ruby 3.4.5 compatibility
gem 'set' # Required for Ruby 3.4.5 compatibility
gem 'singleton' # Required for Ruby 3.4.5 compatibility
gem 'timeout' # Required for Ruby 3.4.5 compatibility
gem 'uri' # Required for Ruby 3.4.5 compatibility
gem 'rswag-api'
gem 'rswag-ui'
gem 'active_model_serializers', '~> 0.10.0'
gem 'psych', '~> 5.2' # Ensure compatible psych version for Ruby 3.4.5

# Build JSON APIs with ease [https://github.com/rails/jbuilder]
# gem "jbuilder"
Expand Down
14 changes: 7 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,13 @@ GEM
net-protocol
netrc (0.11.0)
nio4r (2.5.9)
nokogiri (1.15.2-aarch64-linux)
nokogiri (1.18.10-aarch64-linux-gnu)
racc (~> 1.4)
nokogiri (1.15.2-arm64-darwin)
nokogiri (1.18.10-arm64-darwin)
racc (~> 1.4)
nokogiri (1.15.2-x64-mingw-ucrt)
nokogiri (1.18.10-x64-mingw-ucrt)
racc (~> 1.4)
nokogiri (1.15.2-x86_64-linux)
nokogiri (1.18.10-x86_64-linux-gnu)
racc (~> 1.4)
octokit (10.0.0)
faraday (>= 1, < 3)
Expand All @@ -233,7 +233,7 @@ GEM
date
stringio
public_suffix (5.0.3)
puma (5.6.6)
puma (6.6.1)
nio4r (~> 2.0)
racc (1.7.1)
rack (2.2.8)
Expand Down Expand Up @@ -390,7 +390,7 @@ DEPENDENCIES
jwt (~> 2.7, >= 2.7.1)
lingua
mysql2 (~> 0.5.5)
puma (~> 5.0)
puma (~> 6.0)
rack-cors
rails (~> 8.0, >= 8.0.1)
rspec-rails
Expand All @@ -405,7 +405,7 @@ DEPENDENCIES
tzinfo-data

RUBY VERSION
ruby 3.2.7p253
ruby 3.4.5p0

BUNDLED WITH
2.4.14
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ application up and running.

Things you may want to cover:

* Ruby version - 3.2.1
* Ruby version - 3.4.5

## Development Environment

Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.1'

services:
app:
build: .
Expand Down
Loading