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

Spike for persistent projections toolkit #1025

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
91 changes: 91 additions & 0 deletions .github/workflows/ruby_event_store-persistent_projections.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: ruby_event_store-persistent_projections
on:
schedule:
- cron: "0 17 * * *"
push:
paths:
- "contrib/ruby_event_store-persistent_projections/**"
- ".github/workflows/ruby_event_store-persistent_projections.yml"
- "support/**"
pull_request:
types: [opened, reopened]
paths:
- "contrib/ruby_event_store-persistent_projections/**"
- ".github/workflows/ruby_event_store-persistent_projections.yml"
- "support/**"
jobs:
test:
runs-on: ${{ matrix.os }}
env:
WORKING_DIRECTORY: contrib/ruby_event_store-persistent_projections
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
DATABASE_URL: ${{ matrix.database }}
services:
mysql:
image: mysql:5.7
env:
MYSQL_DATABASE: rails_event_store
MYSQL_ROOT_PASSWORD: secret
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
strategy:
fail-fast: false
matrix:
include:
- ruby: ruby-3.0
gemfile: Gemfile
os: ubuntu-20.04
database: mysql2://root:[email protected]/rails_event_store
- ruby: ruby-2.7
gemfile: Gemfile
os: ubuntu-20.04
database: mysql2://root:[email protected]/rails_event_store
- ruby: ruby-2.6
gemfile: Gemfile
os: ubuntu-20.04
database: mysql2://root:[email protected]/rails_event_store
- ruby: ruby-2.5
gemfile: Gemfile
os: ubuntu-20.04
database: mysql2://root:[email protected]/rails_event_store
steps:
- uses: actions/checkout@v2
- run: test -e ${{ matrix.gemfile }}.lock
working-directory: ${{ env.WORKING_DIRECTORY }}
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
working-directory: ${{ env.WORKING_DIRECTORY }}
- run: make test
working-directory: ${{ env.WORKING_DIRECTORY }}

mutate:
runs-on: ${{ matrix.os }}
env:
WORKING_DIRECTORY: contrib/ruby_event_store-persistent_projections
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
DATABASE_URL: ${{ matrix.database }}
MUTANT_JOBS: 1
strategy:
fail-fast: false
matrix:
include:
- ruby: ruby-2.7
gemfile: Gemfile
os: ubuntu-20.04
database: mysql2://root:[email protected]/rails_event_store
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- run: test -e ${{ matrix.gemfile }}.lock
working-directory: ${{ env.WORKING_DIRECTORY }}
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
working-directory: ${{ env.WORKING_DIRECTORY }}
- run: make mutate-changes
working-directory: ${{ env.WORKING_DIRECTORY }}
15 changes: 15 additions & 0 deletions contrib/ruby_event_store-persistent_projections/.mutant.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# https://github.com/mbj/mutant/blob/master/docs/configuration.md

requires:
- ruby_event_store/persistent_projections
- ruby_event_store/persistent_projections/cli
includes:
- lib
integration: rspec
mutation_timeout: 10.0
coverage_criteria:
timeout: true
process_abort: true
matcher:
subjects:
- RubyEventStore::PersistentProjections*
12 changes: 12 additions & 0 deletions contrib/ruby_event_store-persistent_projections/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
source 'https://rubygems.org'
gemspec

eval_gemfile '../../support/bundler/Gemfile.shared'


gem 'ruby_event_store', path: '../../ruby_event_store'
gem 'pg', '1.2.2'
gem 'mysql2', '0.5.3'
gem 'childprocess'
gem 'rails', '6.1.0'
gem 'sqlite3', '1.4.2'
201 changes: 201 additions & 0 deletions contrib/ruby_event_store-persistent_projections/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
PATH
remote: ../../ruby_event_store
specs:
ruby_event_store (2.1.0)
concurrent-ruby (~> 1.0, >= 1.1.6)

PATH
remote: .
specs:
ruby_event_store-persistent_projections (0.0.1)
activerecord (>= 5.2)
ruby_event_store (>= 1.0.0)

