From 191a63e3c0222ac05bf06faaa496da954e352bbb Mon Sep 17 00:00:00 2001 From: Taras Shpachenko Date: Mon, 22 May 2023 20:47:47 +0200 Subject: [PATCH] Add gem's initial codebase. --- .github/workflows/ci.yml | 42 ++++++++++++++ .gitignore | 8 +++ .rubocop.yml | 13 +++++ .ruby-version | 1 + .yardopts | 5 ++ CHANGELOG.md | 9 +++ Gemfile | 18 ++++++ Gemfile.lock | 92 +++++++++++++++++++++++++++++++ Rakefile | 20 +++++++ bin/console | 11 ++++ bin/setup | 8 +++ lib/mysql2/aws_rds_iam.rb | 12 ++++ lib/mysql2/aws_rds_iam/version.rb | 7 +++ mysql2-aws_rds_iam.gemspec | 41 ++++++++++++++ test/mysql2/test_aws_rds_iam.rb | 15 +++++ test/test_helper.rb | 12 ++++ 16 files changed, 314 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .gitignore create mode 100644 .rubocop.yml create mode 100644 .ruby-version create mode 100644 .yardopts create mode 100644 CHANGELOG.md create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 Rakefile create mode 100755 bin/console create mode 100755 bin/setup create mode 100644 lib/mysql2/aws_rds_iam.rb create mode 100644 lib/mysql2/aws_rds_iam/version.rb create mode 100644 mysql2-aws_rds_iam.gemspec create mode 100644 test/mysql2/test_aws_rds_iam.rb create mode 100644 test/test_helper.rb diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..cad646a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,42 @@ +name: CI + +on: pull_request + +jobs: + lint: + runs-on: ubuntu-latest + name: Linter + steps: + - uses: actions/checkout@v3 + - name: Set up Ruby and gems + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + - name: Run RuboCop + run: bundle exec rubocop + + test: + runs-on: ubuntu-latest + name: Ruby ${{ matrix.ruby }} + strategy: + matrix: + ruby: + - '3.0.0' + - '3.1.0' + steps: + - uses: actions/checkout@v3 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + - name: Run tests + run: bundle exec rake test + + test-results: + name: Check test results + needs: test + runs-on: ubuntu-latest + steps: + - name: Check test results + run: test "${{ needs.test.result }}" = "success" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9106b2a --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +/.bundle/ +/.yardoc +/_yardoc/ +/coverage/ +/doc/ +/pkg/ +/spec/reports/ +/tmp/ diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..62767ee --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,13 @@ +require: + - rubocop-minitest + - rubocop-rake + +AllCops: + TargetRubyVersion: 3.0.0 + NewCops: enable + +Layout/LineLength: + Max: 120 + +Style/Documentation: + Enabled: false diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..fd2a018 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +3.1.0 diff --git a/.yardopts b/.yardopts new file mode 100644 index 0000000..0fa4a8d --- /dev/null +++ b/.yardopts @@ -0,0 +1,5 @@ +--markup markdown +--markup-provider commonmarker +--no-private +- +*.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..736e93b --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,9 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## Unreleased + +No notable changes. diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..ba4013a --- /dev/null +++ b/Gemfile @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +source 'https://rubygems.org' + +gemspec + +gem 'bundler' +gem 'commonmarker' +gem 'minitest' +gem 'minitest-reporters' +gem 'pry' +gem 'rake' +gem 'rubocop' +gem 'rubocop-minitest' +gem 'rubocop-rake' +gem 'timecop' +gem 'webrick' +gem 'yard' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..2d22108 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,92 @@ +PATH + remote: . + specs: + mysql2-aws_rds_iam (0.1.0) + aws-sdk-rds (~> 1) + mysql2 + zeitwerk (~> 2) + +GEM + remote: https://rubygems.org/ + specs: + ansi (1.5.0) + ast (2.4.2) + aws-eventstream (1.2.0) + aws-partitions (1.767.0) + aws-sdk-core (3.173.0) + aws-eventstream (~> 1, >= 1.0.2) + aws-partitions (~> 1, >= 1.651.0) + aws-sigv4 (~> 1.5) + jmespath (~> 1, >= 1.6.1) + aws-sdk-rds (1.179.0) + aws-sdk-core (~> 3, >= 3.165.0) + aws-sigv4 (~> 1.1) + aws-sigv4 (1.5.2) + aws-eventstream (~> 1, >= 1.0.2) + builder (3.2.4) + coderay (1.1.3) + commonmarker (0.23.9) + jmespath (1.6.2) + json (2.6.3) + method_source (1.0.0) + minitest (5.18.0) + minitest-reporters (1.6.0) + ansi + builder + minitest (>= 5.0) + ruby-progressbar + mysql2 (0.5.5) + parallel (1.23.0) + parser (3.2.2.1) + ast (~> 2.4.1) + pry (0.14.2) + coderay (~> 1.1) + method_source (~> 1.0) + rainbow (3.1.1) + rake (13.0.6) + regexp_parser (2.8.0) + rexml (3.2.5) + rubocop (1.51.0) + json (~> 2.3) + parallel (~> 1.10) + parser (>= 3.2.0.0) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.28.0, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.28.1) + parser (>= 3.2.1.0) + rubocop-minitest (0.31.0) + rubocop (>= 1.39, < 2.0) + rubocop-rake (0.6.0) + rubocop (~> 1.0) + ruby-progressbar (1.13.0) + timecop (0.9.6) + unicode-display_width (2.4.2) + webrick (1.8.1) + yard (0.9.34) + zeitwerk (2.6.8) + +PLATFORMS + ruby + x86_64-darwin-22 + +DEPENDENCIES + bundler + commonmarker + minitest + minitest-reporters + mysql2-aws_rds_iam! + pry + rake + rubocop + rubocop-minitest + rubocop-rake + timecop + webrick + yard + +BUNDLED WITH + 2.4.13 diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..9ec5fac --- /dev/null +++ b/Rakefile @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +require 'bundler/gem_tasks' +require 'rake/testtask' +require 'rubocop/rake_task' +require 'yard' + +Rake::TestTask.new(:test) do |t| + t.description = 'Run tests' + t.libs << 'test' + t.test_files = FileList['test/**/test_*.rb'] +end + +desc 'Run linter' +RuboCop::RakeTask.new + +desc 'Generate documentation' +YARD::Rake::YardocTask.new + +task default: %i[test rubocop] diff --git a/bin/console b/bin/console new file mode 100755 index 0000000..6993377 --- /dev/null +++ b/bin/console @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require 'bundler/setup' +require 'mysql2/aws_rds_iam' + +# You can add fixtures and/or initialization code here to make experimenting +# with your gem easier. You can also use a different console, if you like. + +require 'irb' +IRB.start(__FILE__) diff --git a/bin/setup b/bin/setup new file mode 100755 index 0000000..dce67d8 --- /dev/null +++ b/bin/setup @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -euo pipefail +IFS=$'\n\t' +set -vx + +bundle install + +# Do any other automated setup that you need to do here diff --git a/lib/mysql2/aws_rds_iam.rb b/lib/mysql2/aws_rds_iam.rb new file mode 100644 index 0000000..daa22a8 --- /dev/null +++ b/lib/mysql2/aws_rds_iam.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +require 'mysql2' +require 'zeitwerk' + +loader = Zeitwerk::Loader.for_gem_extension(Mysql2) +loader.setup + +module Mysql2 + module AwsRdsIam + end +end diff --git a/lib/mysql2/aws_rds_iam/version.rb b/lib/mysql2/aws_rds_iam/version.rb new file mode 100644 index 0000000..1c447f5 --- /dev/null +++ b/lib/mysql2/aws_rds_iam/version.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +module Mysql2 + module AwsRdsIam + VERSION = '0.1.0' + end +end diff --git a/mysql2-aws_rds_iam.gemspec b/mysql2-aws_rds_iam.gemspec new file mode 100644 index 0000000..7760f26 --- /dev/null +++ b/mysql2-aws_rds_iam.gemspec @@ -0,0 +1,41 @@ +# frozen_string_literal: true + +require_relative 'lib/mysql2/aws_rds_iam/version' + +Gem::Specification.new do |spec| + spec.name = 'mysql2-aws_rds_iam' + spec.version = Mysql2::AwsRdsIam::VERSION + spec.authors = ['Taras Shpachenko'] + spec.email = ['taras.shpachenko@gmail.com'] + + spec.summary = 'AWS RDS IAM authentication for MySQL' + spec.description = 'Mysql2::AwsRdsIam is an extension of mysql2 gem that adds support ' \ + 'of IAM authentication when connecting to MySQL in Amazon RDS.' + spec.homepage = 'https://github.com/floor114/mysql2-aws_rds_iam' + spec.license = 'MIT' + + spec.required_ruby_version = '>= 3.0.0' + + spec.metadata['rubygems_mfa_required'] = 'true' + + spec.metadata['homepage_uri'] = spec.homepage + spec.metadata['source_code_uri'] = spec.homepage + spec.metadata['changelog_uri'] = "#{spec.homepage}/blob/main/CHANGELOG.md" + spec.metadata['bug_tracker_uri'] = "#{spec.homepage}/issues" + spec.metadata['documentation_uri'] = "https://rubydoc.info/gems/mysql2-aws_rds_iam/#{Mysql2::AwsRdsIam::VERSION}" + + spec.files = Dir[ + 'lib/**/*.rb', + '.yardopts', + 'CHANGELOG.md', + 'LICENSE.txt', + 'mysql2-aws_rds_iam.gemspec', + 'README.md' + ] + spec.require_paths = ['lib'] + + # Uncomment to register a new dependency of your gem + spec.add_dependency 'aws-sdk-rds', '~> 1' + spec.add_dependency 'mysql2' + spec.add_dependency 'zeitwerk', '~> 2' +end diff --git a/test/mysql2/test_aws_rds_iam.rb b/test/mysql2/test_aws_rds_iam.rb new file mode 100644 index 0000000..ddac522 --- /dev/null +++ b/test/mysql2/test_aws_rds_iam.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'test_helper' + +module Mysql2 + class TestAwsRdsIam < Minitest::Test + def test_that_it_has_a_version_number + refute_nil ::Mysql2::AwsRdsIam::VERSION + end + + def test_it_does_something_useful + assert 'false' # rubocop:disable Minitest/UselessAssertion + end + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb new file mode 100644 index 0000000..3ff1983 --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +$LOAD_PATH.unshift File.expand_path('../lib', __dir__) +require 'mysql2/aws_rds_iam' + +require 'minitest/reporters' +Minitest::Reporters.use!(Minitest::Reporters::SpecReporter.new) + +require 'timecop' +Timecop.safe_mode = true + +require 'minitest/autorun'