Skip to content

Commit 676b4ec

Browse files
authored
Enable more Launchable integration in bootstraptest and test-all (ruby#12255)
1 parent 1279b5b commit 676b4ec

File tree

6 files changed

+119
-41
lines changed

6 files changed

+119
-41
lines changed

.github/actions/launchable/setup/action.yml

Lines changed: 110 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ description: >-
33
Install the required dependencies and execute the necessary Launchable commands for test recording
44
55
inputs:
6-
report-path:
7-
default: launchable_reports.json
8-
required: true
9-
description: The file path of the test report for uploading to Launchable
10-
116
os:
127
required: true
138
description: The operating system that CI runs on. This value is used in Launchable flavor.
@@ -38,18 +33,27 @@ inputs:
3833
Directory to (re-)checkout source codes. Launchable retrieves the commit information
3934
from the directory.
4035
41-
launchable-workspace:
42-
required: true
43-
default: ${{ github.event.repository.name }}
44-
description: >-
45-
A workspace name in Launchable
46-
4736
test-task:
48-
required: true
37+
required: false
4938
default: ${{ matrix.test_task }}
5039
description: >-
51-
A test task that determine which tests are executed.
40+
Specifies a single test task to be executed.
5241
This value is used in the Launchable flavor.
42+
Either 'test-task' or 'multi-test-tasks' must be configured.
43+
44+
test-tasks:
45+
required: false
46+
default: '[]'
47+
description: >-
48+
Specifies an array of multiple test tasks to be executed.
49+
For example: '["test", "test-all"]'.
50+
If you want to run a single test task, use the 'test-task' input instead.
51+
52+
is-yjit:
53+
required: false
54+
default: 'false'
55+
description: >-
56+
Whether this workflow is executed on YJIT.
5357
5458
runs:
5559
using: composite
@@ -61,11 +65,14 @@ runs:
6165
shell: bash
6266
if: >-
6367
${{
64-
(github.repository == 'ruby/ruby' ||
65-
(github.repository != 'ruby/ruby' && env.LAUNCHABLE_TOKEN)) &&
66-
(inputs.test-task == 'check' ||
67-
inputs.test-task == 'test-all' ||
68-
inputs.test-task == 'test')
68+
(github.repository == 'ruby/ruby'
69+
|| (github.repository != 'ruby/ruby'
70+
&& env.LAUNCHABLE_TOKEN))
71+
&& (inputs.test-task == 'check'
72+
|| inputs.test-task == 'test-all'
73+
|| inputs.test-task == 'test'
74+
|| contains(fromJSON(inputs.test-tasks), 'test-all')
75+
|| contains(fromJSON(inputs.test-tasks), 'test'))
6976
}}
7077
7178
# Launchable CLI requires Python and Java.
@@ -83,6 +90,20 @@ runs:
8390
java-version: '17'
8491
if: steps.enable-launchable.outputs.enable-launchable
8592

93+
- name: Set global vars
94+
id: global
95+
shell: bash
96+
run: |
97+
test_all_enabled="${{ inputs.test-task == 'check' || inputs.test-task == 'test-all' || contains(fromJSON(inputs.test-tasks), 'test-all') }}"
98+
btest_enabled="${{ inputs.test-task == 'check' || inputs.test-task == 'test' || contains(fromJSON(inputs.test-tasks), 'test') }}"
99+
echo test_all_enabled="${test_all_enabled}" >> $GITHUB_OUTPUT
100+
echo btest_enabled="${btest_enabled}" >> $GITHUB_OUTPUT
101+
echo test_all_session_file='launchable_test_all_session.txt' >> $GITHUB_OUTPUT
102+
echo btest_session_file='launchable_btest_session.txt' >> $GITHUB_OUTPUT
103+
echo test_all_report_file='launchable_test_all_report.json' >> $GITHUB_OUTPUT
104+
echo btest_report_file='launchable_btest_report.json' >> $GITHUB_OUTPUT
105+
if: steps.enable-launchable.outputs.enable-launchable
106+
86107
- name: Set environment variables for Launchable
87108
shell: bash
88109
run: |
@@ -92,7 +113,7 @@ runs:
92113
: # The following envs are necessary in Launchable tokenless authentication.
93114
: # https://github.com/launchableinc/cli/blob/v1.80.1/launchable/utils/authentication.py#L20
94115
echo "LAUNCHABLE_ORGANIZATION=${{ github.repository_owner }}" >> $GITHUB_ENV
95-
echo "LAUNCHABLE_WORKSPACE=${{ inputs.launchable-workspace }}" >> $GITHUB_ENV
116+
echo "LAUNCHABLE_WORKSPACE=${{ github.event.repository.name }}" >> $GITHUB_ENV
96117
: # https://github.com/launchableinc/cli/blob/v1.80.1/launchable/utils/authentication.py#L71
97118
echo "GITHUB_PR_HEAD_SHA=${{ github.event.pull_request.head.sha || github.sha }}" >> $GITHUB_ENV
98119
echo "LAUNCHABLE_TOKEN=${{ inputs.launchable-token }}" >> $GITHUB_ENV
@@ -121,45 +142,100 @@ runs:
121142
: #
122143
: # FIXME: Need to fix `WARNING: Failed to process a change to a file`.
123144
: # https://github.com/launchableinc/cli/issues/786
124-
launchable record build --name ${github_ref}_${GITHUB_PR_HEAD_SHA}
125-
echo "TESTS=${TESTS} --launchable-test-reports=${{ inputs.report-path }}" >> $GITHUB_ENV
145+
build_name="${github_ref}_${GITHUB_PR_HEAD_SHA}"
146+
test_opts="${{ inputs.test-opts }}"
147+
test_opts="${test_opts// /}"
148+
test_opts="${test_opts//=/:}"
149+
test_all_test_suite='test-all'
150+
btest_test_suite='btest'
151+
if [ "${{ inputs.is-yjit }}" = "true" ]; then
152+
test_all_test_suite="yjit-${test_all_test_suite}"
153+
btest_test_suite="yjit-${btest_test_suite}"
154+
fi
155+
launchable record build --name "${build_name}"
156+
if [ "${test_all_enabled}" = "true" ]; then
157+
launchable record session \
158+
--build "${build_name}" \
159+
--flavor os=${{ inputs.os }} \
160+
--flavor test_task=${{ inputs.test-task }} \
161+
--flavor test_opts=${test_opts} \
162+
--test-suite ${test_all_test_suite} \
163+
> "${test_all_session_file}"
164+
echo "TESTS=${TESTS} --launchable-test-reports=${test_all_report_file}" >> $GITHUB_ENV
165+
fi
166+
if [ "${btest_enabled}" = "true" ]; then
167+
launchable record session \
168+
--build "${build_name}" \
169+
--flavor os=${{ inputs.os }} \
170+
--flavor test_task=${{ inputs.test-task }} \
171+
--flavor test_opts=${test_opts} \
172+
--test-suite ${btest_test_suite} \
173+
> "${btest_session_file}"
174+
echo "BTESTS=${BTESTS} --launchable-test-reports=${btest_report_file}" >> $GITHUB_ENV
175+
fi
126176
if: steps.enable-launchable.outputs.enable-launchable
177+
env:
178+
test_all_enabled: ${{ steps.global.outputs.test_all_enabled }}
179+
btest_enabled: ${{ steps.global.outputs.btest_enabled }}
180+
test_all_session_file: ${{ steps.global.outputs.test_all_session_file }}
181+
btest_session_file: ${{ steps.global.outputs.btest_session_file }}
182+
test_all_report_file: ${{ steps.global.outputs.test_all_report_file }}
183+
btest_report_file: ${{ steps.global.outputs.btest_report_file }}
127184

128185
- name: Variables to report Launchable
129186
id: variables
130187
shell: bash
131188
run: |
132189
set -x
133-
: # flavor
134-
test_opts="${{ inputs.test-opts }}"
135-
test_opts="${test_opts// /}"
136-
test_opts="${test_opts//=/:}"
137-
echo test-opts="$test_opts" >> $GITHUB_OUTPUT
138190
: # report-path from srcdir
139191
if [ "${srcdir}" = "${{ github.workspace }}" ]; then
140192
dir=
141193
else
142194
# srcdir must be equal to or under workspace
143195
dir=$(echo ${srcdir:+${srcdir}/} | sed 's:[^/][^/]*/:../:g')
144196
fi
145-
report_path="${dir}${builddir:+${builddir}/}${report_path}"
146-
echo report-path="${report_path}" >> $GITHUB_OUTPUT
197+
if [ "${test_all_enabled}" = "true" ]; then
198+
test_report_path="${dir}${builddir:+${builddir}/}${test_all_report_file}"
199+
echo test_report_path="${test_report_path}" >> $GITHUB_OUTPUT
200+
fi
201+
if [ "${btest_enabled}" = "true" ]; then
202+
btest_report_path="${dir}${builddir:+${builddir}/}${btest_report_file}"
203+
echo btest_report_path="${btest_report_path}" >> $GITHUB_OUTPUT
204+
fi
147205
if: steps.enable-launchable.outputs.enable-launchable
148206
env:
149207
srcdir: ${{ inputs.srcdir }}
150208
builddir: ${{ inputs.builddir }}
151-
report_path: ${{ inputs.report-path }}
209+
test_all_enabled: ${{ steps.global.outputs.test_all_enabled }}
210+
btest_enabled: ${{ steps.global.outputs.btest_enabled }}
211+
test_all_report_file: ${{ steps.global.outputs.test_all_report_file }}
212+
btest_report_file: ${{ steps.global.outputs.btest_report_file }}
152213

153214
- name: Record test results in Launchable
154215
uses: gacts/run-and-post-run@674528335da98a7afc80915ff2b4b860a0b3553a # v1.4.0
155216
with:
156217
shell: bash
157218
working-directory: ${{ inputs.srcdir }}
158219
post: |
159-
: # record
160-
launchable record tests --flavor os=${{ inputs.os }} --flavor test_task=${{ inputs.test-task }} --flavor test_opts=${test_opts} raw ${report_path}
161-
rm -f ${report_path}
220+
[[ "${test_all_enabled}" = "true" ]] && \
221+
launchable record tests \
222+
--session "$(cat "${test_all_session_file}")" \
223+
raw "${test_report_path}" || true
224+
225+
[[ "${btest_enabled}" = "true" ]] && \
226+
launchable record tests \
227+
--session "$(cat "${btest_session_file}")" \
228+
raw "${btest_report_path}" || true
229+
230+
rm -f "${test_all_session_file}"
231+
rm -f "${btest_session_file}"
232+
rm -f "${test_report_path}"
233+
rm -f "${btest_report_path}"
162234
if: ${{ always() && steps.enable-launchable.outputs.enable-launchable }}
163235
env:
164-
test_opts: ${{ steps.variables.outputs.test-opts }}
165-
report_path: ${{ steps.variables.outputs.report-path }}
236+
test_report_path: ${{ steps.variables.outputs.test_report_path }}
237+
btest_report_path: ${{ steps.variables.outputs.btest_report_path }}
238+
test_all_enabled: ${{ steps.global.outputs.test_all_enabled }}
239+
btest_enabled: ${{ steps.global.outputs.btest_enabled }}
240+
test_all_session_file: ${{ steps.global.outputs.test_all_session_file }}
241+
btest_session_file: ${{ steps.global.outputs.btest_session_file }}

.github/workflows/mingw.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,10 @@ jobs:
123123
uses: ./.github/actions/launchable/setup
124124
with:
125125
os: windows-2022
126-
# If we support new test task, we need to change this test-opts.
127-
test-opts: --retry --job-status=normal --show-skip --timeout-scale=1.5
128-
${{ matrix.test-all-opts }}
129126
launchable-token: ${{ secrets.LAUNCHABLE_TOKEN }}
130127
builddir: build
131128
srcdir: src
129+
test-tasks: '["test", "test-all"]'
132130
continue-on-error: true
133131

134132
- name: test

.github/workflows/rjit.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,11 @@ jobs:
8383
uses: ./.github/actions/launchable/setup
8484
with:
8585
os: ubuntu-22.04
86-
test-task: test
8786
launchable-token: ${{ secrets.LAUNCHABLE_TOKEN }}
8887
builddir: build
8988
srcdir: src
90-
launchable-workspace: ruby-make-btest
9189
test-opts: ${{ matrix.run_opts }}
90+
test-tasks: '["test", "test-all"]'
9291
continue-on-error: true
9392

9493
- name: make test
@@ -103,8 +102,10 @@ jobs:
103102
RUN_OPTS: ${{ matrix.run_opts }}
104103

105104
- name: make test-all
106-
run: |
107-
$SETARCH make -s test-all RUN_OPTS="$RUN_OPTS"
105+
run: >-
106+
$SETARCH make -s test-all
107+
RUN_OPTS="$RUN_OPTS"
108+
${TESTS:+TESTS="$TESTS"}
108109
timeout-minutes: 60
109110
env:
110111
GNUMAKEFLAGS: ''

.github/workflows/windows.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ jobs:
181181
launchable-token: ${{ secrets.LAUNCHABLE_TOKEN }}
182182
builddir: build
183183
srcdir: src
184+
test-task: ${{ matrix.test_task || 'check' }}
184185
continue-on-error: true
185186
if: ${{ matrix.test_task != 'test-bundled-gems' }}
186187

.github/workflows/yjit-macos.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ jobs:
124124
launchable-token: ${{ secrets.LAUNCHABLE_TOKEN }}
125125
builddir: build
126126
srcdir: src
127+
is-yjit: true
127128
continue-on-error: true
128129

129130
- name: make ${{ matrix.test_task }}

.github/workflows/yjit-ubuntu.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ jobs:
177177
launchable-token: ${{ secrets.LAUNCHABLE_TOKEN }}
178178
builddir: build
179179
srcdir: src
180+
is-yjit: true
180181
continue-on-error: true
181182

182183
- name: make ${{ matrix.test_task }}

0 commit comments

Comments
 (0)