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

Add steep type checker #22

Merged
merged 3 commits into from
Sep 6, 2023
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
4 changes: 2 additions & 2 deletions .github/workflows/rspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ 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
- name: Set up Ruby
# 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
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
/spec/reports/
/tmp/

.gem_rbs_collection

.envrc
.idea
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
27 changes: 27 additions & 0 deletions Steepfile
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion lib/yaml_vault.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
118 changes: 118 additions & 0 deletions rbs_collection.lock.yaml
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions rbs_collection.yaml
Original file line number Diff line number Diff line change
@@ -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
54 changes: 54 additions & 0 deletions sig/yaml_vault.rbs
Original file line number Diff line number Diff line change
@@ -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
Loading