From 98af412bd9726777dfe10b2e5d719e3d9f4ef40b Mon Sep 17 00:00:00 2001 From: Chandrakala Subramanyam Date: Fri, 20 Oct 2023 17:14:51 +0530 Subject: [PATCH 1/3] Included fetching PR branch and pytest-html version Signed-off-by: Chandrakala Subramanyam --- .github/workflows/test-on-comment.yaml | 35 +++++++++++++++++-- .../remote_monitoring_tests/requirements.txt | 2 +- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-on-comment.yaml b/.github/workflows/test-on-comment.yaml index f321e63c6..64a0fa2b1 100644 --- a/.github/workflows/test-on-comment.yaml +++ b/.github/workflows/test-on-comment.yaml @@ -3,28 +3,49 @@ name: Kruize Remote monitoring functional tests on: issue_comment: types: [created] + issue_type: [pull_request] + branch: [master, mvp_demo, remote_monitoring] pull_request_review: types: [submitted] jobs: functest: - # Only run this if the user asked us to - if: github.event.comment.body == 'run functional tests' + if: contains(github.event.comment.body, 'run functional tests') runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v3 + - name: Get PR branch + uses: xt0rted/pull-request-comment-branch@v1 + id: comment-branch + + - name: Debug Comment Content + run: echo "Comment :${{ github.event.comment.body }}" + + - name: Set latest commit status as pending + uses: myrotvorets/set-commit-status-action@master + with: + sha: ${{ steps.comment-branch.outputs.head_sha }} + token: ${{ secrets.GITHUB_TOKEN }} + status: pending + + - name: Checkout PR branch + uses: actions/checkout@v3 + with: + ref: ${{ steps.comment-branch.outputs.head_ref }} + - name: Setup Minikube uses: manusa/actions-setup-minikube@v2.3.0 with: minikube version: 'v1.16.0' kubernetes version: 'v1.19.2' + - name: Build crc run: | echo Build crc ./build.sh -i autotune_operator:test_build docker images | grep autotune + - name: Install Prometheus on minikube run: | echo Install Prometheus on minikube @@ -60,3 +81,11 @@ jobs: name: kruize_test_results path: ./kruize_test_results.tar retention-days: 2 + + - name: Set latest commit status as ${{ job.status }} + uses: myrotvorets/set-commit-status-action@master + if: always() + with: + sha: ${{ steps.comment-branch.outputs.head_sha }} + token: ${{ secrets.GITHUB_TOKEN }} + status: ${{ job.status }} diff --git a/tests/scripts/remote_monitoring_tests/requirements.txt b/tests/scripts/remote_monitoring_tests/requirements.txt index 589b3685a..1b6deedb9 100644 --- a/tests/scripts/remote_monitoring_tests/requirements.txt +++ b/tests/scripts/remote_monitoring_tests/requirements.txt @@ -1,4 +1,4 @@ pytest requests jinja2 -pytest-html +pytest-html==3.2.0 From 03a5e652080649ceafd3947bc885d60aec7e6a75 Mon Sep 17 00:00:00 2001 From: Chandrakala Subramanyam Date: Thu, 26 Oct 2023 17:37:56 +0530 Subject: [PATCH 2/3] Updated the test on comment to replace the previous github actions with github-scripts Signed-off-by: Chandrakala Subramanyam --- .github/workflows/test-on-comment.yaml | 112 ++++++++++++++++++++----- 1 file changed, 91 insertions(+), 21 deletions(-) diff --git a/.github/workflows/test-on-comment.yaml b/.github/workflows/test-on-comment.yaml index 64a0fa2b1..2791331a6 100644 --- a/.github/workflows/test-on-comment.yaml +++ b/.github/workflows/test-on-comment.yaml @@ -4,7 +4,6 @@ on: issue_comment: types: [created] issue_type: [pull_request] - branch: [master, mvp_demo, remote_monitoring] pull_request_review: types: [submitted] @@ -15,24 +14,39 @@ jobs: runs-on: ubuntu-20.04 steps: - - name: Get PR branch - uses: xt0rted/pull-request-comment-branch@v1 - id: comment-branch - + - name: Get workflow run info + run: | + echo "url=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_OUTPUT + echo "id=$GITHUB_RUN_ID" >> $GITHUB_OUTPUT + echo "url=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" + echo "id=$GITHUB_RUN_ID" + id: workflow_run_info + - name: Debug Comment Content run: echo "Comment :${{ github.event.comment.body }}" - - name: Set latest commit status as pending - uses: myrotvorets/set-commit-status-action@master + + - uses: actions/github-script@v6 + id: get-pr with: - sha: ${{ steps.comment-branch.outputs.head_sha }} - token: ${{ secrets.GITHUB_TOKEN }} - status: pending - - - name: Checkout PR branch - uses: actions/checkout@v3 + script: | + const request = { + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.issue.number + } + core.info(`Getting PR #${request.pull_number} from ${request.owner}/${request.repo}`) + try { + const result = await github.rest.pulls.get(request) + return result.data + } catch (err) { + core.setFailed(`Request failed with error ${err}`) + } + + - name: Check out code + uses: actions/checkout@v4 with: - ref: ${{ steps.comment-branch.outputs.head_ref }} + ref: refs/pull/${{ github.event.issue.number }}/head - name: Setup Minikube uses: manusa/actions-setup-minikube@v2.3.0 @@ -82,10 +96,66 @@ jobs: path: ./kruize_test_results.tar retention-days: 2 - - name: Set latest commit status as ${{ job.status }} - uses: myrotvorets/set-commit-status-action@master - if: always() - with: - sha: ${{ steps.comment-branch.outputs.head_sha }} - token: ${{ secrets.GITHUB_TOKEN }} - status: ${{ job.status }} + reportFailure: + runs-on: ubuntu-latest + needs: [functest] + if: failure() + steps: + - name: Create comment + uses: actions/github-script@v6 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + comment_body = ` + @${{ github.actor }} Build(s) failed. + Workflow Run ID: [${{ needs.functest.outputs.workflow_id }}](${{ needs.functest.outputs.workflow_url }}) + `; + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: comment_body + }) + + reportCancelled: + runs-on: ubuntu-latest + needs: [functest] + if: cancelled() + steps: + - name: Create comment + uses: actions/github-script@v6 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + comment_body = ` + @${{ github.actor }} Build(s) cancelled. + Workflow Run ID: [${{ needs.functest.outputs.workflow_id }}](${{ needs.functest.outputs.workflow_url }}) + `; + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: comment_body + }) + + reportSuccess: + runs-on: ubuntu-latest + needs: [functest] + if: success() + steps: + - name: Create comment + uses: actions/github-script@v6 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + + comment_body = ` + @${{ github.actor }} Build(s) successful. + Workflow Run ID: [${{ needs.functest.outputs.workflow_id }}](${{ needs.functest.outputs.workflow_url }}) + `; + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: comment_body + }) From ef7173e9d98c20b3f85ce0781132ef422ee77177 Mon Sep 17 00:00:00 2001 From: bhanvimenghani Date: Wed, 22 Nov 2023 18:24:20 +0530 Subject: [PATCH 3/3] bug fix --- deploy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy.sh b/deploy.sh index d67c027bb..34107a40b 100755 --- a/deploy.sh +++ b/deploy.sh @@ -123,7 +123,7 @@ function check_cluster_type() { } # Iterate through the commandline options -while getopts ac:d:i:k:m:n:o:p:stub-: gopts; do +while getopts ac:d:i:k:m:n:o:p:u:stb-: gopts; do case ${gopts} in -) case "${OPTARG}" in