Skip to content

Commit

Permalink
min code coverage 90%
Browse files Browse the repository at this point in the history
 + use ruby v2.6.5 on CircleCI
 + enable SimpleCov during rake build
 + add xcop for verification of xml, xslt, etc files
 + make tests during rake build less verbose
 + define simple road-map in todo.yml
  • Loading branch information
dgroup committed Jan 16, 2020
1 parent 2f66ae0 commit 8f39ac1
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2.1
executors:
ruby:
docker:
- image: circleci/ruby:2.7.0
- image: circleci/ruby:2.6.5

commands:
bundle_install:
Expand Down
4 changes: 2 additions & 2 deletions .simplecov
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if Gem.win_platform? then
SimpleCov.start do
add_filter "/test/"
add_filter "/features/"
minimum_coverage 80
minimum_coverage 90
end
else
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
Expand All @@ -14,6 +14,6 @@ else
SimpleCov.start do
add_filter "/test/"
add_filter "/features/"
minimum_coverage 80
minimum_coverage 90
end
end
30 changes: 21 additions & 9 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,37 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#

require "bundler/gem_tasks"
require "rake/testtask"
require "rubocop/rake_task"
require "fileutils"
require "xcop/rake_task"

task default: %i[cleanup test rubocop xcop]

desc "Run tests"
Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileList["test/**/*_test.rb"]
Dir.glob("test/resources/**/*.db").each { |f| File.delete(f) }
t.verbose = true
t.warning = false
end

RuboCop::RakeTask.new

task default: %i[test rubocop]
task bump: %w[bump:bundler bump:ruby bump:year]
desc "Validate all XML/XSL/XSD/HTML files for formatting"
Xcop::RakeTask.new :xcop do |task|
task.license = "license.txt"
task.includes = %w[**/*.xml **/*.xsl **/*.xsd **/*.html]
task.excludes = %w[target/**/* coverage/**/* wp/**/*]
end

Rake::Task["release"].enhance do
puts "Don't forget to publish the release on GitHub!"
system "open https://github.com/dgroup/vcs4sql/releases"
task :cleanup do
Dir.glob("test/resources/**/*.db").each { |f| File.delete(f) }
end

task bump: %w[bump:bundler bump:ruby bump:year]

namespace :bump do
task :bundler do
version = Gem.latest_version_for("bundler").to_s
Expand All @@ -69,7 +77,11 @@ namespace :bump do
end

task :year do
replace_in_file "license.txt", /\(c\) (\d+)/ => Date.today.year.to_s
sh "grep -q -r '2020-#{Date.today.strftime('%Y')}' \
--include '*.rb' \
--include '*.txt' \
--include 'Rakefile' \
."
end
end

Expand Down
2 changes: 2 additions & 0 deletions test/sqlite_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#

$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
require "simplecov"
SimpleCov.start
require "vcs4sql"
require "sqlite3"
require "active_support"
Expand Down
34 changes: 34 additions & 0 deletions todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# @todo #/DEV Enable Travis CI as second CI server once the project
# became a public. This might be alternative for Circle CI (just in case)

# @todo #/DEV Explain in readme.md how to use the project,
# add more instructions and generic guide.

# @todo #/DEV There a lot of badges in readme which aren't enabled for now.
# Let's enable them.

# @todo #/DEV Publish a gem to the rubygems.org. Add this instructions to the @Rultor.
# No manual actions required.

# @todo #/DEV Migrate to ruby 2.7.0. For now the project has 2.6.5.
# The project is new, it shouldn't be so expensive.

# @todo #/DEV Think about support of Postgres, MySQL, Oracle and others.
# We need to reuse the existing structure as much as we can.
# Most of classes which are oriented on SQLite should be modified.
# The structure of potential upgrade folder might be the following
# ...
# |- lib
# |- test
# |- upgrade
# |- sqlite
# |- 00-define-initial-structure.sql
# |- 02-add-missing-foreign-keys.sql
# |- 03-add-missing-indexes.sql
# |- 99-add.testdata.sql
# |- postgres
# |- ...
# |- mysql
# |- ...
# |- Gemfile
# ...
1 change: 1 addition & 0 deletions vcs4sql.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,5 @@ elegant way without any dependencies on existing frameworks.'
spec.add_development_dependency "rubocop-performance", "1.5.2"
spec.add_development_dependency "ruby-debug-ide", "~> 0.7.0"
spec.add_development_dependency "simplecov", "~> 0.17.1"
spec.add_development_dependency "xcop", "~> 0.6"
end

