Skip to content
Merged
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
39 changes: 23 additions & 16 deletions .github/workflows/rails_basics_ci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
name: rails_basic_ci
on:
push:
paths-ignore:
- '.github/**/*'
pull_request:
types: [opened, synchronize]
workflow_dispatch:
Expand Down Expand Up @@ -47,7 +44,7 @@ jobs:
strategy:
fail-fast: false
matrix:
group_index: [0,1]
group_index: [0,1,2,3]
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
Expand Down Expand Up @@ -83,29 +80,34 @@ jobs:
with:
reports: prev_merged
glob: spec/**/*_spec.rb
index: ${{ matrix.group_index }}
index: ${{ strategy.job-index }}
total: ${{ strategy.job-total }}
working-directory: rails/basics
- run: echo "$(seq -s, $((${{ matrix.group_index }} * $(nproc))) $((${{ matrix.group_index }} * $(nproc) + $(nproc) - 1)) | sed 's/,$//')"
- run: echo "$(seq -s, $((${{ strategy.job-index }} * $(nproc))) $((${{ strategy.job-index }} * $(nproc) + $(nproc) - 1)) | sed 's/,$//')"
# インスタンス数×nproc個にテストグループを分割し、そのうち2グループ実行する
- env:
GROUP_INDEX: ${{ matrix.group_index }}
run:
bundle exec parallel_rspec \
-n $(nproc) \
--format RspecJunitFormatter \
--out test_reports/junit-${{ matrix.group_index }}-$TEST_ENV_NUMBER.xml \
--format documentation \
${{ steps.split_tests.outputs.paths }}
GHA_JOB_INDEX: ${{ strategy.job-index }}
run: |
bundle
bundle exec parallel_rspec -n $(nproc) ${{ steps.split_tests.outputs.paths }}
working-directory: rails/basics
- uses: actions/upload-artifact@v4
if: ${{ success() || failure() }}
with:
name: test-report-${{ matrix.group_index }}
name: test-report-${{ strategy.job-index }}
path: |
rails/basics/test_reports/
include-hidden-files: true
if-no-files-found: ignore

all-test-are-passed:
runs-on: ubuntu-latest
needs: [test]
if: always()
steps:
- run: |
test "${{ needs.test.result }}" = "success"

dummy:
runs-on: ubuntu-latest
strategy:
Expand All @@ -114,4 +116,9 @@ jobs:
group_index: [0,1]
steps:
- run: |
echo hello;
echo hello branch protection;

use-reusable:
uses: ./.github/workflows/reusable-dummy.yml
with:
message: use-reusable
23 changes: 23 additions & 0 deletions .github/workflows/reusable-dummy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
on:
workflow_call:
inputs:
message:
type: string
required: true

jobs:
dummy-in-reusable:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
group_index: [0,1]
steps:
- run: |
echo hello branch ${{ inputs.message }};
all-test-are-passed:
runs-on: ubuntu-latest
needs: [dummy-in-reusable]
if: always()
steps:
- run: test "${{ needs.dummy-in-reusable.result }}" = "success"
3 changes: 3 additions & 0 deletions rails/basics/.rspec_parallel
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--format RspecJunitFormatter
--out test_reports/junit-<%= ENV['GHA_JOB_INDEX'] %>-<%= ENV['TEST_ENV_NUMBER'] %>.xml
--format documentation
2 changes: 1 addition & 1 deletion rails/basics/spec/models/foo1_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
RSpec.describe 'foo1' do
it do
sleep(1)
expect(0 + 1).to eq 1
expect(0+1).to eq 1
end
end
Loading