Skip to content

Commit

Permalink
[DEX-2143] feat: initial
Browse files Browse the repository at this point in the history
  • Loading branch information
shatalov-boris committed Apr 4, 2024
0 parents commit 77c0c12
Show file tree
Hide file tree
Showing 18 changed files with 298 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/.bundle/
/.yardoc
/_yardoc/
/coverage/
/doc/
/pkg/
/spec/reports/
/tmp/
.rspec_status
lefthook-local.yml
/Gemfile.lock
/gemfiles/*gemfile*
/spec/internal/log/*.log
/.idea
19 changes: 19 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
include:
- project: "nstmrt/rubygems/templates"
ref: master
file: "build-rubygems.yml"

tests:
stage: test
image: dreg.sbmt.io/dhub/library/ruby:$RUBY_VERSION
parallel:
matrix:
- RUBY_VERSION: ['3.0', '3.1', '3.2', '3.3']
before_script:
- gem install bundler -v 2.5.7
- bin/setup
script:
- bundle exec appraisal rspec --format RspecJunitFormatter --out test-results/rspec_$RUBY_VERSION.xml --format documentation
artifacts:
reports:
junit: test-results/rspec*.xml
3 changes: 3 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--color
--require spec_helper
--require rails_helper
17 changes: 17 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
inherit_gem:
sbmt-dev: config/rubocop.yml

AllCops:
TargetRubyVersion: 3.3
TargetRailsVersion: 7.1
Exclude:
- spec/support/grpc/**/*

Style/StringLiterals:
EnforcedStyle: single_quotes

RSpec/FilePath:
Enabled: false

RSpec/SpecFilePathFormat:
Enabled: false
21 changes: 21 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

# See compatibility table at https://www.fastruby.io/blog/ruby/rails/versions/compatibility-table.html

versions_map = {
'6.1' => %w[3.0],
'7.0' => %w[3.1],
'7.1' => %w[3.2 3.3]
}

current_ruby_version = RUBY_VERSION.split('.').first(2).join('.')

versions_map.each do |rails_version, ruby_versions|
ruby_versions.each do |ruby_version|
next if ruby_version != current_ruby_version

appraise "railties-#{ruby_version}-#{rails_version}" do
gem 'railties', "~> #{rails_version}.0"
end
end
end
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Change Log

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased] - yyyy-mm-dd

### Added

### Changed

### Fixed
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ARG RUBY_VERSION

FROM dreg.sbmt.io/dhub/library/ruby:$RUBY_VERSION

ARG BUNDLER_VERSION
ARG RUBYGEMS_VERSION

ENV BUNDLE_JOBS=4 \
BUNDLE_RETRY=3

RUN gem update --system ${RUBYGEMS_VERSION} \
&& gem install --default bundler:${BUNDLER_VERSION}
10 changes: 10 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

source 'https://nexus.sbmt.io/repository/rubygems/'

gemspec

source 'https://nexus.sbmt.io/repository/ruby-gems-sbermarket/' do
gem 'sbmt-app', '~> 1.34'
gem 'sbmt-dev', '~> 0.14'
end
Empty file added README.md
Empty file.
12 changes: 12 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

require 'bundler/gem_tasks'
require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new(:spec)

require 'rubocop/rake_task'

RuboCop::RakeTask.new

task default: %i[spec rubocop]
15 changes: 15 additions & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'bundler/setup'
require 'sbmt/strangler'

# 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.

# (If you use this, don't forget to add pry to your Gemfile!)
# require "pry"
# Pry.start

require 'irb'
IRB.start(__FILE__)
7 changes: 7 additions & 0 deletions bin/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
set -vx

bundle install
bundle exec appraisal install
60 changes: 60 additions & 0 deletions dip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
version: '7'

environment:
RUBY_VERSION: '3.3'

compose:
files:
- docker-compose.yml

interaction:
bash:
description: Open the Bash shell in app's container
service: ruby
command: /bin/bash

bundle:
description: Run Bundler commands
service: ruby
command: bundle

rails:
description: Run RoR commands
service: ruby
command: bundle exec rails

appraisal:
description: Run Appraisal commands
service: ruby
command: bundle exec appraisal

