[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.
This commit is contained in:
Earlopain 2024-01-11 23:16:03 +01:00
parent 7c53f9331b
commit a0a0d8db13
No known key found for this signature in database
GPG Key ID: 48860312319ADF61
11 changed files with 30 additions and 116 deletions

View File

@ -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

View File

@ -1,4 +1,4 @@
<% unless ENV["IGNORE_RUBOCOP_TODO"] %>
<% unless $PROGRAM_NAME.end_with?("ruby-lsp") %>
inherit_from: .rubocop_todo.yml
<% end %>

View File

@ -1,12 +0,0 @@
require:
- actioncable
- actionmailer
- actionpack
- actionview
- activejob
- activemodel
- activerecord
- activestorage
- activesupport
reporters:
- rubocop

9
.vscode/extensions.json vendored Normal file
View File

@ -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": []
}

10
.vscode/settings.json vendored
View File

@ -1,10 +0,0 @@
{
"solargraph.checkGemVersion": false,
"solargraph.diagnostics": true,
"solargraph.externalServer": {
"host": "localhost",
"port": 7658
},
"solargraph.formatting": true,
"solargraph.transport": "external",
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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<self>]
# @overload find(*args)
# @return [Array<self>]
# @return [self, Array<self>]

View File

@ -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: