oss-gate / workshop

OSSの開発に未参加または参加したことはあるけどまだ自信がない人を後押しするワークショップ用のリポジトリー
123 stars 540 forks source link

OSS Gate Workshop: PHP Lovers: 2024-01-15: matsuo: puma: Work log #1757

Closed matsuo closed 7 months ago

matsuo commented 7 months ago

This is a work log of a "OSS Gate workshop". "OSS Gate workshop" is an activity to increase OSS developers. Here's been discussed in Japanese. Thanks.

作業ログ作成時の説明

以下のテンプレートを埋めてタイトルに設定します。埋め方例はスクロールすると見えてきます。

OSS Gate Workshop: ${LOCATION}: ${YEAR}-${MONTH}-${DAY}: ${ACCOUNT_NAME}: ${OSS_NAME}: Work log

タイトル例↓:

OSS Gate Workshop: Tokyo: 2017-01-16: kou: Rabbit: Work log

OSS Gateワークショップ関連情報

matsuo commented 7 months ago

Related: #1754

matsuo commented 7 months ago

https://github.com/rubocop/rubocop を選択。

matsuo commented 7 months ago

https://github.com/rubocop/rubocop/blob/master/LICENSE.txt が存在。MITライセンスであることを確認。

matsuo commented 7 months ago

https://github.com/rubocop/rubocop/blob/master/CONTRIBUTING.md が存在。

matsuo commented 7 months ago
% git clone git@github.com:rubocop/rubocop.git
Cloning into 'rubocop'...
remote: Enumerating objects: 143459, done.
remote: Counting objects: 100% (22381/22381), done.
remote: Compressing objects: 100% (1278/1278), done.
remote: Total 143459 (delta 21548), reused 21172 (delta 21101), pack-reused 121078
Receiving objects: 100% (143459/143459), 43.63 MiB | 2.22 MiB/s, done.
Resolving deltas: 100% (107592/107592), done.
matsuo commented 7 months ago

macOSに同梱されているRuby 2.6だとRuboCop 1.59をインストールできませんでした。

% sudo gem install rubocop
Password:
Fetching rexml-3.2.6.gem
Fetching ruby-progressbar-1.13.0.gem
Fetching racc-1.7.3.gem
Fetching ast-2.4.2.gem
Fetching rubocop-ast-1.30.0.gem
Fetching regexp_parser-2.9.0.gem
Fetching unicode-display_width-2.5.0.gem
Fetching parser-3.3.0.3.gem
Fetching rainbow-3.1.1.gem
Fetching parallel-1.24.0.gem
Fetching language_server-protocol-3.17.0.3.gem
Fetching json-2.7.1.gem
Fetching rubocop-1.59.0.gem
Successfully installed unicode-display_width-2.5.0
Successfully installed ruby-progressbar-1.13.0
Building native extensions. This could take a while...
Successfully installed racc-1.7.3
Successfully installed ast-2.4.2
Successfully installed parser-3.3.0.3
Successfully installed rubocop-ast-1.30.0
Successfully installed rexml-3.2.6
Successfully installed regexp_parser-2.9.0
Successfully installed rainbow-3.1.1
Successfully installed parallel-1.24.0
Successfully installed language_server-protocol-3.17.0.3
Building native extensions. This could take a while...
Successfully installed json-2.7.1
ERROR:  Error installing rubocop:
    The last version of rubocop (>= 0) to support your Ruby & RubyGems was 1.50.2. Try installing it with `gem install rubocop -v 1.50.2`
    rubocop requires Ruby version >= 2.7.0. The current ruby version is 2.6.10.210.
matsuo commented 7 months ago

今回は rubocop-1.50.2 をインストールして対処してみました。

% sudo gem install rubocop -v 1.50.2
Password:
Fetching rubocop-1.50.2.gem
Successfully installed rubocop-1.50.2
Parsing documentation for rubocop-1.50.2
Installing ri documentation for rubocop-1.50.2
Done installing documentation for rubocop after 9 seconds
1 gem installed
matsuo commented 7 months ago

Ruby 3.xがやはりあったほうがよさそう。

% cd rubocop
% bundle install
Fetching gem metadata from https://rubygems.org/..........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Bundler could not find compatible versions for gem "ruby":
  In Gemfile:
    ruby

    rubocop was resolved to 1.59.0, which depends on
      ruby (>= 2.7.0)

Could not find gem 'ruby (>= 2.7.0)', which is required by gem 'rubocop', in any of the
relevant sources:
  the local ruby installation
% rake spec
Could not find gem 'asciidoctor' in any of the gem sources listed in your Gemfile.
Run `bundle install` to install missing gems
matsuo commented 7 months ago

Ruby 3.3.0をインストール。