GEM
remote: https://rubygems.org/
remote: https://oss:[email protected]/
specs:
actioncable (6.1.0)
actionpack (= 6.1.0)
activesupport (= 6.1.0)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.1.0)
actionpack (= 6.1.0)
activejob (= 6.1.0)
activerecord (= 6.1.0)
activestorage (= 6.1.0)
activesupport (= 6.1.0)
mail (>= 2.7.1)
actionmailer (6.1.0)
actionpack (= 6.1.0)
actionview (= 6.1.0)
activejob (= 6.1.0)
activesupport (= 6.1.0)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (6.1.0)
actionview (= 6.1.0)
activesupport (= 6.1.0)
rack (~> 2.0, >= 2.0.9)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.1.0)
actionpack (= 6.1.0)
activerecord (= 6.1.0)
activestorage (= 6.1.0)
activesupport (= 6.1.0)
nokogiri (>= 1.8.5)
actionview (6.1.0)
activesupport (= 6.1.0)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (6.1.0)
activesupport (= 6.1.0)
globalid (>= 0.3.6)
activemodel (6.1.0)
activesupport (= 6.1.0)
activerecord (6.1.0)
activemodel (= 6.1.0)
activesupport (= 6.1.0)
activestorage (6.1.0)
actionpack (= 6.1.0)
activejob (= 6.1.0)
activerecord (= 6.1.0)
activesupport (= 6.1.0)
marcel (~> 0.3.1)
mimemagic (~> 0.3.2)
activesupport (6.1.0)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
ast (2.4.2)
builder (3.2.4)
childprocess (4.0.0)
concurrent-ruby (1.1.8)
crass (1.0.6)
diff-lcs (1.4.4)
erubi (1.10.0)
globalid (0.4.2)
activesupport (>= 4.2.0)
i18n (1.8.9)
concurrent-ruby (~> 1.0)
loofah (2.9.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (0.3.3)
mimemagic (~> 0.3.2)
method_source (1.0.0)
mimemagic (0.3.5)
mini_mime (1.0.2)
minitest (5.14.4)
mutant (0.10.29)
diff-lcs (~> 1.3)
parser (~> 3.0.0)
regexp_parser (~> 2.0, >= 2.0.3)
unparser (~> 0.6.0)
mutant-license (0.1.1.2.1627430819213747598431630701693729869473.0)
mutant-minitest (0.10.29)
minitest (~> 5.11)
mutant (= 0.10.29)
mutant-rspec (0.10.29)
mutant (= 0.10.29)
rspec-core (>= 3.8.0, < 4.0.0)
mysql2 (0.5.3)
nio4r (2.5.7)
nokogiri (1.11.2-x86_64-linux)
racc (~> 1.4)
parser (3.0.0.0)
ast (~> 2.4.1)
pg (1.2.2)
racc (1.5.2)
rack (2.2.3)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (6.1.0)
actioncable (= 6.1.0)
actionmailbox (= 6.1.0)
actionmailer (= 6.1.0)
actionpack (= 6.1.0)
actiontext (= 6.1.0)
actionview (= 6.1.0)
activejob (= 6.1.0)
activemodel (= 6.1.0)
activerecord (= 6.1.0)
activestorage (= 6.1.0)
activesupport (= 6.1.0)
bundler (>= 1.15.0)
railties (= 6.1.0)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
railties (6.1.0)
actionpack (= 6.1.0)
activesupport (= 6.1.0)
method_source
rake (>= 0.8.7)
thor (~> 1.0)
rake (13.0.3)
regexp_parser (2.1.1)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
rspec-mocks (~> 3.10.0)
rspec-core (3.10.1)
rspec-support (~> 3.10.0)
rspec-expectations (3.10.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-mocks (3.10.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-support (3.10.2)
sprockets (4.0.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.2)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.4.2)
thor (1.1.0)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
unparser (0.6.0)
diff-lcs (~> 1.3)
parser (>= 3.0.0)
websocket-driver (0.7.3)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
zeitwerk (2.4.2)

PLATFORMS
x86_64-linux

DEPENDENCIES
childprocess
mutant (~> 0.10.26)
mutant-license!
mutant-minitest (~> 0.10.26)
mutant-rspec (~> 0.10.26)
mysql2 (= 0.5.3)
pg (= 1.2.2)
rails (= 6.1.0)
rake (>= 10.0)
rspec (~> 3.6)
ruby_event_store!
ruby_event_store-persistent_projections!
sqlite3 (= 1.4.2)

BUNDLED WITH
2.2.5
9 changes: 9 additions & 0 deletions contrib/ruby_event_store-persistent_projections/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
GEM_VERSION = $(shell cat lib/ruby_event_store/persistent_projections/version.rb | grep VERSION | egrep -o '[0-9]+\.[0-9]+\.[0-9]+')
GEM_NAME = ruby_event_store-persistent_projections
DATABASE_URL ?= sqlite3::memory:

include ../../support/make/install.mk
include ../../support/make/test.mk
include ../../support/make/mutant.mk
include ../../support/make/gem.mk
include ../../support/make/help.mk
15 changes: 15 additions & 0 deletions contrib/ruby_event_store-persistent_projections/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Ruby Event Store Persistent Projections

![Ruby Event Store Persistent Projections](https://github.com/RailsEventStore/rails_event_store/workflows/ruby_event_store-persistent_projections/badge.svg)

**Experimental feature of RES ecosystem.**

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/RailsEventStore/rails_event_store.

## Releasing

1. Bump version
2. `make build`
3. `make push`
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env ruby

require "ruby_event_store/persistent_projections/cli"

cli = RubyEventStore::PersistentProjections::CLI.new
cli.run(ARGV)
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# frozen_string_literal: true

begin
require 'rails/generators'
rescue LoadError
end

module RubyEventStore
module PersistentProjections
class MigrationGenerator < Rails::Generators::Base
source_root File.expand_path(File.join(File.dirname(__FILE__), './templates'))

def create_migration
template "create_event_store_projections_template.rb", "db/migrate/#{timestamp}_create_event_store_projections.rb"
end

private

def migration_version
"[4.2]"
end

def timestamp
Time.now.strftime("%Y%m%d%H%M%S")
end
end
end
end if defined?(Rails::Generators::Base)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

class CreateEventStoreProjections < ActiveRecord::Migration<%= migration_version %>
def change
create_table(:event_store_projections, force: false) do |t|
t.string :name, null: false
t.integer :position, null: false, default: 0
end
add_index :event_store_projections, :name, unique: true
end
end
Loading