1 comment on commit 8f39ac1

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 8f39ac1 Jan 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't able to retrieve PDD puzzles from the code base and submit them to GitHub. If you think that it's a bug on our side, please submit it to yegor256/0pdd:

set -x && set -e && set -o pipefail && cd /tmp/0pdd20200116-11-1fms2q6/dgroup/vcs4sql && pdd -v -f /tmp/20200116-15513-aayx2a [1]: + set -e + set -o pipefail + cd /tmp/0pdd20200116-11-1fms2q6/dgroup/vcs4sql + pdd -v -f /tmp/20200116-15513-aayx2a Found 5 lines in...

Please, copy and paste this stack trace to GitHub:

UserError
set -x && set -e && set -o pipefail && cd /tmp/0pdd20200116-11-1fms2q6/dgroup/vcs4sql && pdd -v -f /tmp/20200116-15513-aayx2a [1]:
+ set -e
+ set -o pipefail
+ cd /tmp/0pdd20200116-11-1fms2q6/dgroup/vcs4sql
+ pdd -v -f /tmp/20200116-15513-aayx2a

Found 5 lines in /tmp/0pdd20200116-11-1fms2q6/dgroup/vcs4sql/.pdd
My version is 0.20.5
Ruby version is 2.6.0 at x86_64-linux
Reading .
Excluding target/**/*
Excluding coverage/**/*
47 file(s) found, 174 excluded
Reading bin/console...
Reading bin/setup...
Reading .gitignore...
Reading .rakeTasks...
Reading .gitattributes...
Reading .circleci/config.yml...
Reading .rultor.yml...
Reading .simplecov...
Reading changelog.md...
Reading .prettierignore...
Reading license.txt...
Reading .ruby-version...
Reading .github/ISSUE_TEMPLATE.md...
Reading .github/PULL_REQUEST_TEMPLATE.md...
Reading .github/release-drafter.yml...
Reading .github/CODE_OF_CONDUCT.md...
Reading .github/workflows/push.yml...
Reading .github/ISSUE_TEMPLATE/feature_request.md...
Reading .github/ISSUE_TEMPLATE/bug_report.md...
Reading .github/CONTRIBUTING.md...
Reading vcs4sql.gemspec...
Reading .travis.yml...
Reading readme.md...
Reading Gemfile...
Reading .codeclimate.yml...
Reading .0pdd.yml...
Reading test/sqlite_test.rb...
Reading test/resources/01-upgrade-multiple-statements/01-define-table-structure.sql...
Reading test/resources/01-upgrade-multiple-statements/01-missing-indexes.sql...
Reading test/resources/03-upgrade-failure-due-to-md5sum-mismatch/03-define-table-structure.sql...
Reading test/resources/02-upgrade-with-test-data/02-define-table-structure.sql...
Reading test/resources/02-upgrade-with-test-data/02-define-table-structure.testdata.sql...
Reading test/vcs4sql/version_test.rb...
Reading test/vcs4sql/sqlite/migration_test.rb...
Reading test/support/circleci.rb...
Reading test/support/reporters.rb...
Reading lib/vcs4sql/version.rb...
Reading lib/vcs4sql/exception.rb...
Reading lib/vcs4sql/changelog.rb...
Puzzle DEV-ca77ad7c 0/DEV at lib/vcs4sql/changelog.rb
Puzzle DEV-b327c8c7 0/DEV at lib/vcs4sql/changelog.rb
Reading lib/vcs4sql/sqlite/migration.rb...
Puzzle DEV-20cb5df8 0/DEV at lib/vcs4sql/sqlite/migration.rb
Reading lib/vcs4sql/sqlite/applied.rb...
Puzzle DEV-4e0c8599 0/DEV at lib/vcs4sql/sqlite/applied.rb
Puzzle DEV-41a82912 0/DEV at lib/vcs4sql/sqlite/applied.rb
Reading lib/vcs4sql/sqlite/expected.rb...
Puzzle DEV-b96fff30 0/DEV at lib/vcs4sql/sqlite/expected.rb
Reading lib/vcs4sql.rb...
Reading .pdd...
Reading .rubocop.yml...
Reading todo.yml...
ERROR: todo.yml; puzzle at line #16; Too many leading spaces at 24:2; make sure all lines that include the puzzle body start at position #3.
If you can't understand the cause of this issue or you don't know how to fix it, please submit a GitHub issue, we will try to help you: https://github.com/yegor256/pdd/issues. This tool is still in its beta version and we will appreciate your feedback. Here is where you can find more documentation: https://github.com/yegor256/pdd/blob/master/README.md.
Exit code is 1

