diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..e6d21fb --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: ezekg \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..f91af41 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,27 @@ +name: CI +on: + push: + branches: + - master + pull_request: + branches: + - master +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + ruby: + - '3.3' + - '3.2' + - '3.1' + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{matrix.ruby}} + bundler-cache: true + - name: Test + run: bundle exec rake test diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..746c4cd --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +/.bundle/ +/doc/ +/log/*.log +/pkg/ +/tmp/ +/test/dummy/db/*.sqlite3 +/test/dummy/db/*.sqlite3-* +/test/dummy/log/*.log +/test/dummy/storage/ +/test/dummy/tmp/ +.rspec_status +Gemfile.lock +*.gem +*.log diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..34c5164 --- /dev/null +++ b/.rspec @@ -0,0 +1,3 @@ +--format documentation +--color +--require spec_helper diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..1a58814 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +# Changelog + +## [Unreleased] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..32637dd --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,33 @@ +## Security issues + +If you have found a security related issue, please do not file an issue on +GitHub or send a PR addressing the issue. Contact [Keygen](mailto:security@keygen.sh) +directly. You will be given public credit for your disclosure. + +## Reporting issues + +Please try to answer the following questions in your bug report: + +- What did you do? +- What did you expect to happen? +- What happened instead? + +Make sure to include as much relevant information as possible. Ruby version, +Rails version, `verbose_migrations` version, OS version and any stack traces +you have are very valuable. + +## Pull Requests + +- **Add tests!** Your patch won't be accepted if it doesn't have tests. + +- **Document any change in behaviour**. Make sure the README and any other + relevant documentation are kept up-to-date. + +- **Create topic branches**. Please don't ask us to pull from your master branch. + +- **One pull request per feature**. If you want to do more than one thing, send + multiple pull requests. + +- **Send coherent history**. Make sure each individual commit in your pull + request is meaningful. If you had to make multiple intermediate commits while + developing, please squash them before sending them to us. diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..ec328ef --- /dev/null +++ b/Gemfile @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +source "https://rubygems.org" + +# Specify your gem's dependencies in verbose_migrations.gemspec +gemspec + +gem "rake", "~> 13.0" + +gem "rspec", "~> 3.0" diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f56ff19 --- /dev/null +++ b/LICENSE @@ -0,0 +1,20 @@ +Copyright 2024 Keygen LLC + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..56e73c9 --- /dev/null +++ b/README.md @@ -0,0 +1,31 @@ +# VerboseMigrations + +TODO: Delete this and the text below, and describe your gem + +Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/verbose_migrations`. To experiment with that code, run `bin/console` for an interactive prompt. + +## Installation + +TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org. + +Install the gem and add to the application's Gemfile by executing: + + $ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG + +If bundler is not being used to manage dependencies, install the gem by executing: + + $ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG + +## Usage + +TODO: Write usage instructions here + +## Development + +After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. + +To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org). + +## Contributing + +Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/verbose_migrations. diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..bf891d9 --- /dev/null +++ b/Rakefile @@ -0,0 +1,7 @@ +require 'bundler/gem_tasks' +require 'rspec/core/rake_task' + +RSpec::Core::RakeTask.new(:spec) +task test: :spec + +task default: :test diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..8a5a1d6 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,8 @@ +# Security Policy + +## Reporting a vulnerability + +If you find a vulnerability in `verbose_migrations`, please contact Keygen via +[email](mailto:security@keygen.sh). + +You will be given public credit for your disclosure. diff --git a/bin/console b/bin/console new file mode 100755 index 0000000..5d4c3b3 --- /dev/null +++ b/bin/console @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require "bundler/setup" +require "verbose_migrations" + +# You can add fixtures and/or initialization code here to make experimenting +# with your gem easier. You can also use a different console, if you like. + +require "irb" +IRB.start(__FILE__) diff --git a/bin/setup b/bin/setup new file mode 100755 index 0000000..dce67d8 --- /dev/null +++ b/bin/setup @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -euo pipefail +IFS=$'\n\t' +set -vx + +bundle install + +# Do any other automated setup that you need to do here diff --git a/lib/verbose_migrations.rb b/lib/verbose_migrations.rb new file mode 100644 index 0000000..f1103ba --- /dev/null +++ b/lib/verbose_migrations.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +require_relative 'verbose_migrations/version' + +module VerboseMigrations +end diff --git a/lib/verbose_migrations/version.rb b/lib/verbose_migrations/version.rb new file mode 100644 index 0000000..c11f063 --- /dev/null +++ b/lib/verbose_migrations/version.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +module VerboseMigrations + VERSION = '0.0.1' +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..8bc5dd9 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require "verbose_migrations" + +RSpec.configure do |config| + # Enable flags like --only-failures and --next-failure + config.example_status_persistence_file_path = ".rspec_status" + + # Disable RSpec exposing methods globally on `Module` and `main` + config.disable_monkey_patching! + + config.expect_with :rspec do |c| + c.syntax = :expect + end +end diff --git a/spec/verbose_migrations.rb b/spec/verbose_migrations.rb new file mode 100644 index 0000000..42d124d --- /dev/null +++ b/spec/verbose_migrations.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +RSpec.describe VerboseMigrations do + it 'has a version number' do + expect(VerboseMigrations::VERSION).not_to be nil + end +end diff --git a/verbose_migrations.gemspec b/verbose_migrations.gemspec new file mode 100644 index 0000000..6569d16 --- /dev/null +++ b/verbose_migrations.gemspec @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +require_relative "lib/verbose_migrations/version" + +Gem::Specification.new do |spec| + spec.name = 'verbose_migrations' + spec.version = VerboseMigrations::VERSION + spec.authors = ['Zeke Gabrielse'] + spec.email = ['oss@keygen.sh'] + spec.summary = 'Set Active Record logger to DEBUG mode during Active Record migrations.' + spec.description = 'Override Active Record logger to DEBUG mode during Active Record migrations to easily follow along and spot blocking queries in a migration, even when the logger is set to e.g. WARN.' + spec.homepage = 'https://github.com/keygen-sh/verbose_migrations' + spec.license = 'MIT' + + spec.required_ruby_version = '>= 3.1' + spec.files = %w[LICENSE CHANGELOG.md CONTRIBUTING.md SECURITY.md README.md] + Dir.glob('lib/**/*') + spec.require_paths = ['lib'] + + spec.add_dependency 'rails', '>= 6.0' + + spec.add_development_dependency 'rspec-rails' +end