Giter Site home page Giter Site logo

r7kamura_split-tests-by-timings's Introduction

split-tests-by-timings

GitHub Action to split test files based on JUnit XML reports, as circleci tests split --split-by=timings.

Usage

Inputs

  • reports
    • Path to directory where JUnit XML reports are stored.
    • e.g. tmp/junit-xml-reports
  • glob
    • Glob pattern to search test files.
    • e.g. spec/**/*_spec.rb
  • index
    • 0-based index of test node.
    • e.g. 0
  • total
    • Total count of test nodes.
    • e.g. 4

Outputs

  • paths
    • Paths of test files in a space-separated string.
    • e.g. spec/models/user_spec.rb spec/models/post_spec.rb

Example

Here is a full example that runs tests in 4 nodes.

# .github/workflows/example.yml
on:
  push:
    branches:
      - main
  pull_request:

jobs:
  rspec:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        ci_node_index:
          - 0
          - 1
          - 2
          - 3
    steps:
      - uses: actions/checkout@v3
      - uses: ruby/setup-ruby@v1
        with:
          bundler-cache: true
    - uses: dawidd6/action-download-artifact@v2
      with:
        branch: main
        name: junit-xml-reports
        path: tmp/junit-xml-reports-downloaded
      continue-on-error: true
    - uses: r7kamura/split-tests-by-timings@v0
      id: split-tests
      with:
        reports: tmp/junit-xml-reports-downloaded
        glob: spec/**/*_spec.rb
        index: ${{ matrix.ci_node_index }}
        total: 4
    - run : |
        bundle exec rspec \
          --format progress \
          --format RspecJunitFormatter \
          --out tmp/junit-xml-reports/junit-xml-report-${{ matrix.ci_node_index }}.xml \
          ${{ steps.split-tests.outputs.paths }}
    - if: github.ref == 'refs/heads/main'
      uses: actions/upload-artifact@v3
      with:
        if-no-files-found: error
        name: junit-xml-reports
        path: tmp/junit-xml-reports

Acknowledgement

This action uses mtsmfm/split-test as its internal implementation.

r7kamura_split-tests-by-timings's People

Contributors

r7kamura avatar

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.