diff --git a/.github/workflows/kickstart-tests.yml b/.github/workflows/kickstart-tests.yml index 1070abb2ada7..3d92e556ae11 100644 --- a/.github/workflows/kickstart-tests.yml +++ b/.github/workflows/kickstart-tests.yml @@ -30,8 +30,8 @@ name: kickstart-tests on: - issue_comment: - types: [created] + pull_request: + types: [opened, reopened, synchronize] permissions: contents: read @@ -42,24 +42,6 @@ jobs: if: startsWith(github.event.comment.body, '/kickstart-test') runs-on: ubuntu-latest steps: - - name: Query comment author repository permissions - uses: octokit/request-action@v2.x - id: user_permission - with: - route: GET /repos/${{ github.repository }}/collaborators/${{ github.event.sender.login }}/permission - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - # restrict running of tests to users with admin or write permission for the repository - # see https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#get-repository-permissions-for-a-user - # store output if user is allowed in allowed_user job output so it has to be checked in downstream job - - name: Check if user does have correct permissions - if: contains('admin write', fromJson(steps.user_permission.outputs.data).permission) - id: check_user_perm - run: | - echo "User '${{ github.event.sender.login }}' has permission '${{ fromJson(steps.user_permission.outputs.data).permission }}' allowed values: 'admin', 'write'" - echo "allowed_user=true" >> $GITHUB_OUTPUT - - name: Get information for pull request uses: octokit/request-action@v2.x id: pr_api @@ -68,17 +50,6 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Parse comment arguments - id: parse_comment_args - # Do not use comment body directly in the shell command to avoid possible code injection. - env: - BODY: ${{ github.event.comment.body }} - run: | - # extract first line and cut out the "/kickstart-tests" first word - ARGS=$(echo "$BODY" | sed -n '1 s/^[^ ]* *//p' | sed 's/[[:space:]]*$//') - echo "workflow arguments are: $ARGS" - echo "comment_args=${ARGS}" >> $GITHUB_OUTPUT - - name: Get timestamp id: timestamp run: echo "::set-output name=timestamp::$(date +'%Y-%m-%d_%H:%M:%S')" @@ -89,22 +60,23 @@ jobs: set -eux # comment on PR pr_num="${{ github.event.issue.number }}" - timestamp=${{ steps.teimstamp.outputs.timestamp }} + timestamp=${{ steps.timestamp.outputs.timestamp }} sha="${{ steps.pr_api.outcome == 'success' && fromJson(steps.pr_api.outputs.data).head.sha }}" echo "image_description=pr$pr_num-$timestamp-$sha" >> $GITHUB_OUTPUT fi outputs: - allowed_user: ${{ steps.check_user_perm.outputs.allowed_user }} + allowed_user: 'true' base_ref: ${{ fromJson(steps.pr_api.outputs.data).base.ref }} sha: ${{ fromJson(steps.pr_api.outputs.data).head.sha }} - comment_args: ${{ steps.parse_comment_args.outputs.comment_args }} + comment_args: '--testtype smoke' target_branch: ${{ fromJson(steps.pr_api.outputs.data).base.ref }} + timestamp: ${{steps.kstest_run_description.outputs.image_description}} run: needs: pr-info # only do this for Fedora for now; once we have RHEL 8/9 boot.iso builds working, also support these - if: needs.pr-info.outputs.allowed_user == 'true' && needs.pr-info.outputs.comment_args != '' && ! contains(github.event.comment.body, '--waive') + if: needs.pr-info.outputs.allowed_user == 'true' && needs.pr-info.outputs.comment_args != '' runs-on: [self-hosted, kstest] timeout-minutes: 300 env: @@ -336,28 +308,3 @@ jobs: target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - waive: - runs-on: ubuntu-latest - needs: pr-info - if: needs.pr-info.outputs.allowed_user == 'true' && contains(github.event.comment.body, '--waive') - steps: - - - name: Get the waiving reason - id: get_reason - env: - BODY: ${{ github.event.comment.body }} - run: | - REASON=$(echo "$BODY" | sed -e "s#/kickstart-test --waive ##" | sed 's/[[:space:]]*$//') - echo "reason=Waived, $REASON" >> $GITHUB_OUTPUT - - - name: Set status - uses: octokit/request-action@v2.x - with: - route: 'POST /repos/${{ github.repository }}/statuses/${{ needs.pr-info.outputs.sha }}' - context: 'kickstart-test --testtype smoke' - description: '${{ steps.get_reason.outputs.reason }}' - state: ${{ job.status }} - target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/kickstart-tests.yml.j2 b/.github/workflows/kickstart-tests.yml.j2 index 7d4e062b98cc..4adeb01eb19d 100644 --- a/.github/workflows/kickstart-tests.yml.j2 +++ b/.github/workflows/kickstart-tests.yml.j2 @@ -24,8 +24,8 @@ name: kickstart-tests on: - issue_comment: - types: [created] + pull_request: + types: [opened, reopened, synchronize] permissions: contents: read @@ -33,27 +33,8 @@ permissions: jobs: pr-info: - if: startsWith(github.event.comment.body, '/kickstart-test') runs-on: ubuntu-latest steps: - - name: Query comment author repository permissions - uses: octokit/request-action@v2.x - id: user_permission - with: - route: GET /repos/${{ github.repository }}/collaborators/${{ github.event.sender.login }}/permission - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - # restrict running of tests to users with admin or write permission for the repository - # see https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#get-repository-permissions-for-a-user - # store output if user is allowed in allowed_user job output so it has to be checked in downstream job - - name: Check if user does have correct permissions - if: contains('admin write', fromJson(steps.user_permission.outputs.data).permission) - id: check_user_perm - run: | - echo "User '${{ github.event.sender.login }}' has permission '${{ fromJson(steps.user_permission.outputs.data).permission }}' allowed values: 'admin', 'write'" - echo "allowed_user=true" >> $GITHUB_OUTPUT - - name: Get information for pull request uses: octokit/request-action@v2.x id: pr_api @@ -62,17 +43,6 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Parse comment arguments - id: parse_comment_args - # Do not use comment body directly in the shell command to avoid possible code injection. - env: - BODY: ${{ github.event.comment.body }} - run: | - # extract first line and cut out the "/kickstart-tests" first word - ARGS=$(echo "$BODY" | sed -n '1 s/^[^ ]* *//p' | sed 's/[[:space:]]*$//') - echo "workflow arguments are: $ARGS" - echo "comment_args=${ARGS}" >> $GITHUB_OUTPUT - - name: Get timestamp id: timestamp run: echo "::set-output name=timestamp::$(date +'%Y-%m-%d_%H:%M:%S')" @@ -89,17 +59,17 @@ jobs: fi outputs: - allowed_user: ${{ steps.check_user_perm.outputs.allowed_user }} + allowed_user: 'true' base_ref: ${{ fromJson(steps.pr_api.outputs.data).base.ref }} sha: ${{ fromJson(steps.pr_api.outputs.data).head.sha }} - comment_args: ${{ steps.parse_comment_args.outputs.comment_args }} + comment_args: '--testtype smoke' target_branch: ${{ fromJson(steps.pr_api.outputs.data).base.ref }} timestamp: ${{steps.kstest_run_description.outputs.image_description}} run: needs: pr-info # only do this for Fedora for now; once we have RHEL 8/9 boot.iso builds working, also support these - if: needs.pr-info.outputs.allowed_user == 'true' && needs.pr-info.outputs.comment_args != '' && ! contains(github.event.comment.body, '--waive') + if: needs.pr-info.outputs.allowed_user == 'true' && needs.pr-info.outputs.comment_args != '' runs-on: [self-hosted, kstest] timeout-minutes: 300 env: @@ -331,29 +301,4 @@ jobs: target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - waive: - runs-on: ubuntu-latest - needs: pr-info - if: needs.pr-info.outputs.allowed_user == 'true' && contains(github.event.comment.body, '--waive') - steps: - - - name: Get the waiving reason - id: get_reason - env: - BODY: ${{ github.event.comment.body }} - run: | - REASON=$(echo "$BODY" | sed -e "s#/kickstart-test --waive ##" | sed 's/[[:space:]]*$//') - echo "reason=Waived, $REASON" >> $GITHUB_OUTPUT - - - name: Set status - uses: octokit/request-action@v2.x - with: - route: 'POST /repos/${{ github.repository }}/statuses/${{ needs.pr-info.outputs.sha }}' - context: 'kickstart-test --testtype smoke' - description: '${{ steps.get_reason.outputs.reason }}' - state: ${{ job.status }} - target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} {% endif %}