/app/objects/git_repo.rb:66:in `rescue in block in xml'
/app/objects/git_repo.rb:63:in `block in xml'
/app/vendor/ruby-2.6.0/lib/ruby/2.6.0/tempfile.rb:295:in `open'
/app/objects/git_repo.rb:62:in `xml'
/app/objects/puzzles.rb:36:in `deploy'
/app/objects/job.rb:38:in `proceed'
/app/objects/job_starred.rb:33:in `proceed'
/app/objects/job_recorded.rb:32:in `proceed'
/app/objects/job_emailed.rb:35:in `proceed'
/app/objects/job_commiterrors.rb:36:in `proceed'
/app/objects/job_detached.rb:48:in `exclusive'
/app/objects/job_detached.rb:36:in `block in proceed'
/app/objects/job_detached.rb:36:in `fork'
/app/objects/job_detached.rb:36:in `proceed'
/app/0pdd.rb:358:in `block in <top (required)>'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.0.4/lib/sinatra/base.rb:1635:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.0.4/lib/sinatra/base.rb:1635:in `block in compile!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.0.4/lib/sinatra/base.rb:992:in `block (3 levels) in route!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.0.4/lib/sinatra/base.rb:1011:in `route_eval'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.0.4/lib/sinatra/base.rb:992:in `block (2 levels) in route!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.0.4/lib/sinatra/base.rb:1040:in `block in process_route'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.0.4/lib/sinatra/base.rb:1038:in `catch'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.0.4/lib/sinatra/base.rb:1038:in `process_route'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.0.4/lib/sinatra/base.rb:990:in `block in route!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.0.4/lib/sinatra/base.rb:989:in `each'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.0.4/lib/sinatra/base.rb:989:in `route!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.0.4/lib/sinatra/base.rb:1097:in `block in dispatch!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.0.4/lib/sinatra/base.rb:1076:in `block in invoke'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.0.4/lib/sinatra/base.rb:1076:in `catch'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.0.4/lib/sinatra/base.rb:1076:in `invoke'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.0.4/lib/sinatra/base.rb:1094:in `dispatch!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.0.4/lib/sinatra/base.rb:924:in `block in call!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.0.4/lib/sinatra/base.rb:1076:in `block in invoke'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.0.4/lib/sinatra/base.rb:1076:in `catch'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.0.4/lib/sinatra/base.rb:1076:in `invoke'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.0.4/lib/sinatra/base.rb:924:in `call!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.0.4/lib/sinatra/base.rb:913:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-protection-2.0.4/lib/rack/protection/xss_header.rb:18:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-protection-2.0.4/lib/rack/protection/path_traversal.rb:16:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-protection-2.0.4/lib/rack/protection/json_csrf.rb:26:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-protection-2.0.4/lib/rack/protection/base.rb:50:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-protection-2.0.4/lib/rack/protection/base.rb:50:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-protection-2.0.4/lib/rack/protection/frame_options.rb:31:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-2.0.6/lib/rack/logger.rb:15:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-2.0.6/lib/rack/common_logger.rb:33:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.0.4/lib/sinatra/base.rb:231:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.0.4/lib/sinatra/base.rb:224:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-2.0.6/lib/rack/head.rb:12:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-2.0.6/lib/rack/method_override.rb:22:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.0.4/lib/sinatra/base.rb:194:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.0.4/lib/sinatra/base.rb:1957:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.0.4/lib/sinatra/base.rb:1502:in `block in call'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.0.4/lib/sinatra/base.rb:1729:in `synchronize'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.0.4/lib/sinatra/base.rb:1502:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-2.0.6/lib/rack/handler/webrick.rb:86:in `service'
/app/vendor/ruby-2.6.0/lib/ruby/2.6.0/webrick/httpserver.rb:140:in `service'
/app/vendor/ruby-2.6.0/lib/ruby/2.6.0/webrick/httpserver.rb:96:in `run'
/app/vendor/ruby-2.6.0/lib/ruby/2.6.0/webrick/server.rb:307:in `block in start_thread'

Please sign in to comment.