diff --git a/.circleci/Dockerfile b/.circleci/Dockerfile deleted file mode 100644 index 41ccdcb..0000000 --- a/.circleci/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM ubuntu:18.10 -MAINTAINER TSUYUSATO Kitsune - -RUN apt-get update && apt-get install -y \ - curl \ - git \ - locales \ - memcached \ - ruby \ - shellcheck \ - socat \ - && rm -rf /var/lib/apt/lists/* \ - && useradd -ms /bin/bash bashcached \ - && locale-gen en_US.UTF-8 - -USER bashcached -ENV LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8 diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index bf66832..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,22 +0,0 @@ -version: 2.0 - -jobs: - build: - docker: - - image: makenowjust/bashcached-circleci-test:latest - - steps: - - checkout - - run: - name: Run shellcheck - command: | - shellcheck --version - shellcheck bashcached - - run: - name: Run tests - command: | - ruby --version - rake --version - memcached -V - rake test TEST_MEMCACHED=1 - rake test diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..5e910c5 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,29 @@ +name: Test + +on: + push: + branches: + - main + + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + name: Ruby ${{ matrix.ruby }} + strategy: + matrix: + ruby: + - '3.3.5' + + steps: + - uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + - name: Install socat + run: sudo apt-get install -y socat + - name: Run test + run: bundle exec rake test diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..0231c8a --- /dev/null +++ b/Gemfile @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +source "https://rubygems.org" + +gem "minitest" +gem "rake" diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..e129087 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,16 @@ +GEM + remote: https://rubygems.org/ + specs: + minitest (5.25.1) + rake (13.2.1) + +PLATFORMS + arm64-darwin-23 + ruby + +DEPENDENCIES + minitest + rake + +BUNDLED WITH + 2.6.0.dev diff --git a/README.md b/README.md index 79582ee..7427f1e 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [bash]: https://www.gnu.org/software/bash/ [socat]: http://www.dest-unreach.org/socat/ -[![CircleCI](https://circleci.com/gh/MakeNowJust/bashcached.svg?style=svg)](https://circleci.com/gh/MakeNowJust/bashcached) +![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/makenowjust/bashcached/test.yml) ## Feature @@ -53,7 +53,7 @@ $ chmod +x bashcached Or, you could use [`bpkg`](https://github.com/bpkg/bpkg) instaed of downloading script: ```console -$ bpkg install MakeNowJust/bashcached -g +$ bpkg install makenowjust/bashcached -g ``` ## Usage @@ -61,7 +61,7 @@ $ bpkg install MakeNowJust/bashcached -g ```console $ ./bashcached --help bashcached - memcached built on bash + socat -(C) TSUYUSATO "MakeNowJust" Kitsune 2016-2020 +(C) TSUYUSATO "MakeNowJust" Kitsune 2016-2024 USAGE: bashcached [--help] [--version] [--license] [--protocol=tcp|unix] [--port=PORT] [--check=CHECK] @@ -89,4 +89,4 @@ quit ## License and Copyright MIT and [:sushi:](https://github.com/MakeNowJust/sushi-ware) -© TSUYUSATO "[MakeNowJust](https://quine.codes)" Kitsune <> 2016-2018 +© TSUYUSATO "[MakeNowJust](https://quine.codes)" Kitsune <> 2016-2024 diff --git a/bashcached b/bashcached index ddecd3f..7255694 100755 --- a/bashcached +++ b/bashcached @@ -1,6 +1,6 @@ #!/usr/bin/env bash # bashcached - memcached built on bash + socat -# (C) TSUYUSATO "MakeNowJust" Kitsune 2016-2020 +# (C) TSUYUSATO "MakeNowJust" Kitsune 2016-2024 # # USAGE: bashcached [--help] [--version] [--license] [--protocol=tcp|unix] [--port=PORT] [--check=CHECK] # diff --git a/test/command/add_test.rb b/test/command/add_test.rb index 90b759d..43741fd 100644 --- a/test/command/add_test.rb +++ b/test/command/add_test.rb @@ -45,7 +45,7 @@ expect_add client, value: "test", noreply: true expect_get client, value: "test" client << "quit\r\n" - client.gets.must_be_nil + _(client.gets).must_be_nil end end end diff --git a/test/command/append_test.rb b/test/command/append_test.rb index 4db1b31..cd56c33 100644 --- a/test/command/append_test.rb +++ b/test/command/append_test.rb @@ -50,7 +50,7 @@ expect_append client, value: "test", noreply: true expect_not_get client client << "quit\r\n" - client.gets.must_be_nil + _(client.gets).must_be_nil end end end diff --git a/test/command/prepend_test.rb b/test/command/prepend_test.rb index b1aea39..fdb6f54 100644 --- a/test/command/prepend_test.rb +++ b/test/command/prepend_test.rb @@ -50,7 +50,7 @@ expect_append client, value: "test", noreply: true expect_not_get client client << "quit\r\n" - client.gets.must_be_nil + _(client.gets).must_be_nil end end end diff --git a/test/command/quit_test.rb b/test/command/quit_test.rb index 7645f5d..6d5ad2a 100644 --- a/test/command/quit_test.rb +++ b/test/command/quit_test.rb @@ -4,7 +4,7 @@ it "terminate the client connection" do with_bashcached_and_client do |client| client << "quit\r\n" - client.gets.must_be_nil + _(client.gets).must_be_nil end end end diff --git a/test/command/replace_test.rb b/test/command/replace_test.rb index 25c41bb..8e43c5a 100644 --- a/test/command/replace_test.rb +++ b/test/command/replace_test.rb @@ -66,7 +66,7 @@ expect_replace client, value: "test", noreply: true expect_not_get client client << "quit\r\n" - client.gets.must_be_nil + _(client.gets).must_be_nil end end end diff --git a/test/command/set_test.rb b/test/command/set_test.rb index a8376d7..7e5a139 100644 --- a/test/command/set_test.rb +++ b/test/command/set_test.rb @@ -27,7 +27,7 @@ expect_set client, value: "test", noreply: true expect_get client, value: "test" client << "quit\r\n" - client.gets.must_be_nil + _(client.gets).must_be_nil end end diff --git a/test/command/version_test.rb b/test/command/version_test.rb index c0121b6..97545fb 100644 --- a/test/command/version_test.rb +++ b/test/command/version_test.rb @@ -8,7 +8,7 @@ with_bashcached_and_client do |client| client << "version\r\n" version = client.gets - version.must_equal "VERSION #{expect_version}\r\n" + _(version).must_equal "VERSION #{expect_version}\r\n" end end end diff --git a/test/license_test.rb b/test/license_test.rb index 9837eeb..2fde4b7 100644 --- a/test/license_test.rb +++ b/test/license_test.rb @@ -6,6 +6,6 @@ license = "#{File.read("LICENSE.md")}\n#{File.read("LICENSE.🍣.md")}" output = `./bashcached --license` - license.must_equal output + _(license).must_equal output end end diff --git a/test/readme_test.rb b/test/readme_test.rb index ed44d25..9481d21 100644 --- a/test/readme_test.rb +++ b/test/readme_test.rb @@ -8,7 +8,7 @@ .match(%r{(?<=^\$ \.\/bashcached --help\n).*?(?=^\$ )}m) .to_s help = `./bashcached --help` - readme.must_equal help + _(readme).must_equal help end it "example can run" do @@ -24,18 +24,18 @@ case line = example.shift when /\Aversion/ client << "#{line}\r\n" - client.gets.must_equal "#{example.shift}\r\n" + _(client.gets).must_equal "#{example.shift}\r\n" when /\Aset/ client << "#{line}\r\n" client << "#{example.shift}\r\n" - client.gets.must_equal "#{example.shift}\r\n" + _(client.gets).must_equal "#{example.shift}\r\n" when /\Aget/ client << "#{line}\r\n" - client.gets.must_equal "#{example.shift}\r\n" - client.gets.must_equal "#{example.shift}\r\n" + _(client.gets).must_equal "#{example.shift}\r\n" + _(client.gets).must_equal "#{example.shift}\r\n" when /\Aquit/ client << "#{line}\r\n" - client.gets.must_be_nil + _(client.gets).must_be_nil end end end diff --git a/test/test_helper.rb b/test/test_helper.rb index cbc1ee1..907e561 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -7,7 +7,7 @@ TEST_MEMCACHED = ENV.has_key?("TEST_MEMCACHED") -class MiniTest::Test +class Minitest::Test def retry_on_error(times: 10, delay: 0.1, error_class: StandardError) (1..times).each do |i| begin @@ -34,7 +34,7 @@ def with_command(command, timeout:) end begin - Timeout.timeout(0.1) { thread.value.success?.must_equal true } + Timeout.timeout(0.1) { _(thread.value.success?).must_equal true } rescue Timeout::Error Process.kill "INT", -thread.pid # TODO: retry limit is needed? @@ -81,41 +81,41 @@ def write_store_command(client, command, key, flags, exptime, value, noreply, ca def expect_set(client, key: "test", value:, flags: 0, exptime: 0, noreply: false) write_store_command client, "set", key, flags, exptime, value, noreply - client.gets.must_equal "STORED\r\n" unless noreply + _(client.gets).must_equal "STORED\r\n" unless noreply end def expect_add(client, key: "test", value:, flags: 0, exptime: 0, noreply: false, not_stored: false) write_store_command client, "add", key, flags, exptime, value, noreply unless noreply - client.gets.must_equal "#{not_stored ? "NOT_STORED" : "STORED"}\r\n" + _(client.gets).must_equal "#{not_stored ? "NOT_STORED" : "STORED"}\r\n" end end def expect_replace(client, key: "test", value:, flags: 0, exptime: 0, noreply: false, not_stored: false) write_store_command client, "replace", key, flags, exptime, value, noreply unless noreply - client.gets.must_equal "#{not_stored ? "NOT_STORED" : "STORED"}\r\n" + _(client.gets).must_equal "#{not_stored ? "NOT_STORED" : "STORED"}\r\n" end end def expect_append(client, key: "test", value:, flags: 0, exptime: 0, noreply: false, not_stored: false) write_store_command client, "append", key, flags, exptime, value, noreply unless noreply - client.gets.must_equal "#{not_stored ? "NOT_STORED" : "STORED"}\r\n" + _(client.gets).must_equal "#{not_stored ? "NOT_STORED" : "STORED"}\r\n" end end def expect_prepend(client, key: "test", value:, flags: 0, exptime: 0, noreply: false, not_stored: false) write_store_command client, "prepend", key, flags, exptime, value, noreply unless noreply - client.gets.must_equal "#{not_stored ? "NOT_STORED" : "STORED"}\r\n" + _(client.gets).must_equal "#{not_stored ? "NOT_STORED" : "STORED"}\r\n" end end def expect_cas(client, key: "test", value:, flags: 0, exptime: 0, cas_unique:, noreply: false, result:) write_store_command client, "cas", key, flags, exptime, value, noreply, cas_unique unless noreply - client.gets.must_equal "#{result}\r\n" + _(client.gets).must_equal "#{result}\r\n" end end @@ -125,7 +125,7 @@ def expect_get(client, key: "test", value:, flags: 0) def expect_not_get(client, key: "test") client << "get #{key}\r\n" - client.gets.must_equal "END\r\n" + _(client.gets).must_equal "END\r\n" end def expect_gets(client, key: "test", value:, cas_unique:, flags: 0) @@ -153,40 +153,40 @@ def expect_get_many(client, expects) expect_flags = expect[:flags]&.to_s || "0" expect_cas_unique = expect[:cas_unique]&.to_s - $~[:flags].must_equal expect_flags - $~[:cas_unique].must_equal expect_cas_unique if expect_cas_unique - client.read($~[:bytes].to_i).must_equal expect_value.b - client.gets.must_equal "\r\n" + _($~[:flags]).must_equal expect_flags + _($~[:cas_unique]).must_equal expect_cas_unique if expect_cas_unique + _(client.read($~[:bytes].to_i)).must_equal expect_value.b + _(client.gets).must_equal "\r\n" end end - client.gets.must_equal "END\r\n" + _(client.gets).must_equal "END\r\n" end def expect_delete(client, key: "test", noreply: false, not_found: false) client << "delete #{key}#{noreply ? " noreply" : ""}\r\n" unless noreply - client.gets.must_equal "#{not_found ? "NOT_FOUND" : "DELETED"}\r\n" + _(client.gets).must_equal "#{not_found ? "NOT_FOUND" : "DELETED"}\r\n" end end def expect_touch(client, key: "test", exptime:, noreply: false, not_found: false) client << "touch #{key} #{exptime}#{noreply ? " noreply" : ""}\r\n" unless noreply - client.gets.must_equal "#{not_found ? "NOT_FOUND" : "TOUCHED"}\r\n" + _(client.gets).must_equal "#{not_found ? "NOT_FOUND" : "TOUCHED"}\r\n" end end def expect_incr(client, key: "test", value: 1, noreply: false, expect:) client << "incr #{key} #{value}#{noreply ? " noreply" : ""}\r\n" unless noreply - client.gets.must_equal "#{expect}\r\n" + _(client.gets).must_equal "#{expect}\r\n" end end def expect_decr(client, key: "test", value: 1, noreply: false, expect:) client << "decr #{key} #{value}#{noreply ? " noreply" : ""}\r\n" unless noreply - client.gets.must_equal "#{expect}\r\n" + _(client.gets).must_equal "#{expect}\r\n" end end end