% brew install ruby
matsuo commented 7 months ago
% ruby -v
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23]
% sw_vers 
ProductName:        macOS
ProductVersion:     14.2.1
BuildVersion:       23C71
matsuo commented 7 months ago

手元の環境の都合上、sudo bundle installでインストール。

% cd /tmp/rubocop
% sudo bundle install
Password:
Don't run Bundler as root. Installing your bundle as root will break this application for all
non-root users on this machine.
Fetching gem metadata from https://rubygems.org/..........
Resolving dependencies...
Fetching public_suffix 5.0.4
Fetching diff-lcs 1.5.0
Fetching ast 2.4.2
Fetching bump 0.10.0
Fetching docile 1.4.0
Fetching hashdiff 1.1.0
Fetching language_server-protocol 3.17.0.3
Fetching asciidoctor 2.0.20
Installing diff-lcs 1.5.0
Installing ast 2.4.2
Installing public_suffix 5.0.4
Fetching memory_profiler 1.0.1
Fetching parallel 1.24.0
Fetching rainbow 3.1.1
Installing bump 0.10.0
Fetching regexp_parser 2.9.0
Installing docile 1.4.0
Fetching rspec-support 3.12.1
Installing hashdiff 1.1.0
Fetching ruby-progressbar 1.13.0
Installing language_server-protocol 3.17.0.3
Fetching unicode-display_width 2.5.0
Installing asciidoctor 2.0.20
Fetching simplecov-html 0.10.2
Installing memory_profiler 1.0.1
Fetching stackprof 0.2.25
Installing parallel 1.24.0
Fetching test-queue 0.11.1
Installing rainbow 3.1.1
Fetching yard 0.9.34
Installing regexp_parser 2.9.0
Fetching crack 0.4.5
Installing rspec-support 3.12.1
Fetching addressable 2.8.6
Installing ruby-progressbar 1.13.0
Fetching parser 3.3.0.3
Installing unicode-display_width 2.5.0
Fetching rspec-core 3.12.2
Installing simplecov-html 0.10.2
Fetching rspec-expectations 3.12.3
Installing stackprof 0.2.25 with native extensions
Installing test-queue 0.11.1
Fetching rspec-mocks 3.12.6
Installing yard 0.9.34
Installing crack 0.4.5
Fetching simplecov 0.17.1
Installing addressable 2.8.6
Fetching webmock 3.19.1
Installing parser 3.3.0.3
Fetching rubocop-ast 1.30.0
Installing rspec-core 3.12.2
Installing rspec-expectations 3.12.3
Installing rspec-mocks 3.12.6
Fetching rspec 3.12.0
Installing simplecov 0.17.1
Installing webmock 3.19.1
Installing rubocop-ast 1.30.0
Fetching rubocop-capybara 2.20.0
Fetching rubocop-factory_bot 2.25.1
Fetching rubocop-performance 1.20.2
Fetching rubocop-rake 0.6.0
Installing rspec 3.12.0
Installing rubocop-capybara 2.20.0
Installing rubocop-factory_bot 2.25.1
Fetching rubocop-rspec 2.26.1
Installing rubocop-performance 1.20.2
Installing rubocop-rake 0.6.0
Installing rubocop-rspec 2.26.1
Bundle complete! 17 Gemfile dependencies, 42 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
matsuo commented 7 months ago

テストを実行できました。失敗しているテストはない状況。

% cd /tmp/rubocop
% bundle exec rake spec
Starting test-queue master (/tmp/test_queue_16979_5160.sock)

==> Summary (8 workers in 41.2408s)

    [ 1]                           1080 examples, 0 failures        19 suites in 29.2164s      (pid 16982 exit 0 )
    [ 2]                           4060 examples, 0 failures       123 suites in 29.2173s      (pid 16983 exit 0 )
    [ 3]                           4838 examples, 0 failures       149 suites in 29.2180s      (pid 16984 exit 0 )
    [ 4]                            945 examples, 0 failures        36 suites in 29.2179s      (pid 16985 exit 0 )
    [ 5]                2408 examples, 1 pending, 0 failures        69 suites in 29.2181s      (pid 16986 exit 0 )
    [ 6]                           4067 examples, 0 failures       135 suites in 29.2183s      (pid 16987 exit 0 )
    [ 7]                            133 examples, 0 failures         1 suites in 41.2284s      (pid 16988 exit 0 )
    [ 8]                           4833 examples, 0 failures       134 suites in 41.2288s      (pid 16989 exit 0 )
matsuo commented 7 months ago

https://github.com/rubocop/rubocop から https://github.com/puma/puma に変更しました。 https://github.com/oss-gate/workshop/issues/1754#issuecomment-1890851297

matsuo commented 7 months ago

