From d906e5afc3147c2ab9fa9df41bf1d6ee0a9c0760 Mon Sep 17 00:00:00 2001 From: Cody Cutrer Date: Tue, 3 Oct 2023 16:21:06 +0000 Subject: [PATCH] Add VSCode devcontainer configuration --- .devcontainer.json | 11 ++++++ .gitignore | 1 - .pre-commit-config.yaml | 5 +++ .rubocop.yml | 2 + .vscode/launch.json | 17 +++++++++ Dockerfile | 17 +++++++++ Gemfile | 2 +- Gemfile.lock | 61 ++++++++++++++++++------------ Gemfile.rails-7.0.lock | 61 ++++++++++++++++++------------ README.md | 9 ++--- Rakefile | 2 +- activerecord-pg-extensions.gemspec | 2 +- bin/rdbg | 27 +++++++++++++ docker-compose.yml | 24 ++++++++++++ spec/spec_helper.rb | 1 - 15 files changed, 184 insertions(+), 58 deletions(-) create mode 100644 .devcontainer.json create mode 100644 .pre-commit-config.yaml create mode 100644 .vscode/launch.json create mode 100644 Dockerfile create mode 100755 bin/rdbg create mode 100644 docker-compose.yml diff --git a/.devcontainer.json b/.devcontainer.json new file mode 100644 index 0000000..42d8364 --- /dev/null +++ b/.devcontainer.json @@ -0,0 +1,11 @@ +{ + "dockerComposeFile": "docker-compose.yml", + "service": "app", + "workspaceFolder": "/app", + "postCreateCommand": "bundle install && ~/.local/bin/pre-commit install", + "customizations": { + "vscode": { + "extensions": ["GitHub.vscode-github-actions", "GitHub.vscode-pull-request-github", "Shopify.ruby-lsp", "ms-azuretools.vscode-docker"] + } + } +} diff --git a/.gitignore b/.gitignore index 26981ae..c666a5a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ /.bundle/ -/.byebug_history /log/ /pkg/ /workflow/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..9587143 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,5 @@ +repos: +- repo: https://github.com/mattlqx/pre-commit-ruby + rev: v1.3.5 + hooks: + - id: rubocop diff --git a/.rubocop.yml b/.rubocop.yml index 13c1865..ffe8157 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -26,5 +26,7 @@ RSpec/ContextWording: Enabled: false RSpec/FilePath: Enabled: false +RSpec/SpecFilePathFormat: + Enabled: false RSpec/VerifiedDoubles: Enabled: false \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..068fa23 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,17 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "type": "ruby_lsp", + "request": "launch", + "name": "Run Specs", + "program": "rspec" + }, + { + "type": "ruby_lsp", + "request": "launch", + "name": "Run Current Spec", + "program": "rspec ${file}" + } + ] +} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ad52627 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM ruby:3.1 + +RUN apt update && \ + apt install -y --no-install-recommends \ + less \ + pipx \ + postgresql-client + +WORKDIR /app + +RUN /bin/bash -lc "pipx install pre-commit && gem update --system" + +ENV PATH="${PATH}:/app/bin" + +COPY Gemfile *.gemspec *.lock /app/ +COPY lib/active_record/pg_extensions/version.rb /app/lib/active_record/pg_extensions/ +RUN /bin/bash -lc "bundle install" diff --git a/Gemfile b/Gemfile index 29d1299..d9704aa 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source "https://rubygems.org" -plugin "bundler-multilock", "1.0.6" +plugin "bundler-multilock", "1.0.11" return unless Plugin.installed?("bundler-multilock") Plugin.send(:load_plugin, "bundler-multilock") diff --git a/Gemfile.lock b/Gemfile.lock index 94a2284..dca4ddb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,25 +8,25 @@ PATH GEM remote: https://rubygems.org/ specs: - actionpack (7.0.7.2) - actionview (= 7.0.7.2) - activesupport (= 7.0.7.2) + actionpack (7.0.8) + actionview (= 7.0.8) + activesupport (= 7.0.8) rack (~> 2.0, >= 2.2.4) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actionview (7.0.7.2) - activesupport (= 7.0.7.2) + actionview (7.0.8) + activesupport (= 7.0.8) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activemodel (7.0.7.2) - activesupport (= 7.0.7.2) - activerecord (7.0.7.2) - activemodel (= 7.0.7.2) - activesupport (= 7.0.7.2) - activesupport (7.0.7.2) + activemodel (7.0.8) + activesupport (= 7.0.8) + activerecord (7.0.8) + activemodel (= 7.0.8) + activesupport (= 7.0.8) + activesupport (7.0.8) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -38,13 +38,19 @@ GEM ast (2.4.2) base64 (0.1.1) builder (3.2.4) - byebug (11.1.3) concurrent-ruby (1.2.2) crass (1.0.6) + debug (1.8.0) + irb (>= 1.5.0) + reline (>= 0.3.1) diff-lcs (1.5.0) erubi (1.12.0) i18n (1.14.1) concurrent-ruby (~> 1.0) + io-console (0.6.0) + irb (1.8.1) + rdoc + reline (>= 0.3.8) json (2.6.3) language_server-protocol (3.17.0.3) loofah (2.21.3) @@ -67,6 +73,8 @@ GEM ast (~> 2.4.1) racc pg (1.5.4) + psych (5.1.0) + stringio racc (1.7.1) rack (2.2.8) rack-test (2.1.0) @@ -78,16 +86,20 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.0.7.2) - actionpack (= 7.0.7.2) - activesupport (= 7.0.7.2) + railties (7.0.8) + actionpack (= 7.0.8) + activesupport (= 7.0.8) method_source rake (>= 12.2) thor (~> 1.0) zeitwerk (~> 2.5) rainbow (3.1.1) rake (13.0.6) + rdoc (6.5.0) + psych (>= 4.0.0) regexp_parser (2.8.1) + reline (0.3.9) + io-console (~> 0.5) rexml (3.2.6) rspec (3.12.0) rspec-core (~> 3.12.0) @@ -102,7 +114,7 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.12.0) rspec-support (3.12.1) - rubocop (1.56.2) + rubocop (1.56.4) base64 (~> 0.1.1) json (~> 2.3) language_server-protocol (>= 3.17.0) @@ -116,28 +128,29 @@ GEM unicode-display_width (>= 2.4.0, < 3.0) rubocop-ast (1.29.0) parser (>= 3.2.1.0) - rubocop-capybara (2.18.0) + rubocop-capybara (2.19.0) rubocop (~> 1.41) - rubocop-factory_bot (2.23.1) + rubocop-factory_bot (2.24.0) rubocop (~> 1.33) rubocop-inst (1.0.2) rubocop (~> 1.50) rubocop-performance (~> 1.17) - rubocop-performance (1.19.0) + rubocop-performance (1.19.1) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) rubocop-rake (0.6.0) rubocop (~> 1.0) - rubocop-rspec (2.23.2) + rubocop-rspec (2.24.1) rubocop (~> 1.33) rubocop-capybara (~> 2.17) rubocop-factory_bot (~> 2.22) ruby-progressbar (1.13.0) + stringio (3.0.8) thor (1.2.2) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - unicode-display_width (2.4.2) - zeitwerk (2.6.11) + unicode-display_width (2.5.0) + zeitwerk (2.6.12) PLATFORMS arm64-darwin @@ -148,7 +161,7 @@ PLATFORMS DEPENDENCIES activerecord-pg-extensions! appraisal (~> 2.4) - byebug (~> 11.1) + debug (~> 1.8) pg (~> 1.2) rake (~> 13.0) rspec (~> 3.0) @@ -157,4 +170,4 @@ DEPENDENCIES rubocop-rspec (~> 2.3) BUNDLED WITH - 2.4.19 + 2.4.20 diff --git a/Gemfile.rails-7.0.lock b/Gemfile.rails-7.0.lock index 7215919..8018a1f 100644 --- a/Gemfile.rails-7.0.lock +++ b/Gemfile.rails-7.0.lock @@ -8,25 +8,25 @@ PATH GEM remote: https://rubygems.org/ specs: - actionpack (7.0.7.2) - actionview (= 7.0.7.2) - activesupport (= 7.0.7.2) + actionpack (7.0.8) + actionview (= 7.0.8) + activesupport (= 7.0.8) rack (~> 2.0, >= 2.2.4) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actionview (7.0.7.2) - activesupport (= 7.0.7.2) + actionview (7.0.8) + activesupport (= 7.0.8) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activemodel (7.0.7.2) - activesupport (= 7.0.7.2) - activerecord (7.0.7.2) - activemodel (= 7.0.7.2) - activesupport (= 7.0.7.2) - activesupport (7.0.7.2) + activemodel (7.0.8) + activesupport (= 7.0.8) + activerecord (7.0.8) + activemodel (= 7.0.8) + activesupport (= 7.0.8) + activesupport (7.0.8) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -38,13 +38,19 @@ GEM ast (2.4.2) base64 (0.1.1) builder (3.2.4) - byebug (11.1.3) concurrent-ruby (1.2.2) crass (1.0.6) + debug (1.8.0) + irb (>= 1.5.0) + reline (>= 0.3.1) diff-lcs (1.5.0) erubi (1.12.0) i18n (1.14.1) concurrent-ruby (~> 1.0) + io-console (0.6.0) + irb (1.8.1) + rdoc + reline (>= 0.3.8) json (2.6.3) language_server-protocol (3.17.0.3) loofah (2.21.3) @@ -67,6 +73,8 @@ GEM ast (~> 2.4.1) racc pg (1.5.4) + psych (5.1.0) + stringio racc (1.7.1) rack (2.2.8) rack-test (2.1.0) @@ -78,16 +86,20 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.0.7.2) - actionpack (= 7.0.7.2) - activesupport (= 7.0.7.2) + railties (7.0.8) + actionpack (= 7.0.8) + activesupport (= 7.0.8) method_source rake (>= 12.2) thor (~> 1.0) zeitwerk (~> 2.5) rainbow (3.1.1) rake (13.0.6) + rdoc (6.5.0) + psych (>= 4.0.0) regexp_parser (2.8.1) + reline (0.3.9) + io-console (~> 0.5) rexml (3.2.6) rspec (3.12.0) rspec-core (~> 3.12.0) @@ -102,7 +114,7 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.12.0) rspec-support (3.12.1) - rubocop (1.56.2) + rubocop (1.56.4) base64 (~> 0.1.1) json (~> 2.3) language_server-protocol (>= 3.17.0) @@ -116,28 +128,29 @@ GEM unicode-display_width (>= 2.4.0, < 3.0) rubocop-ast (1.29.0) parser (>= 3.2.1.0) - rubocop-capybara (2.18.0) + rubocop-capybara (2.19.0) rubocop (~> 1.41) - rubocop-factory_bot (2.23.1) + rubocop-factory_bot (2.24.0) rubocop (~> 1.33) rubocop-inst (1.0.2) rubocop (~> 1.50) rubocop-performance (~> 1.17) - rubocop-performance (1.19.0) + rubocop-performance (1.19.1) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) rubocop-rake (0.6.0) rubocop (~> 1.0) - rubocop-rspec (2.23.2) + rubocop-rspec (2.24.1) rubocop (~> 1.33) rubocop-capybara (~> 2.17) rubocop-factory_bot (~> 2.22) ruby-progressbar (1.13.0) + stringio (3.0.8) thor (1.2.2) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - unicode-display_width (2.4.2) - zeitwerk (2.6.11) + unicode-display_width (2.5.0) + zeitwerk (2.6.12) PLATFORMS arm64-darwin @@ -149,7 +162,7 @@ DEPENDENCIES activerecord (~> 7.0.0) activerecord-pg-extensions! appraisal (~> 2.4) - byebug (~> 11.1) + debug (~> 1.8) pg (~> 1.2) rake (~> 13.0) rspec (~> 3.0) @@ -158,4 +171,4 @@ DEPENDENCIES rubocop-rspec (~> 2.3) BUNDLED WITH - 2.4.19 + 2.4.20 diff --git a/README.md b/README.md index ede4f0b..e5b90d3 100644 --- a/README.md +++ b/README.md @@ -16,14 +16,13 @@ See individual classes for available methods. ## Development -You will need Postgres locally to test. As long as `psql` can connect with no arguments, you're fine. Otherwise use environment variables -as described at https://www.postgresql.org/docs/current/libpq-envars.html to configure it. The database will be created automatically. +Development requires Docker. After checking out the repo, run `docker compose build` to install dependencies. -`rake` will run both tests and Rubocop. +`docker compose run --rm app rake` will run both tests and Rubocop. -After checking out the repo, run `bundle install` 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. +If using VSCode, simply click "Reopen in Container" when it pops up. -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). +To release a new version, update the version number in `version.rb`, and then run `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 diff --git a/Rakefile b/Rakefile index 156fd6e..cca7175 100644 --- a/Rakefile +++ b/Rakefile @@ -9,4 +9,4 @@ require "rubocop/rake_task" RuboCop::RakeTask.new -task default: %i[spec] +task default: %i[spec rubocop] diff --git a/activerecord-pg-extensions.gemspec b/activerecord-pg-extensions.gemspec index 5d27699..b280201 100644 --- a/activerecord-pg-extensions.gemspec +++ b/activerecord-pg-extensions.gemspec @@ -24,7 +24,7 @@ Gem::Specification.new do |spec| spec.add_dependency "railties", "~> 7.0.0" spec.add_development_dependency "appraisal", "~> 2.4" - spec.add_development_dependency "byebug", "~> 11.1" + spec.add_development_dependency "debug", "~> 1.8" spec.add_development_dependency "pg", "~> 1.2" spec.add_development_dependency "rake", "~> 13.0" spec.add_development_dependency "rspec", "~> 3.0" diff --git a/bin/rdbg b/bin/rdbg new file mode 100755 index 0000000..5e3b279 --- /dev/null +++ b/bin/rdbg @@ -0,0 +1,27 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'rdbg' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) + +bundle_binstub = File.expand_path("bundle", __dir__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300).include?("This file was generated by Bundler") + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("debug", "rdbg") diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..ddb706e --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,24 @@ +version: '3' + +services: + app: + build: . + volumes: + - .:/app:cached + links: + - postgres + command: sleep infinity + environment: + PGHOST: postgres + PGUSER: postgres + + postgres: + image: postgres:latest + restart: unless-stopped + volumes: + - postgres-data:/var/lib/postgresql/data + environment: + POSTGRES_HOST_AUTH_METHOD: trust + +volumes: + postgres-data: diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 9552845..b67f41b 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require "activerecord-pg-extensions" -require "byebug" require "active_record/railtie" require "active_record/pg_extensions/all"