From a0a0d8db139f00fc08d6460b63ad4fd603180eb4 Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Thu, 11 Jan 2024 23:16:03 +0100 Subject: [PATCH] [Docker] Replace solargraph with ruby-lsp It just works. Requires a bit of a workaround for the .rubocop.yml env setup currently in use but thats alright. The companion ruby-lsp-rails doesn't do much right now but I imagine that to become quite powerful in the future. --- .env.sample | 6 ------ .rubocop.yml | 2 +- .solargraph.yml | 12 ----------- .vscode/extensions.json | 9 +++++++++ .vscode/settings.json | 10 --------- Dockerfile | 5 ----- Gemfile | 5 +++-- Gemfile.lock | 45 +++++++++++++---------------------------- README.md | 3 ++- config/solargraph.rb | 31 ---------------------------- docker-compose.yml | 18 +---------------- 11 files changed, 30 insertions(+), 116 deletions(-) delete mode 100644 .solargraph.yml create mode 100644 .vscode/extensions.json delete mode 100644 .vscode/settings.json delete mode 100644 config/solargraph.rb diff --git a/.env.sample b/.env.sample index fa1a6625d..c89397e8e 100644 --- a/.env.sample +++ b/.env.sample @@ -37,12 +37,6 @@ # Development Only # -# solargraph: Start the integrated solargraph service from the compose file. Requires a rebuild when gems change. -# discord: Starts the discord integration to join users to a discord server. -# The application must have its OAuth2 redirect URI set to ${JOINER_BASE_URL}/callback. -# -# COMPOSE_PROFILES=solargraph,discord - # Change the ports that are forwarded by docker to avoid potential conflicts # EXPOSED_SERVER_PORT=3000 diff --git a/.rubocop.yml b/.rubocop.yml index 611634f16..b39793cfe 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,4 +1,4 @@ -<% unless ENV["IGNORE_RUBOCOP_TODO"] %> +<% unless $PROGRAM_NAME.end_with?("ruby-lsp") %> inherit_from: .rubocop_todo.yml <% end %> diff --git a/.solargraph.yml b/.solargraph.yml deleted file mode 100644 index 64b155321..000000000 --- a/.solargraph.yml +++ /dev/null @@ -1,12 +0,0 @@ -require: - - actioncable - - actionmailer - - actionpack - - actionview - - activejob - - activemodel - - activerecord - - activestorage - - activesupport -reporters: - - rubocop diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 000000000..7694a29e3 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,9 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. + // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp + + // List of extensions which should be recommended for users of this workspace. + "recommendations": ["Shopify.ruby-lsp"], + // List of extensions recommended by VS Code that should not be recommended for users of this workspace. + "unwantedRecommendations": [] +} diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 8117eaea2..000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "solargraph.checkGemVersion": false, - "solargraph.diagnostics": true, - "solargraph.externalServer": { - "host": "localhost", - "port": 7658 - }, - "solargraph.formatting": true, - "solargraph.transport": "external", -} diff --git a/Dockerfile b/Dockerfile index a2c35364b..301e98bcd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,11 +8,6 @@ RUN gem i foreman && BUNDLE_IGNORE_CONFIG=true bundle install -j$(nproc) \ && find /usr/local/bundle/gems/ -name "*.c" -delete \ && find /usr/local/bundle/gems/ -name "*.o" -delete -ARG COMPOSE_PROFILES -RUN if [[ $COMPOSE_PROFILES == *"solargraph"* ]]; then \ - bundle exec yard gems; \ -fi - FROM node:20-alpine3.18 as node-builder RUN apk --no-cache add git WORKDIR /app diff --git a/Gemfile b/Gemfile index e88c89b54..999570b09 100644 --- a/Gemfile +++ b/Gemfile @@ -45,11 +45,12 @@ group :development, :test do gem 'puma' end -group :docker do +group :development do gem "rubocop", require: false gem "rubocop-erb", require: false gem "rubocop-rails", require: false - gem "solargraph", require: false + gem "ruby-lsp" + gem "ruby-lsp-rails" end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index cc77245b5..ef71893b4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -85,10 +85,8 @@ GEM addressable (2.8.5) public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) - backport (1.2.0) base64 (0.2.0) bcrypt (3.1.20) - benchmark (0.3.0) better_html (2.0.2) actionview (>= 6.0) activesupport (>= 6.0) @@ -111,7 +109,6 @@ GEM crass (1.0.6) dalli (3.2.6) date (3.3.4) - diff-lcs (1.5.0) diffy (3.4.2) domain_name (0.6.20231109) dotenv (2.8.1) @@ -125,7 +122,6 @@ GEM activesupport (>= 5.0) request_store (>= 1.0) ruby2_keywords - e2mmap (0.1.0) erubi (1.12.0) factory_bot (6.4.2) activesupport (>= 5.0.0) @@ -151,14 +147,9 @@ GEM multi_xml (>= 0.5.2) i18n (1.14.1) concurrent-ruby (~> 1.0) - jaro_winkler (1.5.6) json (2.7.0) jsonapi-renderer (0.2.2) kgio (2.11.4) - kramdown (2.4.0) - rexml - kramdown-parser-gfm (1.1.0) - kramdown (~> 2.0) language_server-protocol (3.17.0.3) listen (3.8.0) rb-fsevent (~> 0.10, >= 0.10.3) @@ -210,6 +201,7 @@ GEM ast (~> 2.4.1) racc pg (1.5.4) + prism (0.19.0) public_suffix (5.0.4) puma (6.4.0) nio4r (~> 2.0) @@ -253,7 +245,6 @@ GEM rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) - rbs (2.8.4) recaptcha (5.16.0) redis (5.0.8) redis-client (>= 0.17.0) @@ -271,8 +262,6 @@ GEM mime-types (>= 1.16, < 4.0) netrc (~> 0.8) retriable (3.1.2) - reverse_markdown (2.1.1) - nokogiri rexml (3.2.6) rubocop (1.58.0) json (~> 2.3) @@ -295,6 +284,16 @@ GEM rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) rubocop-ast (>= 1.30.0, < 2.0) + ruby-lsp (0.13.3) + language_server-protocol (~> 3.17.0) + prism (>= 0.19.0, < 0.20) + sorbet-runtime (>= 0.5.5685) + ruby-lsp-rails (0.2.8) + actionpack (>= 6.0) + activerecord (>= 6.0) + railties (>= 6.0) + ruby-lsp (>= 0.13.0, < 0.14.0) + sorbet-runtime (>= 0.5.9897) ruby-progressbar (1.13.0) ruby-vips (2.2.0) ffi (~> 1.12) @@ -318,26 +317,10 @@ GEM actionpack (>= 5.2) activemodel (>= 5.2) smart_properties (1.17.0) - solargraph (0.49.0) - backport (~> 1.2) - benchmark - bundler (~> 2.0) - diff-lcs (~> 1.4) - e2mmap - jaro_winkler (~> 1.5) - kramdown (~> 2.3) - kramdown-parser-gfm (~> 1.1) - parser (~> 3.0) - rbs (~> 2.0) - reverse_markdown (~> 2.0) - rubocop (~> 1.38) - thor (~> 1.0) - tilt (~> 2.0) - yard (~> 0.9, >= 0.9.24) + sorbet-runtime (0.5.11188) streamio-ffmpeg (3.0.2) multi_json (~> 1.8) thor (1.3.0) - tilt (2.3.0) timeout (0.4.1) tzinfo (2.0.6) concurrent-ruby (~> 1.0) @@ -360,7 +343,6 @@ GEM websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - yard (0.9.34) zeitwerk (2.6.12) PLATFORMS @@ -395,6 +377,8 @@ DEPENDENCIES rubocop rubocop-erb rubocop-rails + ruby-lsp + ruby-lsp-rails ruby-vips rugged shoulda-context @@ -402,7 +386,6 @@ DEPENDENCIES sidekiq (~> 7.0) sidekiq-unique-jobs simple_form - solargraph streamio-ffmpeg unicorn unicorn-worker-killer diff --git a/README.md b/README.md index fb1196e7b..f038323c1 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,6 @@ To mitigate this you can install a WSL distribution and clone the project inside 1. Clone the repo with `git clone https://github.com/e621ng/e621ng.git`. 1. `cd` into the repo. 1. Copy the sample environment file with `cp .env.sample .env`. -1. Uncomment the `COMPOSE_PROFILES` variable if you wish to use solargraph. Doesn't work on Windows without WSL. 1. Run the following commands: ``` docker compose run --rm -e SEED_POST_COUNT=100 e621 /app/bin/setup @@ -54,6 +53,8 @@ You're most likely using Windows. Give this a shot, it tells Git to stop trackin The postgres server accepts outside connections which you can use to access it with a local client. Use `localhost:34517` to connect to a database named `e621_development` with the user `e621`. Leave the password blank, anything will work. +This repo comes with [Ruby LSP](https://github.com/Shopify/ruby-lsp) preconfigured. Install the [VSCode extension](https://marketplace.visualstudio.com/items?itemName=Shopify.ruby-lsp) and follow the instructions. The only requirement is that the Ruby version used by e621 ([see here](https://github.com/e621ng/e621ng/blob/master/.ruby-version)) is installed on your host. I recommend [rbenv](https://github.com/rbenv/rbenv) to manage your Ruby versions. + ## Production Setup Installation follows the same steps as the docker compose file. Ubuntu 20.04 is the current installation target. diff --git a/config/solargraph.rb b/config/solargraph.rb deleted file mode 100644 index 2feb002bc..000000000 --- a/config/solargraph.rb +++ /dev/null @@ -1,31 +0,0 @@ -# The following comments fill some of the gaps in Solargraph's understanding of -# Rails apps. Since they're all in YARD, they get mapped in Solargraph but -# ignored at runtime. -# -# You can put this file anywhere in the project, as long as it gets included in -# the workspace maps. It's recommended that you keep it in a standalone file -# instead of pasting it into an existing one. -# -# @!parse -# class ActionController::Base -# include ActionController::MimeResponds -# extend ActiveSupport::Callbacks::ClassMethods -# extend AbstractController::Callbacks::ClassMethods -# end -# class ActiveRecord::Base -# extend ActiveRecord::QueryMethods -# extend ActiveRecord::FinderMethods -# extend ActiveRecord::Associations::ClassMethods -# extend ActiveRecord::Inheritance::ClassMethods -# include ActiveRecord::Persistence -# end -# @!override ActiveRecord::FinderMethods#find -# @overload find(id) -# @param id [Integer] -# @return [self] -# @overload find(list) -# @param list [Array] -# @return [Array] -# @overload find(*args) -# @return [Array] -# @return [self, Array] diff --git a/docker-compose.yml b/docker-compose.yml index ece7f21a6..0ba5e5769 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -28,10 +28,7 @@ x-depends-on: &common-depends-on services: e621: - build: - context: ./ - args: - COMPOSE_PROFILES: ${COMPOSE_PROFILES-} + build: ./ image: e621 volumes: - .:/app @@ -168,19 +165,6 @@ services: profiles: - rubocop - solargraph: - image: e621 - entrypoint: solargraph socket -h 0.0.0.0 - working_dir: ${PWD-} - volumes: - - .:${PWD-} - environment: - IGNORE_RUBOCOP_TODO: "1" - ports: - - 7658:7658 - profiles: - - solargraph - volumes: post_data: iqdb_data: