Skip to content

feat: branch protectionの挙動確認 #90

feat: branch protectionの挙動確認

feat: branch protectionの挙動確認 #90

Workflow file for this run

name: rails_basic_ci
on:
push:
paths-ignore:
- '.github/**/*'
pull_request:
types: [opened, synchronize]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CI: true
RAILS_ENV: test
defaults:
run:
shell: bash
jobs:
test:
runs-on: ubuntu-latest
container: ghcr.io/fn-reflection/testcases:latest
timeout-minutes: 20
services:
mysql:
image: mysql:8.4.6
ports:
- 3306:3306
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: test
MYSQL_USER: user
MYSQL_PASSWORD: pass
options: >-
--tmpfs /var/lib/mysql:rw,size=1024m
--health-cmd="mysqladmin ping --silent"
--health-start-period 5s
--health-interval 1s
--health-timeout 5s
--health-retries 30
permissions:
contents: read
actions: read
strategy:
fail-fast: false
matrix:
group_index: [0,1,2,3]
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
working-directory: rails/basics
- run: |
mysql -h mysql -u root -proot -e "CREATE DATABASE IF NOT EXISTS test2;"
mysql -h mysql -u root -proot -e "CREATE DATABASE IF NOT EXISTS test3;"
mysql -h mysql -u root -proot -e "CREATE DATABASE IF NOT EXISTS test4;"
# nproc個のデータベースをセットアップする
- run: bundle exec rails "parallel:setup[`nproc`]"
working-directory: rails/basics
- uses: dawidd6/action-download-artifact@v6
with:
name: test-report-.*
name_is_regexp: true
path: prev
branch: ${{ github.ref_name }}
workflow_conclusion: success
if_no_artifact_found: warn
- run: |
PREV_REPORT_DIR=prev
MERGED_REPORT_DIR=prev_merged
echo $PREV_REPORT_DIR
mkdir -p $PREV_REPORT_DIR
echo $MERGED_REPORT_DIR
mkdir -p $MERGED_REPORT_DIR
find $PREV_REPORT_DIR -type f -name 'junit-*.xml' -exec mv {} $MERGED_REPORT_DIR \;
ls $MERGED_REPORT_DIR
- uses: r7kamura/split-tests-by-timings@v0
id: split_tests
with:
reports: prev_merged
glob: spec/**/*_spec.rb
index: ${{ strategy.job-index }}
total: ${{ strategy.job-total }}
working-directory: rails/basics
- run: echo "$(seq -s, $((${{ strategy.job-index }} * $(nproc))) $((${{ strategy.job-index }} * $(nproc) + $(nproc) - 1)) | sed 's/,$//')"
# インスタンス数×nproc個にテストグループを分割し、そのうち2グループ実行する
- env:
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-${{ strategy.job-index }}
path: |
rails/basics/test_reports/
include-hidden-files: true
if-no-files-found: ignore
all-test-is-passed:
runs-on: ubuntu-latest
needs: [test]
if: always()
steps:
- run: |
test "${{ needs.test.result }}" = "success"
dummy:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
group_index: [0,1]
steps:
- run: |
echo hello branch protection;