-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
386 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.idea/ | ||
/.bundle/ | ||
/.yardoc | ||
/_yardoc/ | ||
/coverage/ | ||
/doc/ | ||
/pkg/ | ||
/spec/reports/ | ||
/tmp/ | ||
/test-results/ | ||
.rspec_status | ||
lefthook-local.yml | ||
/Gemfile.lock | ||
/gemfiles/*gemfile* | ||
/spec/internal/log/*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
include: | ||
- project: "nstmrt/rubygems/templates" | ||
ref: master | ||
file: "build-rubygems.yml" | ||
|
||
lint: | ||
stage: test | ||
image: dreg.sbmt.io/dhub/library/ruby:3.3 | ||
script: | ||
- bundle install | ||
- bundle exec rubocop | ||
|
||
tests: | ||
stage: test | ||
image: dreg.sbmt.io/dhub/library/ruby:$RUBY_VERSION | ||
parallel: | ||
matrix: | ||
- RUBY_VERSION: ['2.7', '3.0', '3.1', '3.2', '3.3'] | ||
before_script: | ||
- gem install bundler -v 2.4.22 | ||
- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--color | ||
--require spec_helper | ||
--require rails_helper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
inherit_gem: | ||
sbmt-dev: config/rubocop.yml | ||
|
||
AllCops: | ||
TargetRubyVersion: 2.7 | ||
TargetRailsVersion: 6.0 | ||
|
||
Rails/OverridingEnvVars: | ||
Exclude: | ||
- spec/spec_helper.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
# See compatibility table at https://www.fastruby.io/blog/ruby/rails/versions/compatibility-table.html | ||
|
||
versions_map = { | ||
"5.2" => %w[2.7], | ||
"6.0" => %w[2.7], | ||
"6.1" => %w[2.7 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 "rails-#{rails_version}" do | ||
gem "rails", "~> #{rails_version}.0" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# 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 | ||
|
||
## [Unreleased] | ||
|
||
## [0.1.0] - 2024-04-12 | ||
|
||
- Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
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}" \ | ||
&& rm /usr/local/lib/ruby/gems/*/specifications/default/bundler*.gemspec \ | ||
&& gem install --default bundler:${BUNDLER_VERSION} \ | ||
&& gem install bundler -v ${BUNDLER_VERSION} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
source "https://nexus.sbmt.io/repository/rubygems/" | ||
|
||
gemspec | ||
|
||
source "https://nexus.sbmt.io/repository/ruby-gems-sbermarket/" do | ||
gem "sbmt-dev", ">= 0.6.0" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,28 @@ | ||
# Sbmt Pact | ||
|
||
## Функционал | ||
|
||
На данный момент существующая версия гема `pact-ruby` поддерживает [Pact Specification](https://github.com/pact-foundation/pact-specification) лишь версий v1 и v2, что не позволяет: | ||
- написание контрактных тестов для async messages (kafka, etc) | ||
- написание контрактных тестов с отличными от http транспортами (например, grpc) | ||
|
||
Гем `pact-ruby` более не поддерживается меинтейнерами, так как произошел переход к [rust-core](https://github.com/pact-foundation/pact-reference), который в отличных от rust стеков предполагается использовать через FFI | ||
|
||
Данный гем позволяет избавиться от вышеперечисленных недостатков и реализует поддержку последних версий pact-спецификаций: | ||
- базируется на [pact-ffi](https://github.com/pact-foundation/pact-reference/releases) и [pact-ruby-ffi](https://github.com/YOU54F/pact-ruby-ffi) | ||
- предоставляет удобный DSL, упрощающий написание контрактных тестов в ruby/rspec | ||
- поддерживает pact-broker и существующие gitlab-пайплайны в PaaS | ||
|
||
## Разработка | ||
|
||
### Локальное окружение | ||
|
||
1. Подготовка рабочего окружения | ||
```shell | ||
dip provision | ||
``` | ||
|
||
2. Запуск тестов | ||
```shell | ||
dip rspec | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/pact" | ||
|
||
# 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__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
set -euxo pipefail | ||
|
||
bundle install | ||
bundle exec appraisal install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
set -euxo pipefail | ||
|
||
bundle exec rubocop | ||
bundle exec appraisal rspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
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.0: | ||
command: bundle exec appraisal rails-6.0 rspec | ||
rails-6.1: | ||
command: bundle exec appraisal rails-6.1 rspec | ||
rails-7.0: | ||
command: bundle exec appraisal rails-7.0 rspec | ||
|
||
rubocop: | ||
description: Run Ruby linter | ||
service: ruby | ||
command: bundle exec rubocop | ||
|
||
setup: | ||
description: Install deps | ||
service: ruby | ||
command: bin/setup | ||
|
||
test: | ||
description: Run linters, run all tests | ||
service: ruby | ||
command: bin/test | ||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
services: | ||
ruby: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
args: | ||
RUBY_VERSION: ${RUBY_VERSION:-3.3} | ||
BUNDLER_VERSION: 2.4.22 | ||
RUBYGEMS_VERSION: 3.4.22 | ||
image: sbmt-pact-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 | ||
command: bash | ||
working_dir: /app | ||
volumes: | ||
- .:/app:cached | ||
- ${SBMT_RUBYGEMS_PATH:-..}:/app/vendor/gems:cached | ||
- bundler_data:/usr/local/bundle | ||
|
||
volumes: | ||
bundler_data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pre-commit: | ||
commands: | ||
rubocop: | ||
run: dip {cmd} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
require "zeitwerk" | ||
|
||
module Sbmt | ||
module Pact | ||
class Error < StandardError; end | ||
# Your code goes here... | ||
end | ||
end | ||
|
||
loader = Zeitwerk::Loader.new | ||
loader.push_dir(File.join(__dir__, "..")) | ||
|
||
loader.tag = "sbmt-pact" | ||
|
||
loader.ignore("#{__dir__}/pact/version.rb") | ||
|
||
loader.setup | ||
loader.eager_load |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
module Sbmt | ||
module Pact | ||
VERSION = "0.1.0" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "lib/sbmt/pact/version" | ||
|
||
Gem::Specification.new do |spec| | ||
spec.name = "sbmt-pact" | ||
spec.version = Sbmt::Pact::VERSION | ||
spec.authors = ["Ruby Platform Team"] | ||
|
||
spec.summary = "Pact contract testing helpers" | ||
spec.description = spec.summary | ||
spec.homepage = "https://gitlab.sbmt.io/nstmrt/rubygems/sbmt-pact" | ||
spec.required_ruby_version = ">= 2.7.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 | ||
|
||
# Specify which files should be added to the gem when it is released. | ||
# The `git ls-files -z` loads the files in the RubyGem that have been added into git. | ||
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 "zeitwerk", "~> 2.3" | ||
spec.add_dependency "pact-ffi", "~> 0.0.3" | ||
spec.add_dependency "ffi", "~> 1.15" | ||
|
||
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.1.0" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
require "combustion" | ||
|
||
begin | ||
Combustion.initialize! :action_controller do | ||
config.log_level = :fatal if ENV["LOG"].to_s.empty? | ||
config.i18n.available_locales = %i[ru en] | ||
config.i18n.default_locale = :ru | ||
end | ||
rescue => e | ||
# Fail fast if application couldn't be loaded | ||
warn "💥 Failed to load the app: #{e.message}\n#{e.backtrace.join("\n")}" | ||
exit(1) | ||
end | ||
|
||
require "sbmt/dev/testing/rails_configuration" |
Oops, something went wrong.