Skip to content

Commit 7377b65

Browse files
committed
Add Launchable in CI
1 parent 983655c commit 7377b65

File tree

7 files changed

+119
-0
lines changed

7 files changed

+119
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Set up Launchable
2+
description: >-
3+
Install the required dependencies and execute the necessary Launchable commands for test recording
4+
5+
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+
11+
test-task:
12+
default: none
13+
required: true
14+
description: >-
15+
Test task that determine how tests are run.
16+
This value is used in the Launchable flavor.
17+
18+
runs:
19+
using: composite
20+
21+
steps:
22+
- name: Enable Launchable conditionally
23+
id: enable-launchable
24+
run: echo "enable-launchable=true" >> $GITHUB_OUTPUT
25+
shell: bash
26+
if: ${{ github.repository == 'ruby/debug' }}
27+
28+
# Launchable CLI requires Python and Java.
29+
# https://www.launchableinc.com/docs/resources/cli-reference/
30+
- name: Set up Python
31+
uses: actions/setup-python@871daa956ca9ea99f3c3e30acb424b7960676734 # v5.0.0
32+
with:
33+
python-version: "3.x"
34+
if: ${{ steps.enable-launchable.outputs.enable-launchable }}
35+
36+
- name: Set up Java
37+
uses: actions/setup-java@7a445ee88d4e23b52c33fdc7601e40278616c7f8 # v4.0.0
38+
with:
39+
distribution: 'temurin'
40+
java-version: '17'
41+
if: ${{ steps.enable-launchable.outputs.enable-launchable }}
42+
43+
- name: Set environment variables for Launchable
44+
shell: bash
45+
run: |
46+
: # GITHUB_PULL_REQUEST_URL are used for commenting test reports in Launchable Github App.
47+
: # https://github.com/launchableinc/cli/blob/v1.80.1/launchable/utils/link.py#L42
48+
echo "GITHUB_PULL_REQUEST_URL=${{ github.event.pull_request.html_url }}" >> $GITHUB_ENV
49+
: # The following envs are necessary in Launchable tokenless authentication.
50+
: # https://github.com/launchableinc/cli/blob/v1.80.1/launchable/utils/authentication.py#L20
51+
echo "LAUNCHABLE_ORGANIZATION=${{ github.repository_owner }}" >> $GITHUB_ENV
52+
echo "LAUNCHABLE_WORKSPACE=${{ github.event.repository.name }}" >> $GITHUB_ENV
53+
: # https://github.com/launchableinc/cli/blob/v1.80.1/launchable/utils/authentication.py#L71
54+
echo "GITHUB_PR_HEAD_SHA=${{ github.event.pull_request.head.sha || github.sha }}" >> $GITHUB_ENV
55+
if: ${{ steps.enable-launchable.outputs.enable-launchable }}
56+
57+
- name: Set up Launchable
58+
shell: bash
59+
run: |
60+
set -x
61+
PATH=$PATH:$(python -msite --user-base)/bin
62+
echo "PATH=$PATH" >> $GITHUB_ENV
63+
pip install --user launchable
64+
launchable verify
65+
: # The build name cannot include a slash, so we replace the string here.
66+
github_ref="${{ github.ref }}"
67+
github_ref="${github_ref//\//_}"
68+
launchable record build --name ${github_ref}_${GITHUB_PR_HEAD_SHA}
69+
echo "TESTOPTS=${TESTOPTS} --runner=launchable --launchable-test-report-json=${{ inputs.report-path }}" >> $GITHUB_ENV
70+
if: ${{ steps.enable-launchable.outputs.enable-launchable }}
71+
72+
- name: Record test results in Launchable
73+
uses: gacts/run-and-post-run@674528335da98a7afc80915ff2b4b860a0b3553a # v1.4.0
74+
with:
75+
shell: bash
76+
post: |
77+
launchable record tests --flavor os=${{ inputs.os }} --flavor test_task=${{ inputs.test-task }} file ${{ inputs.report-path }}
78+
rm -f ${{ inputs.report-path }}
79+
if: ${{ always() && steps.enable-launchable.outputs.enable-launchable }}

.github/workflows/protocol.yml

+8
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ jobs:
2525

2626
steps:
2727
- uses: actions/checkout@v4
28+
with:
29+
# Set fetch-depth: 10 so that Launchable can receive commits information.
30+
fetch-depth: 10
31+
- name: Set up Launchable
32+
uses: ./.github/actions/launchable/setup
33+
with:
34+
os: ubuntu-latest
35+
test-task: test_protocol
2836
- name: Set up Ruby
2937
uses: ruby/setup-ruby@v1
3038
with:

.github/workflows/ruby-macos.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ jobs:
2424

2525
steps:
2626
- uses: actions/checkout@v4
27+
with:
28+
# Set fetch-depth: 10 so that Launchable can receive commits information.
29+
fetch-depth: 10
30+
- name: Set up Launchable
31+
uses: ./.github/actions/launchable/setup
32+
with:
33+
os: macos-latest
34+
test-task: test_console
2735
- name: Set up Ruby
2836
uses: ruby/setup-ruby@v1
2937
with:

.github/workflows/ruby.yml

+8
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ jobs:
2525

2626
steps:
2727
- uses: actions/checkout@v4
28+
with:
29+
# Set fetch-depth: 10 so that Launchable can receive commits information.
30+
fetch-depth: 10
31+
- name: Set up Launchable
32+
uses: ./.github/actions/launchable/setup
33+
with:
34+
os: ubuntu-latest
35+
test-task: test_console
2836
- name: Set up Ruby
2937
uses: ruby/setup-ruby@v1
3038
with:

.github/workflows/test_test.yml

+8
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ jobs:
2525

2626
steps:
2727
- uses: actions/checkout@v4
28+
with:
29+
# Set fetch-depth: 10 so that Launchable can receive commits information.
30+
fetch-depth: 10
31+
- name: Set up Launchable
32+
uses: ./.github/actions/launchable/setup
33+
with:
34+
os: ubuntu-latest
35+
test-task: test_test
2836
- name: Set up Ruby
2937
uses: ruby/setup-ruby@v1
3038
with:

Gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ gem "rake-compiler"
77
gem "test-unit", "~> 3.0"
88
gem "test-unit-rr"
99
gem "json-schema"
10+
gem "test-unit-launchable"

test/support/test_case.rb

+7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111

1212
require_relative 'assertions'
1313

14+
# Load this library only in the debug CI to prevent LoadError
15+
# when these tests are executed in ruby/ruby.
16+
if ENV['LAUNCHABLE_ORGANIZATION'] && ENV['LAUNCHABLE_WORKSPACE']
17+
# "test/unit/runner/launchable" is used for uploading test result to Launchable.
18+
require "test/unit/runner/launchable"
19+
end
20+
1421
module DEBUGGER__
1522
class TestCase < Test::Unit::TestCase
1623
TestInfo = Struct.new(:queue, :mode, :prompt_pattern, :remote_info,

0 commit comments

Comments
 (0)