|
| 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 }} |
0 commit comments