Skip to content

Commit

Permalink
CI: Refactor a logic for skipped tests.
Browse files Browse the repository at this point in the history
* Make the make's TESTS argument update easily by updating TESTS env with added steps.
* Use the `$(...)` rather than backquotes.
  See <https://www.shellcheck.net/wiki/SC2006>.
* Use double-quotes for the make's argument `TESTS="$(...)"` to support
  space-separated skipped tests such as
  `skipped_tests: 'TestGem#test_.* TestMkmf.*'`.
* Replace the `matrix.skipped_tests != ''` with `matrix.skipped_tests`.
  I think that these expressions are equivalent.
  See <https://docs.github.com/en/actions/learn-github-actions/expressions#functions>
  for details.
  > Type - Result
  > Null - ''
  • Loading branch information
junaruga committed Feb 22, 2024
1 parent 133d774 commit 6478514
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 15 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/macos.yml
Expand Up @@ -71,25 +71,30 @@ jobs:

- run: make

- name: Set test options for skipped tests
run: |
set -x
TESTS="$(echo "${{ matrix.skipped_tests }}" | sed 's| |$$/ -n!/|g;s|^|-n!/|;s|$|$$/|')"
echo "TESTS=${TESTS}" >> $GITHUB_ENV
if: ${{ matrix.test_task == 'check' && matrix.skipped_tests }}

- name: make ${{ matrix.test_task }}
run: |
make -s ${{ matrix.test_task }} ${TESTS:+TESTS=`echo "$TESTS" | sed 's| |$$/ -n!/|g;s|^|-n!/|;s|$|$$/|'`}
make -s ${{ matrix.test_task }} ${TESTS:+TESTS="$TESTS"}
timeout-minutes: 60
env:
RUBY_TESTOPTS: '-q --tty=no'
TESTS: ${{ matrix.test_task == 'check' && matrix.skipped_tests || '' }}
TEST_BUNDLED_GEMS_ALLOW_FAILURES: 'minitest,test-unit,debug,bigdecimal,drb,typeprof'
PRECHECK_BUNDLED_GEMS: 'no'

- name: make skipped tests
run: |
make -s test-all TESTS=`echo "$TESTS" | sed 's| |$$/ -n/|g;s|^|-n/|;s|$|$$/|'`
make -s test-all TESTS="${TESTS//-n!\//-n/}"
env:
GNUMAKEFLAGS: ''
RUBY_TESTOPTS: '-v --tty=no'
TESTS: ${{ matrix.skipped_tests }}
PRECHECK_BUNDLED_GEMS: 'no'
if: ${{ matrix.test_task == 'check' && matrix.skipped_tests != '' }}
if: ${{ matrix.test_task == 'check' && matrix.skipped_tests }}
continue-on-error: ${{ matrix.continue-on-skipped_tests || false }}

- uses: ./.github/actions/slack
Expand Down
15 changes: 10 additions & 5 deletions .github/workflows/ubuntu.yml
Expand Up @@ -88,26 +88,31 @@ jobs:

- run: $SETARCH make

- name: Set test options for skipped tests
run: |
set -x
TESTS="$(echo "${{ matrix.skipped_tests }}" | sed 's| |$$/ -n!/|g;s|^|-n!/|;s|$|$$/|')"
echo "TESTS=${TESTS}" >> $GITHUB_ENV
if: ${{ matrix.test_task == 'check' && matrix.skipped_tests }}

- name: make ${{ matrix.test_task }}
run: >-
$SETARCH make -s ${{ matrix.test_task }}
${TESTS:+TESTS=`echo "$TESTS" | sed 's| |$$/ -n!/|g;s|^|-n!/|;s|$|$$/|'`}
${TESTS:+TESTS="$TESTS"}
${{ !contains(matrix.test_task, 'bundle') && 'RUBYOPT=-w' || '' }}
timeout-minutes: 40
env:
RUBY_TESTOPTS: '-q --tty=no'
TESTS: ${{ matrix.test_task == 'check' && matrix.skipped_tests || '' }}
TEST_BUNDLED_GEMS_ALLOW_FAILURES: 'minitest,test-unit,debug,bigdecimal,drb,typeprof'
PRECHECK_BUNDLED_GEMS: 'no'

- name: make skipped tests
run: |
$SETARCH make -s test-all TESTS=`echo "$TESTS" | sed 's| |$$/ -n/|g;s|^|-n/|;s|$|$$/|'`
$SETARCH make -s test-all TESTS="${TESTS//-n!\//-n/}"
env:
GNUMAKEFLAGS: ''
RUBY_TESTOPTS: '-v --tty=no'
TESTS: ${{ matrix.skipped_tests }}
if: ${{ matrix.test_task == 'check' && matrix.skipped_tests != '' }}
if: ${{ matrix.test_task == 'check' && matrix.skipped_tests }}
continue-on-error: ${{ matrix.continue-on-skipped_tests || false }}

- uses: ./.github/actions/slack
Expand Down
15 changes: 10 additions & 5 deletions .github/workflows/yjit-macos.yml
Expand Up @@ -103,26 +103,31 @@ jobs:
- name: Enable YJIT through ENV
run: echo "RUBY_YJIT_ENABLE=1" >> $GITHUB_ENV

- name: Set test options for skipped tests
run: |
set -x
TESTS="$(echo "${{ matrix.skipped_tests }}" | sed 's| |$$/ -n!/|g;s|^|-n!/|;s|$|$$/|')"
echo "TESTS=${TESTS}" >> $GITHUB_ENV
if: ${{ matrix.test_task == 'check' && matrix.skipped_tests }}

- name: make ${{ matrix.test_task }}
run: |
make -s ${{ matrix.test_task }} ${TESTS:+TESTS=`echo "$TESTS" | sed 's| |$$/ -n!/|g;s|^|-n!/|;s|$|$$/|'`}
make -s ${{ matrix.test_task }} ${TESTS:+TESTS="$TESTS"}
timeout-minutes: 60
env:
RUBY_TESTOPTS: '-q --tty=no'
TESTS: ${{ matrix.test_task == 'check' && matrix.skipped_tests || '' }}
TEST_BUNDLED_GEMS_ALLOW_FAILURES: ''
PRECHECK_BUNDLED_GEMS: 'no'
continue-on-error: ${{ matrix.continue-on-test_task || false }}

- name: make skipped tests
run: |
make -s test-all TESTS=`echo "$TESTS" | sed 's| |$$/ -n/|g;s|^|-n/|;s|$|$$/|'`
make -s test-all TESTS="${TESTS//-n!\//-n/}"
env:
GNUMAKEFLAGS: ''
RUBY_TESTOPTS: '-v --tty=no'
TESTS: ${{ matrix.skipped_tests }}
PRECHECK_BUNDLED_GEMS: 'no'
if: ${{ matrix.test_task == 'check' && matrix.skipped_tests != '' }}
if: ${{ matrix.test_task == 'check' && matrix.skipped_tests }}
continue-on-error: ${{ matrix.continue-on-skipped_tests || false }}

- uses: ./.github/actions/slack
Expand Down

0 comments on commit 6478514

Please sign in to comment.