From a56648adb02b14a224004748dab230f26c7fb76a Mon Sep 17 00:00:00 2001 From: Scott J Dickerson Date: Wed, 10 Apr 2024 20:24:02 -0400 Subject: [PATCH] :seedling: Fix global-ci workflow parsing for test refs Resolves: #31 - Pass the github event PR description via a step env variable to avoid any string interpolation problems. - Report the calculated test ref (`GOLANG_TESTS_REF` and `UI_TESTS_REF`) via step summary so it is easy to see in the action summary page. - Bump `actions/checkout` to `@v4` to fix its deprecated warning. Signed-off-by: Scott J Dickerson --- .github/workflows/global-ci.yml | 37 +++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/.github/workflows/global-ci.yml b/.github/workflows/global-ci.yml index 7626f02..77b26e4 100644 --- a/.github/workflows/global-ci.yml +++ b/.github/workflows/global-ci.yml @@ -130,16 +130,19 @@ jobs: if: ${{ inputs.run_api_tests }} steps: - name: Extract pull request number from inputs or PR description + env: + body: ${{ github.event.pull_request.body }} run: | - PULL_REQUEST_NUMBER=$(echo "${{ github.event.pull_request.body }}" | grep -oP '[A|a][P|p][I|i] [T|t]ests [P|p][R|r]:\s*\K\d+' || true) - if [ -z "$PULL_REQUEST_NUMBER" ]; then - echo "GOLANG_TESTS_REF=${{ inputs.api_tests_ref }}" >>$GITHUB_ENV - else - echo "GOLANG_TESTS_REF=refs/pull/$PULL_REQUEST_NUMBER/merge" >>$GITHUB_ENV - fi + PULL_REQUEST_NUMBER=$(echo ${body} | grep -oP '[A|a][P|p][I|i] [T|t]ests [P|p][R|r]:\s*\K\d+' || true) + [ -z "$PULL_REQUEST_NUMBER" ] \ + && GOLANG_TESTS_REF=${{ inputs.api_tests_ref }} \ + || GOLANG_TESTS_REF=refs/pull/$PULL_REQUEST_NUMBER/merge + + echo "GOLANG_TESTS_REF=${GOLANG_TESTS_REF}" >>"$GITHUB_ENV" + echo "Using GOLANG_TESTS_REF \`${GOLANG_TESTS_REF}\`" >>"$GITHUB_STEP_SUMMARY" - name: Checkout golang api tests repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: konveyor/go-konveyor-tests path: go-konveyor-tests @@ -207,19 +210,22 @@ jobs: matrix: # TODO enable customizing the number of tiers run for nightlies tier: [tier0] #, tier1, tier2, tier3] - steps: + steps: - name: Extract pull request number from inputs or PR description + env: + body: ${{ github.event.pull_request.body }} run: | - PULL_REQUEST_NUMBER=$(echo "${{ github.event.pull_request.body }}" | grep -oP '[U|u][I|i] [T|t]ests [P|p][R|r]: \K\d+' || true) - if [ -z "$PULL_REQUEST_NUMBER" ]; then - echo "UI_TESTS_REF=${{ inputs.ui_tests_ref }}" >>$GITHUB_ENV - else - echo "UI_TESTS_REF=refs/pull/$PULL_REQUEST_NUMBER/merge" >>$GITHUB_ENV - fi + PULL_REQUEST_NUMBER=$(echo ${body} | grep -oP '[U|u][I|i] [T|t]ests [P|p][R|r]: \K\d+' || true) + [ -z "$PULL_REQUEST_NUMBER" ] \ + && UI_TESTS_REF=${{ inputs.ui_tests_ref }} \ + || UI_TESTS_REF=refs/pull/$PULL_REQUEST_NUMBER/merge + + echo "UI_TESTS_REF=${UI_TESTS_REF}" >>"$GITHUB_ENV" + echo "Using UI_TESTS_REF \`${UI_TESTS_REF}\`" >>"$GITHUB_STEP_SUMMARY" - name: Checkout ui tests repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: konveyor/tackle-ui-tests path: tackle-ui-tests @@ -304,7 +310,6 @@ jobs: uses: actions/upload-artifact@v3 if: always() with: - # name: tackle-ui-test-reports-${{ matrix.split }} name: tackle-ui-test-reports-${{ matrix.tier }} path: | tackle-ui-tests/cypress/reports