From 2e3d26a18ec900074455d7e56a9d4e08079dfdf9 Mon Sep 17 00:00:00 2001 From: joker1007 Date: Wed, 6 Sep 2023 00:26:18 +0900 Subject: [PATCH 1/3] chore: add steep --- .gitignore | 2 + Gemfile | 5 ++ Steepfile | 27 +++++++++ rbs_collection.lock.yaml | 118 +++++++++++++++++++++++++++++++++++++++ rbs_collection.yaml | 24 ++++++++ 5 files changed, 176 insertions(+) create mode 100644 Steepfile create mode 100644 rbs_collection.lock.yaml create mode 100644 rbs_collection.yaml diff --git a/.gitignore b/.gitignore index 9d39763..d946d4e 100644 --- a/.gitignore +++ b/.gitignore @@ -8,5 +8,7 @@ /spec/reports/ /tmp/ +.gem_rbs_collection + .envrc .idea diff --git a/Gemfile b/Gemfile index 2b23a99..c47af43 100644 --- a/Gemfile +++ b/Gemfile @@ -5,3 +5,8 @@ gemspec gem "aws-sdk-kms" gem "google-api-client" + +gem 'solargraph', require: false +gem 'steep', require: false +gem 'ruby-lsp', require: false +gem 'debug', require: false diff --git a/Steepfile b/Steepfile new file mode 100644 index 0000000..843bd6e --- /dev/null +++ b/Steepfile @@ -0,0 +1,27 @@ +D = Steep::Diagnostic + +target :lib do + signature "sig" + + check "lib" # Directory name + + library "yaml" + library "base64" + + # configure_code_diagnostics(D::Ruby.default) # `default` diagnostics setting (applies by default) + # configure_code_diagnostics(D::Ruby.strict) # `strict` diagnostics setting + # configure_code_diagnostics(D::Ruby.lenient) # `lenient` diagnostics setting + # configure_code_diagnostics(D::Ruby.silent) # `silent` diagnostics setting + configure_code_diagnostics do |hash| + hash[D::Ruby::MethodDefinitionMissing] = :warning + hash[D::Ruby::UnknownConstant] = nil + end +end + +target :test do + # signature "sig", "sig-private" + + # check "test" + + # library "pathname" # Standard libraries +end diff --git a/rbs_collection.lock.yaml b/rbs_collection.lock.yaml new file mode 100644 index 0000000..2aefa79 --- /dev/null +++ b/rbs_collection.lock.yaml @@ -0,0 +1,118 @@ +--- +sources: +- type: git + name: ruby/gem_rbs_collection + revision: b42e4de88058603a34446942143b3ac197b9685c + remote: https://github.com/ruby/gem_rbs_collection.git + repo_dir: gems +path: ".gem_rbs_collection" +gems: +- name: activesupport + version: '7.0' + source: + type: git + name: ruby/gem_rbs_collection + revision: b42e4de88058603a34446942143b3ac197b9685c + remote: https://github.com/ruby/gem_rbs_collection.git + repo_dir: gems +- name: aws-sdk-core + version: '3' + source: + type: git + name: ruby/gem_rbs_collection + revision: b42e4de88058603a34446942143b3ac197b9685c + remote: https://github.com/ruby/gem_rbs_collection.git + repo_dir: gems +- name: aws-sdk-kms + version: '1' + source: + type: git + name: ruby/gem_rbs_collection + revision: b42e4de88058603a34446942143b3ac197b9685c + remote: https://github.com/ruby/gem_rbs_collection.git + repo_dir: gems +- name: concurrent-ruby + version: '1.1' + source: + type: git + name: ruby/gem_rbs_collection + revision: b42e4de88058603a34446942143b3ac197b9685c + remote: https://github.com/ruby/gem_rbs_collection.git + repo_dir: gems +- name: date + version: '0' + source: + type: stdlib +- name: erb + version: '0' + source: + type: stdlib +- name: faraday + version: '2.5' + source: + type: git + name: ruby/gem_rbs_collection + revision: b42e4de88058603a34446942143b3ac197b9685c + remote: https://github.com/ruby/gem_rbs_collection.git + repo_dir: gems +- name: forwardable + version: '0' + source: + type: stdlib +- name: httpclient + version: '2.8' + source: + type: git + name: ruby/gem_rbs_collection + revision: b42e4de88058603a34446942143b3ac197b9685c + remote: https://github.com/ruby/gem_rbs_collection.git + repo_dir: gems +- name: i18n + version: '1.10' + source: + type: git + name: ruby/gem_rbs_collection + revision: b42e4de88058603a34446942143b3ac197b9685c + remote: https://github.com/ruby/gem_rbs_collection.git + repo_dir: gems +- name: jwt + version: '2.5' + source: + type: git + name: ruby/gem_rbs_collection + revision: b42e4de88058603a34446942143b3ac197b9685c + remote: https://github.com/ruby/gem_rbs_collection.git + repo_dir: gems +- name: logger + version: '0' + source: + type: stdlib +- name: minitest + version: '0' + source: + type: stdlib +- name: monitor + version: '0' + source: + type: stdlib +- name: mutex_m + version: '0' + source: + type: stdlib +- name: securerandom + version: '0' + source: + type: stdlib +- name: singleton + version: '0' + source: + type: stdlib +- name: time + version: '0' + source: + type: stdlib +- name: uri + version: '0' + source: + type: stdlib +gemfile_lock_path: Gemfile.lock diff --git a/rbs_collection.yaml b/rbs_collection.yaml new file mode 100644 index 0000000..b73db80 --- /dev/null +++ b/rbs_collection.yaml @@ -0,0 +1,24 @@ +# Download sources +sources: + - type: git + name: ruby/gem_rbs_collection + remote: https://github.com/ruby/gem_rbs_collection.git + revision: main + repo_dir: gems + +# You can specify local directories as sources also. +# - type: local +# path: path/to/your/local/repository + +# A directory to install the downloaded RBSs +path: .gem_rbs_collection + +gems: + # Skip loading rbs gem's RBS. + # It's unnecessary if you don't use rbs as a library. + - name: rbs + ignore: true + - name: steep + ignore: true + - name: yaml_vault + ignore: true From 5f051883c1efb4e27b3357944afc0886a399cfa2 Mon Sep 17 00:00:00 2001 From: joker1007 Date: Wed, 6 Sep 2023 22:17:36 +0900 Subject: [PATCH 2/3] chore: add yaml_vault.rbs --- lib/yaml_vault.rb | 2 +- sig/yaml_vault.rbs | 54 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 sig/yaml_vault.rbs diff --git a/lib/yaml_vault.rb b/lib/yaml_vault.rb index 215e8d2..1ef7281 100644 --- a/lib/yaml_vault.rb +++ b/lib/yaml_vault.rb @@ -134,7 +134,7 @@ def initialize(key_id, region: nil, aws_access_key_id: nil, aws_secret_access_ke options[:access_key_id] = aws_access_key_id if aws_access_key_id options[:secret_access_key] = aws_secret_access_key if aws_secret_access_key options[:profile] = aws_profile if aws_profile - @client = Aws::KMS::Client.new(options) + @client = Aws::KMS::Client.new(**options) @key_id = key_id end diff --git a/sig/yaml_vault.rbs b/sig/yaml_vault.rbs new file mode 100644 index 0000000..c5a6098 --- /dev/null +++ b/sig/yaml_vault.rbs @@ -0,0 +1,54 @@ +module YamlVault + class Main + @yaml: String + @keys: Array[String] + @prefix: String + @suffix: String + @passphrase: String + @sign_passphrase: String + @salt: String + @cipher: String + @key_len: Integer + @signature_key_len: Integer + @digest: String + @aws_kms_key_id: String + @aws_region: String + @aws_access_key_id: String + @aws_secret_access_key: String + @aws_profile: String + @gcp_kms_resource_id: String + @gcp_credential_file: String + @cryptor: _Cryptor + + def encrypt: () -> untyped + def decrypt: () -> untyped + def encrypt_hash: () -> Hash[String, Object] + def decrypt_hash: () -> Hash[String, Object] + def encrypt_yaml: () -> String + def decrypt_yaml: () -> String + def get_cryptor: (String) -> _Cryptor + + module ValueCryptor + class KMS + @client: Aws::KMS::Client + @key_id: String + + def encrypt: (String) -> String + def decrypt: (String) -> String + end + + class GCPKMS + @client: untyped # Google::Apis::CloudkmsV1::CloudKMSService + @resource_id: String + + def encrypt: (String) -> String + def decrypt: (String) -> String + end + end + end + + interface _Cryptor + def encrypt: (String) -> String + def decrypt: (String) -> String + end +end From f8677fabab77a1dcc549a9adbc6ff3819b74df7f Mon Sep 17 00:00:00 2001 From: joker1007 Date: Wed, 6 Sep 2023 22:22:25 +0900 Subject: [PATCH 3/3] ci: update github action --- .github/workflows/rspec.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml index b8ea0fa..66e9a18 100644 --- a/.github/workflows/rspec.yml +++ b/.github/workflows/rspec.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby-version: ['2.7', '3.0', '3.1'] + ruby-version: ['2.7', '3.0', '3.1', '3.2'] steps: - uses: actions/checkout@v2 @@ -19,7 +19,7 @@ jobs: # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby, # change this to (see https://github.com/ruby/setup-ruby#versioning): # uses: ruby/setup-ruby@v1 - uses: ruby/setup-ruby@v1.110.0 + uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby-version }} bundler-cache: true # runs 'bundle install' and caches installed gems automatically