Skip to content

Commit

Permalink
Report to Launchable at post-run
Browse files Browse the repository at this point in the history
Instead of separate two actions, register the post run at setup.

Co-authored-by: Naoto Ono <onoto1998@gmail.com>
  • Loading branch information
nobu and ono-max committed Mar 10, 2024
1 parent d94ad00 commit 8e3cb69
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 63 deletions.
40 changes: 0 additions & 40 deletions .github/actions/launchable/record-test/action.yml

This file was deleted.

59 changes: 58 additions & 1 deletion .github/actions/launchable/setup/action.yml
Expand Up @@ -8,12 +8,29 @@ inputs:
required: true
description: The file path of the test report for uploading to Launchable

os:
required: true
description: The operating system that CI runs on. This value is used in Launchable flavor.

test-opts:
default: none
required: false
description: >-
Test options that determine how tests are run.
This value is used in the Launchable flavor.
launchable-token:
required: false
description: >-
Launchable token is needed if you want to run Launchable on your forked repository.
See https://github.com/ruby/ruby/wiki/CI-Servers#launchable-ci for details.
builddir:
required: false
default: ${{ github.workspace }}
description: >-
Directory to create Launchable report file.
srcdir:
required: false
default: ${{ github.workspace }}
Expand Down Expand Up @@ -81,7 +98,8 @@ runs:
pip install --user launchable
launchable verify
: # The build name cannot include a slash, so we replace the string here.
github_ref="$(echo ${{ github.ref }} | sed 's/\//_/g')"
github_ref="${{ github.ref }}"
github_ref="${github_ref//\//_}"
: # With the --name option, we need to configure a unique identifier for this build.
: # To avoid setting the same build name as the CI which runs on other branches, we use the branch name here.
: #
Expand All @@ -90,3 +108,42 @@ runs:
launchable record build --name ${github_ref}_${GITHUB_PR_HEAD_SHA}
echo "TESTS=${TESTS} --launchable-test-reports=${{ inputs.report-path }}" >> $GITHUB_ENV
if: steps.enable-launchable.outputs.enable-launchable

- name: Variables to report Launchable
id: variables
shell: bash
run: |
set -x
: # flavor
test_opts="${{ inputs.test-opts }}"
test_opts="${test_opts// /}"
test_opts="${test_opts//=/:}"
echo test-opts="$test_opts" >> $GITHUB_OUTPUT
: # report-path from srcdir
if [ "${srcdir}" = "${{ github.workspace }}" ]; then
dir=
else
# srcdir must be equal to or under workspace
dir=$(echo ${srcdir:+${srcdir}/} | sed 's:[^/][^/]*/:../:g')
fi
report_path="${dir}${builddir:+${builddir}/}${report_path}"
echo report-path="${report_path}" >> $GITHUB_OUTPUT
if: steps.enable-launchable.outputs.enable-launchable
env:
srcdir: ${{ inputs.srcdir }}
builddir: ${{ inputs.builddir }}
report_path: ${{ inputs.report-path }}

- name: Record test results in Launchable
uses: gacts/run-and-post-run@674528335da98a7afc80915ff2b4b860a0b3553a # v1.4.0
with:
shell: bash
working-directory: ${{ inputs.srcdir }}
post: |
: # record
launchable record tests --flavor os=${{ inputs.os }} --flavor test_task=${{ matrix.test_task }} --flavor test_opts=${test_opts} raw ${report_path}
rm -f ${report_path}
if: ${{ always() && steps.enable-launchable.outputs.enable-launchable }}
env:
test_opts: ${{ steps.variables.outputs.test-opts }}
report_path: ${{ steps.variables.outputs.report-path }}
14 changes: 3 additions & 11 deletions .github/workflows/macos.yml
Expand Up @@ -90,7 +90,10 @@ jobs:
id: enable-launchable
uses: ./.github/actions/launchable/setup
with:
os: ${{ matrix.os }}
test-opts: ${{ matrix.test_opts }}
launchable-token: ${{ secrets.LAUNCHABLE_TOKEN }}
builddir: build
srcdir: src

- name: Set extra test options
Expand All @@ -116,17 +119,6 @@ jobs:
if: ${{ matrix.test_task == 'check' && matrix.skipped_tests }}
continue-on-error: ${{ matrix.continue-on-skipped_tests || false }}

- name: Record test results in Launchable
uses: ./.github/actions/launchable/record-test
with:
# We need to configure the `build` directory because
# this composite action is executed in the default working directory.
report-path: ../build/launchable_reports.json
os: ${{ matrix.os }}
test-opts: ${{ matrix.test_opts }}
srcdir: src
if: ${{ always() && steps.enable-launchable.outputs.enable-launchable }}

- uses: ./.github/actions/slack
with:
label: ${{ matrix.os }} / ${{ matrix.test_task }}
Expand Down
14 changes: 3 additions & 11 deletions .github/workflows/ubuntu.yml
Expand Up @@ -107,7 +107,10 @@ jobs:
id: enable-launchable
uses: ./.github/actions/launchable/setup
with:
os: ${{ matrix.os }}
test-opts: ${{ matrix.configure }}
launchable-token: ${{ secrets.LAUNCHABLE_TOKEN }}
builddir: build
srcdir: src

- name: make ${{ matrix.test_task }}
Expand All @@ -130,17 +133,6 @@ jobs:
if: ${{ matrix.test_task == 'check' && matrix.skipped_tests }}
continue-on-error: ${{ matrix.continue-on-skipped_tests || false }}

- name: Record test results in Launchable
uses: ./.github/actions/launchable/record-test
with:
# We need to configure the `build` directory because
# this composite action is executed in the default working directory.
report-path: ../build/launchable_reports.json
os: ubuntu-20.04
test-opts: ${{ matrix.configure }}
srcdir: src
if: ${{ always() && steps.enable-launchable.outputs.enable-launchable }}

- uses: ./.github/actions/slack
with:
label: ${{ matrix.test_task }} ${{ matrix.configure }}${{ matrix.arch }}
Expand Down

0 comments on commit 8e3cb69

Please sign in to comment.