From d2b572dc096e535b0543f2e98a5aea83d39cb963 Mon Sep 17 00:00:00 2001 From: Naoto Ono Date: Mon, 29 Jan 2024 11:35:15 +0900 Subject: [PATCH 1/4] Add launchable integration --- .github/workflows/protocol.yml | 37 ++++++++++++++++++++++++++++++- .github/workflows/ruby-macos.yaml | 37 ++++++++++++++++++++++++++++++- .github/workflows/ruby.yml | 37 ++++++++++++++++++++++++++++++- .github/workflows/test_test.yml | 37 ++++++++++++++++++++++++++++++- Gemfile | 1 + test/support/test_case.rb | 2 ++ 6 files changed, 147 insertions(+), 4 deletions(-) diff --git a/.github/workflows/protocol.yml b/.github/workflows/protocol.yml index 755557039..984819287 100644 --- a/.github/workflows/protocol.yml +++ b/.github/workflows/protocol.yml @@ -6,6 +6,17 @@ on: pull_request: branches: [ master ] +env: + # GITHUB_PULL_REQUEST_URL are used for commenting test reports in Launchable Github App. + # https://github.com/launchableinc/cli/blob/v1.80.1/launchable/utils/link.py#L42 + GITHUB_PULL_REQUEST_URL: ${{ github.event.pull_request.html_url }} + # The following envs are necessary in Launchable tokenless authentication. + # https://github.com/launchableinc/cli/blob/v1.80.1/launchable/utils/authentication.py#L20 + LAUNCHABLE_ORGANIZATION: "ruby" + LAUNCHABLE_WORKSPACE: "debug" + # https://github.com/launchableinc/cli/blob/v1.80.1/launchable/utils/authentication.py#L71 + GITHUB_PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} + jobs: test: @@ -18,6 +29,27 @@ jobs: steps: - uses: actions/checkout@v4 + with: + # Set fetch-depth: 0 so that Launchable can receive commits information. + fetch-depth: 0 + # Launchable requires Python and Java + # https://www.launchableinc.com/docs/resources/cli-reference/ + - uses: actions/setup-python@v4 + with: + python-version: "3.10" + - name: Set up JDK 1.8 + uses: actions/setup-java@v3 + with: + distribution: 'adopt' + java-version: '8' + # Setup Launchable + - name: Launchable - install command + run: pip install launchable + - name: Launchable - verify + run: launchable verify + - name: Launchable - record build + run: launchable record build --name ${GITHUB_PR_HEAD_SHA} + - name: Set up Ruby uses: ruby/setup-ruby@v1 with: @@ -27,4 +59,7 @@ jobs: run: | bundle exec rake clobber bundle exec rake compile - bundle exec rake test_protocol + TESTOPTS="--runner=junitxml --junitxml-output-file=protocol.xml" bundle exec rake test_protocol + - name: Launchable - record tests + run: launchable record tests --flavor test=protocol --flavor os=ubuntu-latest --flavor ruby=${{ matrix.ruby-version }} file protocol.xml + if: always() diff --git a/.github/workflows/ruby-macos.yaml b/.github/workflows/ruby-macos.yaml index 4b04e8647..97a072686 100644 --- a/.github/workflows/ruby-macos.yaml +++ b/.github/workflows/ruby-macos.yaml @@ -6,6 +6,17 @@ on: pull_request: branches: [ master ] +env: + # GITHUB_PULL_REQUEST_URL are used for commenting test reports in Launchable Github App. + # https://github.com/launchableinc/cli/blob/v1.80.1/launchable/utils/link.py#L42 + GITHUB_PULL_REQUEST_URL: ${{ github.event.pull_request.html_url }} + # The following envs are necessary in Launchable tokenless authentication. + # https://github.com/launchableinc/cli/blob/v1.80.1/launchable/utils/authentication.py#L20 + LAUNCHABLE_ORGANIZATION: "ruby" + LAUNCHABLE_WORKSPACE: "debug" + # https://github.com/launchableinc/cli/blob/v1.80.1/launchable/utils/authentication.py#L71 + GITHUB_PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} + jobs: test: @@ -18,6 +29,27 @@ jobs: steps: - uses: actions/checkout@v4 + with: + # Set fetch-depth: 0 so that Launchable can receive commits information. + fetch-depth: 0 + # Launchable requires Python and Java + # https://www.launchableinc.com/docs/resources/cli-reference/ + - uses: actions/setup-python@v4 + with: + python-version: "3.10" + - name: Set up JDK 1.8 + uses: actions/setup-java@v3 + with: + distribution: 'adopt' + java-version: '8' + # Setup Launchable + - name: Launchable - install command + run: pip install launchable + - name: Launchable - verify + run: launchable verify + - name: Launchable - record build + run: launchable record build --name ${GITHUB_PR_HEAD_SHA} + - name: Set up Ruby uses: ruby/setup-ruby@v1 with: @@ -27,4 +59,7 @@ jobs: run: | bundle exec rake clobber bundle exec rake compile - bundle exec rake test_console + TESTOPTS="--runner=junitxml --junitxml-output-file=ruby-macos.xml" bundle exec rake test_console + - name: launchable record tests + run: launchable record tests --flavor test=console --flavor os=macos-latest --flavor ruby=${{ matrix.ruby-version }} file ruby-macos.xml + if: always() diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index dd76ced54..c5052e5fd 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -6,6 +6,17 @@ on: pull_request: branches: [ master ] +env: + # GITHUB_PULL_REQUEST_URL are used for commenting test reports in Launchable Github App. + # https://github.com/launchableinc/cli/blob/v1.80.1/launchable/utils/link.py#L42 + GITHUB_PULL_REQUEST_URL: ${{ github.event.pull_request.html_url }} + # The following envs are necessary in Launchable tokenless authentication. + # https://github.com/launchableinc/cli/blob/v1.80.1/launchable/utils/authentication.py#L20 + LAUNCHABLE_ORGANIZATION: "ruby" + LAUNCHABLE_WORKSPACE: "debug" + # https://github.com/launchableinc/cli/blob/v1.80.1/launchable/utils/authentication.py#L71 + GITHUB_PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} + jobs: test: @@ -18,6 +29,27 @@ jobs: steps: - uses: actions/checkout@v4 + with: + # Set fetch-depth: 0 so that Launchable can receive commits information. + fetch-depth: 0 + # Launchable requires Python and Java + # https://www.launchableinc.com/docs/resources/cli-reference/ + - uses: actions/setup-python@v4 + with: + python-version: "3.10" + - name: Set up JDK 1.8 + uses: actions/setup-java@v3 + with: + distribution: 'adopt' + java-version: '8' + # Setup Launchable + - name: Launchable - install command + run: pip install launchable + - name: Launchable - verify + run: launchable verify + - name: Launchable - record build + run: launchable record build --name ${GITHUB_PR_HEAD_SHA} + - name: Set up Ruby uses: ruby/setup-ruby@v1 with: @@ -27,4 +59,7 @@ jobs: run: | bundle exec rake clobber bundle exec rake compile - bundle exec rake test_console + TESTOPTS="--runner=junitxml --junitxml-output-file=ruby.xml" bundle exec rake test_console + - name: launchable record tests + run: launchable record tests --flavor test=console --flavor os=ubuntu-latest --flavor ruby=${{ matrix.ruby-version }} file ruby.xml + if: always() diff --git a/.github/workflows/test_test.yml b/.github/workflows/test_test.yml index 3123697fe..0a45b7c34 100644 --- a/.github/workflows/test_test.yml +++ b/.github/workflows/test_test.yml @@ -6,6 +6,17 @@ on: pull_request: branches: [ master ] +env: + # GITHUB_PULL_REQUEST_URL are used for commenting test reports in Launchable Github App. + # https://github.com/launchableinc/cli/blob/v1.80.1/launchable/utils/link.py#L42 + GITHUB_PULL_REQUEST_URL: ${{ github.event.pull_request.html_url }} + # The following envs are necessary in Launchable tokenless authentication. + # https://github.com/launchableinc/cli/blob/v1.80.1/launchable/utils/authentication.py#L20 + LAUNCHABLE_ORGANIZATION: "ruby" + LAUNCHABLE_WORKSPACE: "debug" + # https://github.com/launchableinc/cli/blob/v1.80.1/launchable/utils/authentication.py#L71 + GITHUB_PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} + jobs: test: @@ -18,6 +29,27 @@ jobs: steps: - uses: actions/checkout@v4 + with: + # Set fetch-depth: 0 so that Launchable can receive commits information. + fetch-depth: 0 + # Launchable requires Python and Java + # https://www.launchableinc.com/docs/resources/cli-reference/ + - uses: actions/setup-python@v4 + with: + python-version: "3.10" + - name: Set up JDK 1.8 + uses: actions/setup-java@v3 + with: + distribution: 'adopt' + java-version: '8' + # Setup Launchable + - name: Launchable - install command + run: pip install launchable + - name: Launchable - verify + run: launchable verify + - name: Launchable - record build + run: launchable record build --name ${GITHUB_PR_HEAD_SHA} + - name: Set up Ruby uses: ruby/setup-ruby@v1 with: @@ -27,4 +59,7 @@ jobs: run: | bundle exec rake clobber bundle exec rake compile - bundle exec rake test_test + TESTOPTS="--runner=junitxml --junitxml-output-file=test_test.xml" bundle exec rake test_test + - name: launchable record tests + run: launchable record tests --flavor test=test-framework --flavor os=ubuntu-latest --flavor ruby=${{ matrix.ruby-version }} file test_test.xml + if: always() diff --git a/Gemfile b/Gemfile index c59ccbe1a..50630d1e8 100644 --- a/Gemfile +++ b/Gemfile @@ -7,3 +7,4 @@ gem "rake-compiler" gem "test-unit", "~> 3.0" gem "test-unit-rr" gem "json-schema" +gem "test-unit-runner-junitxml" diff --git a/test/support/test_case.rb b/test/support/test_case.rb index fae5b9f58..5725e8df2 100644 --- a/test/support/test_case.rb +++ b/test/support/test_case.rb @@ -7,6 +7,8 @@ require 'timeout' require 'json' require 'rbconfig' +# "test/unit/runner/junitxml" is used for reporting test result in JUnit XML format. +require "test/unit/runner/junitxml" require_relative '../../lib/debug/client' require_relative 'assertions' From a7a91aa6da34998c8b75bcb6a15e94bc22d0adb0 Mon Sep 17 00:00:00 2001 From: Naoto Ono Date: Fri, 9 Feb 2024 15:02:34 +0900 Subject: [PATCH 2/4] require "test/unit/runner/junitxml" if launchable env is configured --- test/support/test_case.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/support/test_case.rb b/test/support/test_case.rb index 5725e8df2..766dc5055 100644 --- a/test/support/test_case.rb +++ b/test/support/test_case.rb @@ -7,12 +7,15 @@ require 'timeout' require 'json' require 'rbconfig' -# "test/unit/runner/junitxml" is used for reporting test result in JUnit XML format. -require "test/unit/runner/junitxml" require_relative '../../lib/debug/client' require_relative 'assertions' +if ENV['LAUNCHABLE_ORGANIZATION'] && ENV['LAUNCHABLE_WORKSPACE'] + # "test/unit/runner/junitxml" is used for reporting test result in JUnit XML format. + require "test/unit/runner/junitxml" +end + module DEBUGGER__ class TestCase < Test::Unit::TestCase TestInfo = Struct.new(:queue, :mode, :prompt_pattern, :remote_info, From 0623e2ac7de788a3322f1094ced8c24bcbd0c63f Mon Sep 17 00:00:00 2001 From: Naoto Ono Date: Fri, 9 Feb 2024 15:11:10 +0900 Subject: [PATCH 3/4] Add comment --- test/support/test_case.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/support/test_case.rb b/test/support/test_case.rb index 766dc5055..d20f91622 100644 --- a/test/support/test_case.rb +++ b/test/support/test_case.rb @@ -11,6 +11,8 @@ require_relative 'assertions' +# Load this library only in the debug CI to prevent LoadError +# when these tests are executed in ruby/ruby. if ENV['LAUNCHABLE_ORGANIZATION'] && ENV['LAUNCHABLE_WORKSPACE'] # "test/unit/runner/junitxml" is used for reporting test result in JUnit XML format. require "test/unit/runner/junitxml" From 08d401308a87c7aa8096a691490398da7bf5b07d Mon Sep 17 00:00:00 2001 From: Naoto Ono Date: Fri, 9 Feb 2024 15:53:19 +0900 Subject: [PATCH 4/4] Use `github.sha` when running tests on the master branch --- .github/workflows/protocol.yml | 2 +- .github/workflows/ruby-macos.yaml | 2 +- .github/workflows/ruby.yml | 2 +- .github/workflows/test_test.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/protocol.yml b/.github/workflows/protocol.yml index 984819287..cfe560403 100644 --- a/.github/workflows/protocol.yml +++ b/.github/workflows/protocol.yml @@ -15,7 +15,7 @@ env: LAUNCHABLE_ORGANIZATION: "ruby" LAUNCHABLE_WORKSPACE: "debug" # https://github.com/launchableinc/cli/blob/v1.80.1/launchable/utils/authentication.py#L71 - GITHUB_PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} + GITHUB_PR_HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }} jobs: test: diff --git a/.github/workflows/ruby-macos.yaml b/.github/workflows/ruby-macos.yaml index 97a072686..5d505fae7 100644 --- a/.github/workflows/ruby-macos.yaml +++ b/.github/workflows/ruby-macos.yaml @@ -15,7 +15,7 @@ env: LAUNCHABLE_ORGANIZATION: "ruby" LAUNCHABLE_WORKSPACE: "debug" # https://github.com/launchableinc/cli/blob/v1.80.1/launchable/utils/authentication.py#L71 - GITHUB_PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} + GITHUB_PR_HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }} jobs: test: diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index c5052e5fd..c3f6e7e2d 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -15,7 +15,7 @@ env: LAUNCHABLE_ORGANIZATION: "ruby" LAUNCHABLE_WORKSPACE: "debug" # https://github.com/launchableinc/cli/blob/v1.80.1/launchable/utils/authentication.py#L71 - GITHUB_PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} + GITHUB_PR_HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }} jobs: test: diff --git a/.github/workflows/test_test.yml b/.github/workflows/test_test.yml index 0a45b7c34..c3955fc20 100644 --- a/.github/workflows/test_test.yml +++ b/.github/workflows/test_test.yml @@ -15,7 +15,7 @@ env: LAUNCHABLE_ORGANIZATION: "ruby" LAUNCHABLE_WORKSPACE: "debug" # https://github.com/launchableinc/cli/blob/v1.80.1/launchable/utils/authentication.py#L71 - GITHUB_PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} + GITHUB_PR_HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }} jobs: test: