Skip to content

Commit de50236

Browse files
authored
Enable Launchable integration in compilers.yml (ruby#12136)
1 parent f1b576e commit de50236

File tree

4 files changed

+82
-17
lines changed

4 files changed

+82
-17
lines changed

.github/actions/compilers/action.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,16 @@ runs:
7777
- shell: bash
7878
run: docker pull --quiet 'ghcr.io/ruby/ruby-ci-image:${{ inputs.tag }}'
7979

80+
- name: Enable Launchable conditionally
81+
id: enable-launchable
82+
run: echo "enable-launchable=true" >> $GITHUB_OUTPUT
83+
shell: bash
84+
if: >-
85+
${{
86+
github.repository == 'ruby/ruby' ||
87+
(github.repository != 'ruby/ruby' && env.LAUNCHABLE_TOKEN)
88+
}}
89+
8090
- name: compile
8191
shell: bash
8292
run: >-
@@ -98,4 +108,18 @@ runs:
98108
--env INPUT_MSPECOPT='${{ inputs.mspecopt }}'
99109
--env INPUT_ENABLE_SHARED='${{ inputs.enable_shared }}'
100110
--env INPUT_STATIC_EXTS='${{ inputs.static_exts }}'
111+
--env LAUNCHABLE_ORGANIZATION='${{ github.repository_owner }}'
112+
--env LAUNCHABLE_WORKSPACE='${{ github.event.repository.name }}'
113+
--env LAUNCHABLE_ENABLED='${{ steps.enable-launchable.outputs.enable-launchable || false }}'
114+
--env GITHUB_PR_HEAD_SHA='${{ github.event.pull_request.head.sha || github.sha }}'
115+
--env GITHUB_PULL_REQUEST_URL='${{ github.event.pull_request.html_url }}'
116+
--env GITHUB_REF='${{ github.ref }}'
117+
--env GITHUB_ACTIONS
118+
--env GITHUB_RUN_ID
119+
--env GITHUB_REPOSITORY
120+
--env GITHUB_WORKFLOW
121+
--env GITHUB_RUN_NUMBER
122+
--env GITHUB_EVENT_NAME
123+
--env GITHUB_SHA
124+
--env GITHUB_HEAD_REF
101125
'ghcr.io/ruby/ruby-ci-image:${{ inputs.tag }}'

.github/actions/compilers/entrypoint.sh

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,49 @@ if [[ -n "${INPUT_STATIC_EXTS}" ]]; then
7070
echo "::endgroup::"
7171
fi
7272

73+
ruby_test_opts=''
74+
tests=''
75+
76+
# Launchable
77+
setup_launchable() {
78+
pushd ${srcdir}
79+
# Launchable creates .launchable file in the current directory, but cannot a file to ${srcdir} directory.
80+
# As a workaround, we set LAUNCHABLE_SESSION_DIR to ${builddir}.
81+
export LAUNCHABLE_SESSION_DIR=${builddir}
82+
local github_ref="${GITHUB_REF//\//_}"
83+
boot_report_path='launchable_bootstraptest.json'
84+
test_report_path='launchable_test_all.json'
85+
ruby_test_opts+=--launchable-test-reports="${boot_report_path}"
86+
tests+=--launchable-test-reports="${test_report_path}"
87+
grouped launchable record build --name "${github_ref}"_"${GITHUB_PR_HEAD_SHA}" || true
88+
trap launchable_record_test EXIT
89+
}
90+
launchable_record_test() {
91+
pushd "${builddir}"
92+
grouped launchable record tests --flavor test_task=test --test-suite bootstraptest raw "${boot_report_path}" || true
93+
if [ "$INPUT_CHECK" = "true" ]; then
94+
grouped launchable record tests --flavor test_task=test-all --test-suite test-all raw "${test_report_path}" || true
95+
fi
96+
}
97+
if [ "$LAUNCHABLE_ENABLED" = "true" ]; then
98+
setup_launchable
99+
fi
100+
73101
pushd ${builddir}
74102

75103
grouped make showflags
76104
grouped make all
77-
grouped make test
105+
grouped make test RUBY_TESTOPTS="${ruby_test_opts}"
78106

79107
[[ -z "${INPUT_CHECK}" ]] && exit 0
80108

81109
if [ "$INPUT_CHECK" = "true" ]; then
82-
tests="ruby -ext-"
110+
tests+=" -- ruby -ext-"
83111
else
84-
tests="$INPUT_CHECK"
112+
tests+=" -- $INPUT_CHECK"
85113
fi
86114

87115
# grouped make install
88116
grouped make test-tool
89-
grouped make test-all TESTS="-- $tests"
117+
grouped make test-all TESTS="$tests"
90118
grouped env CHECK_LEAKS=true make test-spec MSPECOPT="$INPUT_MSPECOPT"

.github/workflows/compilers.yml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ jobs:
5454
steps:
5555
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
5656
with: { sparse-checkout-cone-mode: false, sparse-checkout: /.github }
57-
- { uses: './.github/actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true } }
57+
# Set fetch-depth: 10 so that Launchable can receive commits information.
58+
- { uses: './.github/actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true, fetch-depth: 10 } }
5859
- name: 'clang 18 LTO'
5960
uses: './.github/actions/compilers'
6061
with:
@@ -74,7 +75,7 @@ jobs:
7475
steps:
7576
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
7677
with: { sparse-checkout-cone-mode: false, sparse-checkout: /.github }
77-
- { uses: './.github/actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true } }
78+
- { uses: './.github/actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true, fetch-depth: 10 } }
7879
- name: 'GCC 13 LTO'
7980
uses: './.github/actions/compilers'
8081
with:
@@ -101,7 +102,7 @@ jobs:
101102
steps:
102103
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
103104
with: { sparse-checkout-cone-mode: false, sparse-checkout: /.github }
104-
- { uses: './.github/actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true } }
105+
- { uses: './.github/actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true, fetch-depth: 10 } }
105106
- { uses: './.github/actions/compilers', name: 'clang 20', with: { tag: 'clang-20' } }
106107
- { uses: './.github/actions/compilers', name: 'clang 19', with: { tag: 'clang-19' } }
107108
- { uses: './.github/actions/compilers', name: 'clang 18', with: { tag: 'clang-18' } }
@@ -119,7 +120,7 @@ jobs:
119120
steps:
120121
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
121122
with: { sparse-checkout-cone-mode: false, sparse-checkout: /.github }
122-
- { uses: './.github/actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true } }
123+
- { uses: './.github/actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true, fetch-depth: 10 } }
123124
- { uses: './.github/actions/compilers', name: 'clang 13', with: { tag: 'clang-13' } }
124125
- { uses: './.github/actions/compilers', name: 'clang 12', with: { tag: 'clang-12' } }
125126
- { uses: './.github/actions/compilers', name: 'clang 11', with: { tag: 'clang-11' } }
@@ -139,7 +140,7 @@ jobs:
139140
steps:
140141
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
141142
with: { sparse-checkout-cone-mode: false, sparse-checkout: /.github }
142-
- { uses: './.github/actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true } }
143+
- { uses: './.github/actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true, fetch-depth: 10 } }
143144
# -Wno-strict-prototypes is necessary with current clang-15 since
144145
# older autoconf generate functions without prototype and -pedantic
145146
# now implies strict-prototypes. Disabling the error but leaving the
@@ -164,7 +165,7 @@ jobs:
164165
steps:
165166
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
166167
with: { sparse-checkout-cone-mode: false, sparse-checkout: /.github }
167-
- { uses: './.github/actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true } }
168+
- { uses: './.github/actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true, fetch-depth: 10 } }
168169
- { uses: './.github/actions/compilers', name: 'C++20', with: { CXXFLAGS: '-std=c++20 -Werror=pedantic -pedantic-errors -Wno-c++11-long-long' } }
169170
- { uses: './.github/actions/compilers', name: 'C++23', with: { CXXFLAGS: '-std=c++23 -Werror=pedantic -pedantic-errors -Wno-c++11-long-long' } }
170171
- { uses: './.github/actions/compilers', name: 'C++26', with: { CXXFLAGS: '-std=c++26 -Werror=pedantic -pedantic-errors -Wno-c++11-long-long' } }
@@ -183,7 +184,7 @@ jobs:
183184
steps:
184185
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
185186
with: { sparse-checkout-cone-mode: false, sparse-checkout: /.github }
186-
- { uses: './.github/actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true } }
187+
- { uses: './.github/actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true, fetch-depth: 10 } }
187188
- { uses: './.github/actions/compilers', name: 'disable-jit', with: { append_configure: '--disable-yjit --disable-rjit' } }
188189
- { uses: './.github/actions/compilers', name: 'disable-dln', with: { append_configure: '--disable-dln' } }
189190
- { uses: './.github/actions/compilers', name: 'enable-mkmf-verbose', with: { append_configure: '--enable-mkmf-verbose' } }
@@ -202,7 +203,7 @@ jobs:
202203
steps:
203204
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
204205
with: { sparse-checkout-cone-mode: false, sparse-checkout: /.github }
205-
- { uses: './.github/actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true } }
206+
- { uses: './.github/actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true, fetch-depth: 10 } }
206207
- { uses: './.github/actions/compilers', name: 'NDEBUG', with: { cppflags: '-DNDEBUG' } }
207208
- { uses: './.github/actions/compilers', name: 'RUBY_DEBUG', with: { cppflags: '-DRUBY_DEBUG' } }
208209
- { uses: './.github/actions/compilers', name: 'ARRAY_DEBUG', with: { cppflags: '-DARRAY_DEBUG' } }
@@ -221,7 +222,7 @@ jobs:
221222
steps:
222223
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
223224
with: { sparse-checkout-cone-mode: false, sparse-checkout: /.github }
224-
- { uses: './.github/actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true } }
225+
- { uses: './.github/actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true, fetch-depth: 10 } }
225226
- { uses: './.github/actions/compilers', name: 'HASH_DEBUG', with: { cppflags: '-DHASH_DEBUG' } }
226227
- { uses: './.github/actions/compilers', name: 'ID_TABLE_DEBUG', with: { cppflags: '-DID_TABLE_DEBUG' } }
227228
- { uses: './.github/actions/compilers', name: 'RGENGC_DEBUG=-1', with: { cppflags: '-DRGENGC_DEBUG=-1' } }
@@ -240,7 +241,7 @@ jobs:
240241
steps:
241242
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
242243
with: { sparse-checkout-cone-mode: false, sparse-checkout: /.github }
243-
- { uses: './.github/actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true } }
244+
- { uses: './.github/actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true, fetch-depth: 10 } }
244245
- { uses: './.github/actions/compilers', name: 'USE_LAZY_LOAD', with: { cppflags: '-DUSE_LAZY_LOAD' } }
245246
- { uses: './.github/actions/compilers', name: 'USE_SYMBOL_GC=0', with: { cppflags: '-DUSE_SYMBOL_GC=0' } }
246247
- { uses: './.github/actions/compilers', name: 'USE_THREAD_CACHE=0', with: { cppflags: '-DUSE_THREAD_CACHE=0' } }
@@ -259,7 +260,7 @@ jobs:
259260
steps:
260261
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
261262
with: { sparse-checkout-cone-mode: false, sparse-checkout: /.github }
262-
- { uses: './.github/actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true } }
263+
- { uses: './.github/actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true, fetch-depth: 10 } }
263264
- { uses: './.github/actions/compilers', name: 'GC_DEBUG_STRESS_TO_CLASS', with: { cppflags: '-DGC_DEBUG_STRESS_TO_CLASS' } }
264265
- { uses: './.github/actions/compilers', name: 'GC_ENABLE_LAZY_SWEEP=0', with: { cppflags: '-DGC_ENABLE_LAZY_SWEEP=0' } }
265266
- { uses: './.github/actions/compilers', name: 'GC_PROFILE_DETAIL_MEMORY', with: { cppflags: '-DGC_PROFILE_DETAIL_MEMORY' } }
@@ -278,7 +279,7 @@ jobs:
278279
steps:
279280
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
280281
with: { sparse-checkout-cone-mode: false, sparse-checkout: /.github }
281-
- { uses: './.github/actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true } }
282+
- { uses: './.github/actions/setup/directories', with: { srcdir: 'src', builddir: 'build', makeup: true, fetch-depth: 10 } }
282283
- { uses: './.github/actions/compilers', name: 'VM_DEBUG_BP_CHECK', with: { cppflags: '-DVM_DEBUG_BP_CHECK' } }
283284
- { uses: './.github/actions/compilers', name: 'VM_DEBUG_VERIFY_METHOD_CACHE', with: { cppflags: '-DVM_DEBUG_VERIFY_METHOD_CACHE' } }
284285
- { uses: './.github/actions/compilers', name: 'enable-yjit', with: { append_configure: '--enable-yjit --disable-rjit' } }

bootstraptest/runner.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,19 @@ def main
236236
return true
237237
end
238238

239-
require_relative '../tool/lib/launchable'
239+
begin
240+
require_relative '../tool/lib/launchable'
241+
rescue LoadError
242+
# The following error sometimes happens, so we're going to skip writing Launchable report files in this case.
243+
#
244+
# ```
245+
# /tmp/tmp.bISss9CtXZ/.ext/common/json/ext.rb:15:in 'Kernel#require':
246+
# /tmp/tmp.bISss9CtXZ/.ext/x86_64-linux/json/ext/parser.so:
247+
# undefined symbol: ruby_abi_version - ruby_abi_version (LoadError)
248+
# ```
249+
#
250+
return true
251+
end
240252
BT.launchable_test_reports = writer = Launchable::JsonStreamWriter.new($1)
241253
writer.write_array('testCases')
242254
at_exit {

0 commit comments

Comments
 (0)