From 3d20b97677b65dcbfcfaa00db3844e967c43e0ac Mon Sep 17 00:00:00 2001 From: Sam Westerman Date: Mon, 5 Feb 2024 10:57:51 -0800 Subject: [PATCH 1/3] Create 'retries' gem --- .gitmodules | 3 +++ gems/retries/0.0.5/_scripts/test | 22 ++++++++++++++++++++++ gems/retries/0.0.5/_src | 1 + gems/retries/0.0.5/_test/Steepfile | 11 +++++++++++ gems/retries/0.0.5/_test/test.rb | 10 ++++++++++ gems/retries/0.0.5/retries.rbs | 15 +++++++++++++++ 6 files changed, 62 insertions(+) create mode 100755 gems/retries/0.0.5/_scripts/test create mode 160000 gems/retries/0.0.5/_src create mode 100644 gems/retries/0.0.5/_test/Steepfile create mode 100644 gems/retries/0.0.5/_test/test.rb create mode 100644 gems/retries/0.0.5/retries.rbs diff --git a/.gitmodules b/.gitmodules index 3c92435b..92782581 100644 --- a/.gitmodules +++ b/.gitmodules @@ -238,3 +238,6 @@ [submodule "gems/json-jwt/1.16/_src"] path = gems/json-jwt/1.16/_src url = https://github.com/nov/json-jwt.git +[submodule "gems/retries/0.0.5/_src"] + path = gems/retries/0.0.5/_src + url = https://github.com/ooyala/retries.git diff --git a/gems/retries/0.0.5/_scripts/test b/gems/retries/0.0.5/_scripts/test new file mode 100755 index 00000000..1437a64d --- /dev/null +++ b/gems/retries/0.0.5/_scripts/test @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +# Exit command with non-zero status code, Output logs of every command executed, Treat unset variables as an error when substituting. +set -eou pipefail +# Internal Field Separator - Linux shell variable +IFS=$'\n\t' +# Print shell input lines +set -v + +# Set RBS_DIR variable to change directory to execute type checks using `steep check` +RBS_DIR=$(cd $(dirname $0)/..; pwd) +# Set REPO_DIR variable to validate RBS files added to the corresponding folder +REPO_DIR=$(cd $(dirname $0)/../../..; pwd) +# Validate RBS files, using the bundler environment present +bundle exec rbs --repo $REPO_DIR -r retries:0.0.5 validate --silent + +cd ${RBS_DIR}/_test +# Run type checks +bundle exec steep check + +$(git rev-parse --show-toplevel)/bin/check-untyped-call.rb +$(git rev-parse --show-toplevel)/bin/check-manifest-yaml.rb diff --git a/gems/retries/0.0.5/_src b/gems/retries/0.0.5/_src new file mode 160000 index 00000000..9622c684 --- /dev/null +++ b/gems/retries/0.0.5/_src @@ -0,0 +1 @@ +Subproject commit 9622c684f32dae96bf181dafff344bd096df1217 diff --git a/gems/retries/0.0.5/_test/Steepfile b/gems/retries/0.0.5/_test/Steepfile new file mode 100644 index 00000000..e2a56309 --- /dev/null +++ b/gems/retries/0.0.5/_test/Steepfile @@ -0,0 +1,11 @@ +D = Steep::Diagnostic + +target :test do + check "." + signature "." + + repo_path "../../../" + library "retries" + + configure_code_diagnostics(D::Ruby.all_error) +end diff --git a/gems/retries/0.0.5/_test/test.rb b/gems/retries/0.0.5/_test/test.rb new file mode 100644 index 00000000..57e8b0df --- /dev/null +++ b/gems/retries/0.0.5/_test/test.rb @@ -0,0 +1,10 @@ +# Write Ruby code to test the RBS. +# It is type checked by `steep check` command. + +require "retries" + +Retries.sleep_enabled = Retries.sleep_enabled + +with_retries max_tries: 10, base_sleep_seconds: 1.2, max_sleep_seconds: 3.4, handler: ->(e,a,t){}, rescue: [StandardError] do |attempt| + puts "Attempt ##{attempt}" +end diff --git a/gems/retries/0.0.5/retries.rbs b/gems/retries/0.0.5/retries.rbs new file mode 100644 index 00000000..06652028 --- /dev/null +++ b/gems/retries/0.0.5/retries.rbs @@ -0,0 +1,15 @@ +class Retries + VERSION: String + + attr_accessor self.sleep_enabled: bool +end + +module Kernel + def with_retries: [T] (?max_tries: Integer, + ?base_sleep_seconds: Numeric, + ?max_sleep_seconds: Numeric, + ?handler: (^(Exception exception, Integer attempts, Float time) -> void)?, + ?rescue: Exception | Array[Exception], + ) { (Integer attempt_number) -> T } -> T + | [T] (Hash[Symbol, untyped] opts) { (Integer attempt_number) -> T } -> T +end From 54469aba1f582471e58cc3af39c222c8abaa8f1f Mon Sep 17 00:00:00 2001 From: Sam W <87729887+sw-square@users.noreply.github.com> Date: Mon, 5 Feb 2024 11:33:47 -0800 Subject: [PATCH 2/3] Update retries.rbs --- gems/retries/0.0.5/retries.rbs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gems/retries/0.0.5/retries.rbs b/gems/retries/0.0.5/retries.rbs index 06652028..67849e29 100644 --- a/gems/retries/0.0.5/retries.rbs +++ b/gems/retries/0.0.5/retries.rbs @@ -5,11 +5,11 @@ class Retries end module Kernel - def with_retries: [T] (?max_tries: Integer, - ?base_sleep_seconds: Numeric, - ?max_sleep_seconds: Numeric, + def with_retries: [T] (?max_tries: Integer?, + ?base_sleep_seconds: Numeric?, + ?max_sleep_seconds: Numeric?, ?handler: (^(Exception exception, Integer attempts, Float time) -> void)?, - ?rescue: Exception | Array[Exception], + ?rescue: Exception | Array[Exception] | nil, ) { (Integer attempt_number) -> T } -> T | [T] (Hash[Symbol, untyped] opts) { (Integer attempt_number) -> T } -> T end From de064a0706da201c3f6d81d9a2a8b5aa611b94bb Mon Sep 17 00:00:00 2001 From: Masataka Pocke Kuwabara Date: Fri, 8 Mar 2024 14:39:36 +0900 Subject: [PATCH 3/3] Remove unnecessary files They are no longer necessary because they are automatically generated during the test process. --- gems/retries/0.0.5/_scripts/test | 22 ---------------------- gems/retries/0.0.5/_test/Steepfile | 11 ----------- 2 files changed, 33 deletions(-) delete mode 100755 gems/retries/0.0.5/_scripts/test delete mode 100644 gems/retries/0.0.5/_test/Steepfile diff --git a/gems/retries/0.0.5/_scripts/test b/gems/retries/0.0.5/_scripts/test deleted file mode 100755 index 1437a64d..00000000 --- a/gems/retries/0.0.5/_scripts/test +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash - -# Exit command with non-zero status code, Output logs of every command executed, Treat unset variables as an error when substituting. -set -eou pipefail -# Internal Field Separator - Linux shell variable -IFS=$'\n\t' -# Print shell input lines -set -v - -# Set RBS_DIR variable to change directory to execute type checks using `steep check` -RBS_DIR=$(cd $(dirname $0)/..; pwd) -# Set REPO_DIR variable to validate RBS files added to the corresponding folder -REPO_DIR=$(cd $(dirname $0)/../../..; pwd) -# Validate RBS files, using the bundler environment present -bundle exec rbs --repo $REPO_DIR -r retries:0.0.5 validate --silent - -cd ${RBS_DIR}/_test -# Run type checks -bundle exec steep check - -$(git rev-parse --show-toplevel)/bin/check-untyped-call.rb -$(git rev-parse --show-toplevel)/bin/check-manifest-yaml.rb diff --git a/gems/retries/0.0.5/_test/Steepfile b/gems/retries/0.0.5/_test/Steepfile deleted file mode 100644 index e2a56309..00000000 --- a/gems/retries/0.0.5/_test/Steepfile +++ /dev/null @@ -1,11 +0,0 @@ -D = Steep::Diagnostic - -target :test do - check "." - signature "." - - repo_path "../../../" - library "retries" - - configure_code_diagnostics(D::Ruby.all_error) -end