BSD 3-Clause License https://github.com/puma/puma/blob/master/LICENSE

https://github.com/puma/puma/blob/master/CONTRIBUTING.md

matsuo commented 7 months ago
% git clone git@github.com:puma/puma.git && cd puma
Cloning into 'puma'...
remote: Enumerating objects: 24160, done.
remote: Counting objects: 100% (241/241), done.
remote: Compressing objects: 100% (124/124), done.
remote: Total 24160 (delta 121), reused 215 (delta 111), pack-reused 23919
Receiving objects: 100% (24160/24160), 11.33 MiB | 1.95 MiB/s, done.
Resolving deltas: 100% (13766/13766), done.
% brew install ragel

手元の環境の都合上、sudo bundle installでインストール。

% sudo bundle install
Don't run Bundler as root. Installing your bundle as root will break this application for all
non-root users on this machine.
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Fetching localhost 1.1.10
Fetching webrick 1.8.1
Fetching rake-compiler 1.1.9
Fetching minitest-stub-const 0.6
Fetching nio4r 2.7.0
Fetching rack 3.0.8
Fetching method_source 1.0.0
Fetching minitest 5.21.1
Installing localhost 1.1.10
Installing webrick 1.8.1
Fetching rubocop 1.59.0
Installing rake-compiler 1.1.9
Installing minitest-stub-const 0.6
Installing nio4r 2.7.0 with native extensions
Installing rack 3.0.8
Fetching rackup 2.1.0
Installing method_source 1.0.0
Fetching m 1.6.2
Installing minitest 5.21.1
Fetching minitest-proveit 1.0.0
Fetching minitest-retry 0.2.2
Installing rubocop 1.59.0
Installing rackup 2.1.0
Installing m 1.6.2
Installing minitest-proveit 1.0.0
Installing minitest-retry 0.2.2
Bundle complete! 15 Gemfile dependencies, 29 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
matsuo commented 7 months ago

Compile the native extensions

% bundle exec rake compile
checking for BIO_read() in -llibcrypto... no
checking for BIO_read() in -lcrypto... yes
checking for SSL_CTX_new() in -lssl... yes
checking for openssl/bio.h... yes
checking for DTLS_method() in openssl/ssl.h... yes
checking for SSL_CTX_set_session_cache_mode(NULL, 0) in openssl/ssl.h... yes
checking for TLS_server_method() in openssl/ssl.h... yes
checking for SSL_CTX_set_min_proto_version(NULL, 0) in openssl/ssl.h... yes
checking for X509_STORE_up_ref()... yes
checking for SSL_CTX_set_ecdh_auto(NULL, 0) in openssl/ssl.h... yes
checking for SSL_CTX_set_dh_auto(NULL, 0) in openssl/ssl.h... yes
checking for SSL_get1_peer_certificate() in openssl/ssl.h... yes
checking for Random.bytes... yes
creating Makefile
compiling ../../../../ext/puma_http11/http11_parser.c
compiling ../../../../ext/puma_http11/mini_ssl.c
compiling ../../../../ext/puma_http11/puma_http11.c
linking shared-object puma/puma_http11.bundle
/usr/bin/install -c -m 0755 puma_http11.bundle /private/tmp/puma/lib/puma
matsuo commented 7 months ago
% bundle exec bin/puma test/rackup/hello.ru
Puma starting in single mode...
* Puma version: 6.4.2 (ruby 3.3.0-p0) ("The Eagle of Durango")
*  Min threads: 0
*  Max threads: 5
*  Environment: development
*          PID: 20880
* Listening on http://0.0.0.0:9292
Use Ctrl-C to stop
% curl http://0.0.0.0:9292
Hello World% 
matsuo commented 7 months ago
% bundle exec bin/puma test/rackup/hello.ru
Puma starting in single mode...
* Puma version: 6.4.2 (ruby 3.3.0-p0) ("The Eagle of Durango")
*  Min threads: 0
*  Max threads: 5
*  Environment: development
*          PID: 20880
* Listening on http://0.0.0.0:9292
Use Ctrl-C to stop
% curl http://0.0.0.0:9292
Hello World% 
% bundle exec bin/puma test/rackup/hello.ru
Puma starting in single mode...
* Puma version: 6.4.2 (ruby 3.3.0-p0) ("The Eagle of Durango")
*  Min threads: 0
*  Max threads: 5
*  Environment: development
*          PID: 23557
* Listening on http://0.0.0.0:9292
Use Ctrl-C to stop
^C- Gracefully stopping, waiting for requests to finish
=== puma shutdown: 2024-01-14 14:31:54 +0900 ===
- Goodbye!
matsuo commented 7 months ago

Retrospective: https://github.com/oss-gate/workshop/pull/1766