Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce a GitHub Actions workflow #9

Merged
merged 4 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions .circleci/Dockerfile

This file was deleted.

22 changes: 0 additions & 22 deletions .circleci/config.yml

This file was deleted.

29 changes: 29 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

source "https://rubygems.org"

gem "minitest"
gem "rake"
16 changes: 16 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -53,15 +53,15 @@ $ 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

```console
$ ./bashcached --help
bashcached - memcached built on bash + socat
(C) TSUYUSATO "MakeNowJust" Kitsune 2016-2020 <[email protected]>
(C) TSUYUSATO "MakeNowJust" Kitsune 2016-2024 <[email protected]>

USAGE: bashcached [--help] [--version] [--license] [--protocol=tcp|unix] [--port=PORT] [--check=CHECK]

Expand Down Expand Up @@ -89,4 +89,4 @@ quit
## License and Copyright

MIT and [:sushi:](https://github.com/MakeNowJust/sushi-ware)
© TSUYUSATO "[MakeNowJust](https://quine.codes)" Kitsune <<[email protected]>> 2016-2018
© TSUYUSATO "[MakeNowJust](https://quine.codes)" Kitsune <<[email protected]>> 2016-2024
2 changes: 1 addition & 1 deletion bashcached
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# bashcached - memcached built on bash + socat
# (C) TSUYUSATO "MakeNowJust" Kitsune 2016-2020 <[email protected]>
# (C) TSUYUSATO "MakeNowJust" Kitsune 2016-2024 <[email protected]>
#
# USAGE: bashcached [--help] [--version] [--license] [--protocol=tcp|unix] [--port=PORT] [--check=CHECK]
#
Expand Down
2 changes: 1 addition & 1 deletion test/command/add_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion test/command/append_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion test/command/prepend_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion test/command/quit_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion test/command/replace_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion test/command/set_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion test/command/version_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion test/license_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 6 additions & 6 deletions test/readme_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
36 changes: 18 additions & 18 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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?
Expand Down Expand Up @@ -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

Expand All @@ -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)
Expand Down Expand Up @@ -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