Created
October 6, 2017 11:20
-
-
Save negabaro/0e1f5e407fc2a40f4f074321d5e0f13f to your computer and use it in GitHub Desktop.
不要な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
#echo "export RSPEC_ENABLE=0" >> ~/.bashrc | |
should_run_rspec(){ | |
echo "You Should Run RSPEC Test" | |
sed -i 's/export RSPEC_ENABLE=0/export RSPEC_ENABLE=1/g' ~/.bashrc | |
} | |
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD)" | |
check_file() { | |
for var in $changed_files | |
do | |
echo $var | |
if [[ $var =~ $1 ]]; then | |
echo "$1 is included in your git push" | |
else | |
echo "$1 is not included in your git push" | |
should_run_rspec | |
break | |
fi | |
done | |
} | |
echo "export RSPEC_ENABLE=0" >> ~/.bashrc | |
check_file "(^docker|circle.yml|.envrc.sample|^config/deploy|README.md|Capfile|Guardfile|memo.txt|^log|PULL_REQUEST_TEMPLATE.md|default.rubocop.yml|pryrc.sample)" |
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
machine: | |
ruby: | |
version: | |
2.3.1 | |
services: | |
- redis | |
- docker | |
environment: | |
RAILS_ENV: test | |
database: | |
override: | |
- mv config/database.ci.yml config/database.yml | |
post: | |
- git diff-tree -r --name-only --no-commit-id ORIG_HEAD | |
- bash ~/xx-beta/bin/check_rspec_enable.sh | |
dependencies: | |
cache_directories: | |
- "elasticsearch-2.3.2" | |
pre: | |
- docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS: | |
parallel: true | |
- phantomjs -v | |
override: | |
- bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3 | |
post: | |
- if [[ ! -e elasticsearch-2.3.2 ]]; then wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.3.2/elasticsearch-2.3.2.tar.gz && tar -xvf elasticsearch-2.3.2.tar.gz && elasticsearch-2.3.2/bin/plugin install analysis-kuromoji && elasticsearch-2.3.2/bin/plugin install analysis-icu; fi: | |
parallel: true | |
- elasticsearch-2.3.2/bin/elasticsearch: | |
parallel: true | |
background: true | |
- wget --tries=10 --retry-connrefused -v http://127.0.0.1:9200/ -O -: | |
parallel: true | |
test: | |
pre: | |
- echo "-----db:migrate:reset start-----" | |
- bundle exec rake db:migrate:reset: | |
parallel: true | |
- echo "-----db:migrate:reset end-----" | |
override: | |
- echo $RSPEC_ENABLE | |
- if [[ "${RSPEC_ENABLE}" == 1 ]] ; then bash bin/circleci-specs-in-parallel.sh ; fi: | |
parallel: true | |
# files: | |
# - spec/**/*_spec.rb | |
# deployment: | |
# develop: | |
# branch: develop | |
# commands: | |
# - sh docker/run_sh.sh: | |
# timeout: 1500 | |
# beta: | |
# branch: beta | |
# commands: | |
# - sh docker/run_sh.sh: | |
# timeout: 1500 | |
# staging: | |
# branch: staging | |
# commands: | |
# - sh docker/run_sh.sh: | |
# timeout: 1500 | |
# production: | |
# branch: production | |
# commands: | |
# - sh docker/run_sh.sh: | |
# timeout: 1500 | |
# test: | |
# branch: feature/auto_deploy | |
# commands: | |
# - sh docker/run_sh.sh: | |
# timeout: 1500 |
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
#!/bin/bash | |
i=0 | |
files=() | |
# sort spec files by number of examples for better balancing | |
for file in $(find ./spec -name "*_spec.rb" -print0 | xargs -0 grep -e "^ *it" -c | sort -t: -k2,2rn | awk -F":" '{ print $1 }') | |
do | |
if [ $(($i % $CIRCLE_NODE_TOTAL)) -eq $CIRCLE_NODE_INDEX ] | |
then | |
files+=" $file" | |
fi | |
((i++)) | |
done | |
echo "specs to be tested: ${files[@]}" | |
bundle exec rspec ${files[@]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment