Giter VIP home page Giter VIP logo

owen2345 / rspec_chunked Goto Github PK

View Code? Open in Web Editor NEW
3.0 4.0 1.0 157 KB

This gem permits running rspec tests in parallel by chunking tests into defined groups and balancing by file size. If the default order is not enough, it permits to balance manually by moving x percentage of test files from group A into group B.

License: MIT License

Ruby 100.00%
ruby rspec github-workflow parallel-tests

rspec_chunked's Introduction

RspecChunked

This gem permits running rspec tests in parallel by chunking tests into defined groups and balancing by file size. If the default order is not enough, it permits to balance manually by moving x percentage of test files from group A into group B.

Installation

  • Add this line to your application's Gemfile:
  group :test do
    gem 'rspec_chunked'
  end
  • And then execute: bundle install

  • Add manual balance (optional)

      # config/rspec_chunked.rb
      if defined?(RspecChunked::ChunkedTests)
        data = { 1 => { to: 2, percentage: 15 },
                 4 => { to: 3, percentage: 10 } }
        RspecChunked::ChunkedTests.balance_settings = data
      end

    Balance tests by moving 15% tests files from group 1 into group 2 and moving 10% tests files from group 4 into group 3

Usage

  • Basic initialization CI_JOBS=1/3 rake rspec_chunked
  • Custom initialization CI_LOGIC=qty_specs CI_JOBS=1/3 CI_CMD="bundle exec rspec ..." rake rspec_chunked
  • CI_JOBS: Current job number / quantity of groups/jobs to be split
  • CI_CMD: Custom rspec command
  • CI_LOGIC: Kind of logic to be used when ordering tests: qty_specs or file_size (by default file_size)

Coverage merge reports (when using simplecov)

This task will merge all coverage reports rake rspec_chunked:merge_reports

Github workflow result

  • Before:
    Before

  • After:
    After

  • Github workflow sample:

    rspec_tests:
      name: Rspec tests
      runs-on: ubuntu-latest
      strategy:
        fail-fast: false
        matrix:
          ci_job: [ 1, 2, 3, 4 ] # enumerize jobs
      env:
        CI_JOBS: ${{ matrix.ci_job }}/4 # <current_job>/<total_jobs>
    
      steps:
        - uses: actions/checkout@v2
        - name: Backend tests
          run: docker-compose run test /bin/sh -c "CI_JOBS=$CI_JOBS rake rspec_chunked"
    

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/owen2345/rspec_chunked. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

rspec_chunked's People

Contributors

owen2345 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

nschonni

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.