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

Abstract file diff, support list of modified files as an input argument #101 #119 #124

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
62 changes: 62 additions & 0 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# frozen_string_literal: true
# A sample Guardfile
# More info at https://github.com/guard/guard#readme

## Uncomment and set this to only include directories you want to watch
# directories %w(app lib config test spec features) \
# .select{|d| Dir.exist?(d) ? d : UI.warning('Directory #{d} does not exist')}

## Note: if you are using the `directories` clause above and you are not
## watching the project directory ('.'), then you will want to move
## the Guardfile to a watched dir and symlink it back, e.g.
#
# $ mkdir config
# $ mv Guardfile config/
# $ ln -s config/Guardfile .
#
# and, you'll have to watch 'config/Guardfile' instead of 'Guardfile'

# Note: The cmd option is now required due to the increasing number of ways
# rspec may be run, below are examples of the most common uses.
# * bundler: 'bundle exec rspec'
# * bundler binstubs: 'bin/rspec'
# * spring: 'bin/rspec' (This will use spring if running and you have
# installed the spring binstubs per the docs)
# * zeus: 'zeus rspec' (requires the server to be started separately)
# * 'just' rspec: 'rspec'
require 'guard/compat/plugin'

SPEC_DIRS = ENV.fetch('SPEC_DIRS', 'spec features').split

Guard::Compat::UI.info("spec_paths are #{SPEC_DIRS}")

guard_options = {
cmd: 'bundle exec rspec',
# cmd: 'spring crystalball',
# run_all: { cmd: 'CRYSTALBALL=true rspec' },
all_on_start: true,
failed_mode: :focus,
spec_paths: SPEC_DIRS
}

guard :rspec, guard_options do
require 'guard/rspec/dsl'
dsl = Guard::RSpec::Dsl.new(self)

# RSpec files
rspec = dsl.rspec
watch(rspec.spec_helper) { rspec.spec_dir }
watch(rspec.spec_support) { rspec.spec_dir }
watch(rspec.spec_files)

# Ruby files
ruby = dsl.ruby
dsl.watch_spec_files_for(ruby.lib_files)

# Capybara features specs
# watch(rails.view_dirs) { |m| rspec.spec.call('features/#{m[1]}') }
# watch(rails.layouts) { |m| rspec.spec.call('features/#{m[1]}') }

# Turnip features and steps
watch('features')
end
29 changes: 29 additions & 0 deletions bin/guard
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

#
# This file was generated by Bundler.
#
# The application 'guard' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require "pathname"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)

bundle_binstub = File.expand_path("../bundle", __FILE__)

if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
end
end

require "rubygems"
require "bundler/setup"

load Gem.bin_path("guard", "guard")
1 change: 1 addition & 0 deletions crystalball.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'actionview'
spec.add_development_dependency 'activerecord'
spec.add_development_dependency 'factory_bot'
spec.add_development_dependency 'guard-rspec'
spec.add_development_dependency 'i18n'
spec.add_development_dependency 'parser'
spec.add_development_dependency 'pry'
Expand Down
23 changes: 23 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: '3.4'

services:
crystalball:
command: bash -c "bundle install --no-binstubs && bin/guard start --force-polling --watchdir ${SPEC_DIRS:-.}"
build:
context: .
dockerfile: ./docker/Dockerfile
args:
BUNDLER_VERSION: '2.0.2'
RUBY_VERSION: '2.4.4'
image: crystalball
environment:
- EDITOR=micro
- HISTFILE=/crystalball/log/.bash_history
stdin_open: true
tty: true
volumes:
- .:/crystalball:cached
- bundle:/bundle

volumes:
bundle:
35 changes: 35 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
ARG RUBY_VERSION
FROM ruby:$RUBY_VERSION

ARG BUNDLER_VERSION

# Install micro editor
RUN cd /usr/local/bin \
&& curl -sL https://getmic.ro | bash

# Install dependencies
# RUN apt-get update -qq \
# && DEBIAN_FRONTEND=noninteractive apt-get -yq dist-upgrade \
# && DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \
# build-essential \
# && apt-get clean \
# && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
# && truncate -s 0 /var/log/*log

# Configure bundler and PATH
ENV LANG=C.UTF-8 \
GEM_HOME=/bundle \
BUNDLE_JOBS=4 \
BUNDLE_RETRY=3
ENV BUNDLE_PATH $GEM_HOME
ENV BUNDLE_APP_CONFIG=$BUNDLE_PATH \
BUNDLE_BIN=$BUNDLE_PATH/bin
ENV PATH /crystalball/bin:$BUNDLE_BIN:$PATH

# Upgrade RubyGems and install required Bundler version
RUN gem update --system && \
gem install bundler:$BUNDLER_VERSION && \
git config --global user.email "[email protected]" && \
git config --global user.name "John Doe"

WORKDIR /crystalball