Skip to content

Commit

Permalink
add sonarcloud config to main flow
Browse files Browse the repository at this point in the history
  • Loading branch information
lytrungtin committed Dec 29, 2022
1 parent ef11d73 commit e43ea7b
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 63 deletions.
58 changes: 0 additions & 58 deletions .github/workflows/brakeman.yml

This file was deleted.

19 changes: 17 additions & 2 deletions .github/workflows/main_flow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,22 @@ jobs:
run: bin/rails db:schema:load
# Add or replace test runners here
- name: Run tests
run: bin/rake test
run: bin/rake
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args:
-Dsonar.projectKey=lytrungtin_url_shortener
-Dsonar.organization=lytrungtin
-Dsonar.exclusions=/vendor/**
-Dsonar.java.file.suffixes=-
-Dsonar.c.file.suffixes=-
-Dsonar.cpp.file.suffixes=-
-Dsonar.objc.file.suffixes=-
-Dsonar.ruby.coverage.reportPaths=/home/runner/work/url_shortener/url_shortener/coverage/.resultset.json
lint:
runs-on: ubuntu-latest
steps:
Expand All @@ -54,4 +69,4 @@ jobs:
- name: Security audit application code
run: bundle exe brakeman -q -w2
- name: Lint Ruby files
run: bundle exec rubocop --parallel
run: bundle exec rubocop -A --parallel --require rubocop-rails
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ group :development, :test do
gem 'rubocop'
gem 'rubocop-rails'
gem 'rubocop-rake'
gem 'simplecov', require: false, group: :test
gem 'simplecov', group: :test
end
5 changes: 5 additions & 0 deletions test/controllers/redirection_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ class RedirectionControllerTest < ActionDispatch::IntegrationTest
assert_response :not_found
end

test 'access with invalid slug format should render to not found' do
get shortened_url(slug: 'te@@st')
assert_response :not_found
end

test 'access with not existed slug should render to not found' do
get shortened_url(slug: '1a2b3c')
assert_response :not_found
Expand Down
11 changes: 9 additions & 2 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@
ENV['RAILS_ENV'] ||= 'test'
require 'simplecov'
require 'simplecov_json_formatter'
SimpleCov.formatter = SimpleCov::Formatter::JSONFormatter
SimpleCov.start

# Generate HTML and JSON reports
SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new([
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::JSONFormatter
])
SimpleCov.start do
enable_coverage :branch
end
require_relative '../config/environment'
require 'rails/test_help'

Expand Down

0 comments on commit e43ea7b

Please sign in to comment.