|
| 1 | +name: parallel-tests-ruby-project |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ 'main' ] |
| 6 | + pull_request: |
| 7 | + |
| 8 | +concurrency: |
| 9 | + group: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}-ruby-parallel-tests |
| 10 | + cancel-in-progress: true |
| 11 | + |
| 12 | +jobs: |
| 13 | + main: |
| 14 | + name: ruby-${{ matrix.ruby }} rspec-${{ matrix.rspec }} simplecov-${{ matrix.simplecov }} parallel-tests-${{ matrix.parallel_tests }} |
| 15 | + runs-on: ubuntu-latest |
| 16 | + |
| 17 | + strategy: |
| 18 | + fail-fast: false |
| 19 | + matrix: |
| 20 | + ruby: [ '2.5', '2.6', '2.7', '3.0', 'head' ] |
| 21 | + rspec: [ '3.6.0', '3.8.0', '3.10.0' ] |
| 22 | + simplecov: [ '0.14.0', '0.19.0', '0.21.0' ] |
| 23 | + parallel_tests: [ '2.10.0', '2.32.0', '3.0.0', '3.5.0', '3.7.0' ] |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: Checkout |
| 27 | + uses: actions/checkout@v2 |
| 28 | + |
| 29 | + - name: Setup Ruby |
| 30 | + uses: ruby/setup-ruby@v1 |
| 31 | + with: |
| 32 | + ruby-version: ${{ matrix.ruby }} |
| 33 | + |
| 34 | + - name: Install Dependencies |
| 35 | + run: bundle install --jobs 3 --retry 3 |
| 36 | + |
| 37 | + - name: Run Features |
| 38 | + env: |
| 39 | + RSPEC_VERSION: "~> ${{ matrix.rspec }}" |
| 40 | + SIMPLECOV_VERSION: "~> ${{ matrix.simplecov }}" |
| 41 | + PARALLEL_TESTS_VERSION: "~> ${{ matrix.parallel_tests }}" |
| 42 | + run: | |
| 43 | + mkdir -p exit-codes |
| 44 | + if bundle exec cucumber --retry 3 --no-strict-flaky --tags "@ruby-app and @parallel-tests"; then |
| 45 | + echo 0 > exit-codes/ruby-${{ matrix.ruby }}-rspec-${{ matrix.rspec }}-simplecov-${{ matrix.simplecov }}-parallel_tests-${{ matrix.parallel_tests }}.txt |
| 46 | + else |
| 47 | + echo 1 > exit-codes/ruby-${{ matrix.ruby }}-rspec-${{ matrix.rspec }}-simplecov-${{ matrix.simplecov }}-parallel_tests-${{ matrix.parallel_tests }}.txt |
| 48 | + fi |
| 49 | +
|
| 50 | + - name: Save Exit Code |
| 51 | + uses: actions/upload-artifact@v2 |
| 52 | + with: |
| 53 | + name: ruby-${{ matrix.ruby }}-rspec-${{ matrix.rspec }}-simplecov-${{ matrix.simplecov }}-parallel_tests-${{ matrix.parallel_tests }}.txt |
| 54 | + path: exit-codes/ruby-${{ matrix.ruby }}-rspec-${{ matrix.rspec }}-simplecov-${{ matrix.simplecov }}-parallel_tests-${{ matrix.parallel_tests }}.txt |
| 55 | + retention-days: 1 |
| 56 | + |
| 57 | + parallel-tests-success-rate: |
| 58 | + needs: [ 'main' ] |
| 59 | + name: parallel-tests-success-rate |
| 60 | + runs-on: ubuntu-latest |
| 61 | + |
| 62 | + steps: |
| 63 | + - name: Download Exit Code Reports |
| 64 | + uses: actions/download-artifact@v2 |
| 65 | + with: |
| 66 | + path: exit-codes-temp |
| 67 | + |
| 68 | + - name: Finalize Artifacts |
| 69 | + run: | |
| 70 | + mkdir -p exit-codes |
| 71 | + find exit-codes-temp -mindepth 2 -type f -exec mv -i '{}' exit-codes ';' |
| 72 | +
|
| 73 | + - name: Install dc |
| 74 | + run: | |
| 75 | + sudo apt-get update |
| 76 | + sudo apt-get install dc -y |
| 77 | +
|
| 78 | + - name: Measure Success Rate |
| 79 | + run: | |
| 80 | + cat exit-codes/*.txt |
| 81 | + [[ `ls -1q exit-codes/*.txt | wc -l | sed 's/^ *//g'` == 225 ]] || exit 1 |
| 82 | + [[ `cat exit-codes/*.txt | sed '2,$s/$/+/;$s/$/p/' | dc` < 6 ]] || exit 1 |
0 commit comments