rspec:
description: Run Rspec commands
service: ruby
command: bundle exec rspec
subcommands:
all:
command: bundle exec appraisal rspec
rails-6.1:
command: bundle exec appraisal rails-6.1 rspec
rails-7.0:
command: bundle exec appraisal rails-7.0 rspec
rails-7.1:
command: bundle exec appraisal rails-7.1 rspec

rubocop:
description: Run Ruby linter
service: ruby
command: bundle exec rubocop

setup:
description: Install deps
service: ruby
command: bin/setup

provision:
- dip compose down --volumes
- cp -f lefthook-local.dip_example.yml lefthook-local.yml
- rm -f Gemfile.lock
- rm -f gemfiles/*gemfile*
- dip setup
26 changes: 26 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
services:
ruby:
build:
context: .
dockerfile: Dockerfile
args:
RUBY_VERSION: ${RUBY_VERSION:-3.3}
RUBYGEMS_VERSION: 3.5.7
BUNDLER_VERSION: 2.5.7
image: sbmt-strangler-dev:0.1.0-ruby_${RUBY_VERSION:-3.3}
environment:
HISTFILE: /app/tmp/.bash_history
BUNDLE_PATH: /usr/local/bundle
BUNDLE_CONFIG: /app/.bundle/config
prometheus_multiproc_dir: ./tmp
command: bash
working_dir: /app
volumes:
- .:/app:cached
- ${SBMT_RUBYGEMS_PATH:-..}:/app/vendor/gems:cached
- bundler_data:/usr/local/bundle
tmpfs:
- /tmp

volumes:
bundler_data:
4 changes: 4 additions & 0 deletions lefthook-local.dip_example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pre-commit:
commands:
rubocop:
run: dip {cmd}
6 changes: 6 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pre-commit:
commands:
rubocop:
tags: backend
glob: "{*.rb,**/*.rb,Gemfile,Rakefile}"
run: bundle exec rubocop -A --force-exclusion {staged_files} && git add {staged_files}
7 changes: 7 additions & 0 deletions lib/sbmt/strangler/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

module Sbmt
module Strangler
VERSION = '0.1.0'
end
end
51 changes: 51 additions & 0 deletions sbmt-strangler.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# frozen_string_literal: true

require_relative 'lib/sbmt/strangler/version'

Gem::Specification.new do |spec|
spec.name = 'sbmt-strangler'
spec.version = Sbmt::Strangler::VERSION
spec.authors = ['sbermarket team']

spec.summary = 'Utility for strangler pattern'
spec.description = spec.summary
spec.homepage = 'https://gitlab.sbmt.io/nstmrt/rubygems/sbmt-strangler'
spec.required_ruby_version = '>= 3.0.0'

spec.metadata['allowed_push_host'] = 'https://nexus.sbmt.io'

spec.metadata['homepage_uri'] = spec.homepage
spec.metadata['source_code_uri'] = spec.homepage
spec.metadata['changelog_uri'] = "#{spec.homepage}/-/blob/master/CHANGELOG.md"
spec.metadata['rubygems_mfa_required'] = 'false' # rubocop:disable Gemspec/RequireMFA

spec.files = Dir.chdir(__dir__) do
`git ls-files -z`.split("\x0").reject do |f|
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
end
end
spec.bindir = 'exe'
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
spec.require_paths = ['lib']

spec.add_dependency 'faraday', '> 1.0'
spec.add_dependency 'faraday-net_http_persistent', '> 1.0'
spec.add_dependency 'net-http-persistent', '>= 4.0.1'

spec.add_dependency 'flipper'
spec.add_dependency 'railties', '>= 6.1', '< 7.2'
spec.add_dependency 'sentry-rails', '>= 5.3.1'
spec.add_dependency 'yabeda', '>= 0.11'
spec.add_dependency 'yabeda-prometheus-mmap', '~> 0.3'
spec.add_dependency 'oj'
spec.add_dependency 'dry-monads'
spec.add_dependency 'dry-struct'

spec.add_dependency 'sbmt-app', '>= 1.34.0'

spec.add_development_dependency 'appraisal', '>= 2.4'
spec.add_development_dependency 'bundler', '>= 2.3'
spec.add_development_dependency 'combustion', '>= 1.3'
spec.add_development_dependency 'rake', '>= 13.0'
spec.add_development_dependency 'sbmt-dev', '~> 0.14'
end

0 comments on commit 77c0c12

Please sign in to comment.