From cd3d46358419747c9c3ddd904dbc1b6989ab0df0 Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Thu, 31 Aug 2023 12:43:43 -0400 Subject: [PATCH 01/22] added new workflow file for removing label part --- .../workflows/pr-remove-request-review.yml | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/pr-remove-request-review.yml diff --git a/.github/workflows/pr-remove-request-review.yml b/.github/workflows/pr-remove-request-review.yml new file mode 100644 index 0000000000..22c6936ddc --- /dev/null +++ b/.github/workflows/pr-remove-request-review.yml @@ -0,0 +1,25 @@ +name: Remove Review Label + +on: + pull_request_review: + types: [edited, dismissed] + +jobs: + remove-review-label: + runs-on: ubuntu-latest + permissions: + pull-requests: write + + if: github.repository_owner == 'cryostatio' && contains(github.event.pull_request.labels.*.name, 'review-requested') + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Remove label + run: | + pr_number=${{ github.event.pull_request.number }} + echo "Removing 'review-requested' label from the PR" + gh pr edit $pr_number --remove-label "review-requested" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 421cd4caed2b0514fd00c90b27dba2a38563bf37 Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Fri, 1 Sep 2023 11:53:16 -0400 Subject: [PATCH 02/22] apply fixes --- .github/workflows/pr-remove-request-review.yml | 2 +- .github/workflows/pr-request-review.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-remove-request-review.yml b/.github/workflows/pr-remove-request-review.yml index 22c6936ddc..cac197fd47 100644 --- a/.github/workflows/pr-remove-request-review.yml +++ b/.github/workflows/pr-remove-request-review.yml @@ -10,7 +10,7 @@ jobs: permissions: pull-requests: write - if: github.repository_owner == 'cryostatio' && contains(github.event.pull_request.labels.*.name, 'review-requested') + if: contains(github.event.pull_request.labels.*.name, 'review-requested') steps: - name: Checkout code diff --git a/.github/workflows/pr-request-review.yml b/.github/workflows/pr-request-review.yml index 79e561feb5..049e65f901 100644 --- a/.github/workflows/pr-request-review.yml +++ b/.github/workflows/pr-request-review.yml @@ -12,7 +12,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} permissions: pull-requests: write - if: github.repository_owner == 'cryostatio' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/request_review') + if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/request_review') steps: - run: | # Adding label 'review-requested' to the PR. Mergify will add reviewers. From 4c90d8bb369bf076cd98c63058b704cdd34ff694 Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Fri, 1 Sep 2023 13:40:45 -0400 Subject: [PATCH 03/22] test25 --- .github/workflows/pr-remove-request-review.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-remove-request-review.yml b/.github/workflows/pr-remove-request-review.yml index cac197fd47..a6dc25db3c 100644 --- a/.github/workflows/pr-remove-request-review.yml +++ b/.github/workflows/pr-remove-request-review.yml @@ -2,7 +2,7 @@ name: Remove Review Label on: pull_request_review: - types: [edited, dismissed] + types: [submitted, edited, dismissed] jobs: remove-review-label: From 0f054ce751057c669bdbad06cf94d42f7f3f7407 Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Wed, 20 Sep 2023 13:27:52 -0400 Subject: [PATCH 04/22] update --- .../workflows/pr-remove-request-review.yml | 25 ------------------- 1 file changed, 25 deletions(-) delete mode 100644 .github/workflows/pr-remove-request-review.yml diff --git a/.github/workflows/pr-remove-request-review.yml b/.github/workflows/pr-remove-request-review.yml deleted file mode 100644 index a6dc25db3c..0000000000 --- a/.github/workflows/pr-remove-request-review.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Remove Review Label - -on: - pull_request_review: - types: [submitted, edited, dismissed] - -jobs: - remove-review-label: - runs-on: ubuntu-latest - permissions: - pull-requests: write - - if: contains(github.event.pull_request.labels.*.name, 'review-requested') - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Remove label - run: | - pr_number=${{ github.event.pull_request.number }} - echo "Removing 'review-requested' label from the PR" - gh pr edit $pr_number --remove-label "review-requested" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 3e04c49130165a30f59b4670f96d44cc28f62a20 Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Fri, 22 Sep 2023 13:30:50 -0400 Subject: [PATCH 05/22] build_test command enhancements --- .github/workflows/pr-ci.yml | 73 +++++++++++++++++++++++++++++++++---- 1 file changed, 65 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pr-ci.yml b/.github/workflows/pr-ci.yml index d32dc2a23a..e6d3fcebcd 100644 --- a/.github/workflows/pr-ci.yml +++ b/.github/workflows/pr-ci.yml @@ -12,11 +12,11 @@ on: jobs: check-before-build: runs-on: ubuntu-latest - if: github.repository_owner == 'cryostatio' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/build_test') + if: github.repository_owner == 'cryostatio' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/build_test') || startsWith(github.event.comment.body, '/retest')) permissions: pull-requests: write steps: - - name: Fail if needs-triage label applied + - name: Fail if needs-triage label applied if: ${{ contains(github.event.issue.labels.*.name, 'needs-triage') }} run: exit 1 - name: Show warning if permission is denied @@ -43,12 +43,12 @@ jobs: repo, comment_id: context.payload.comment.id, content: "+1", - }); + }); - checkout-branch: + checkout-branch: runs-on: ubuntu-latest needs: [check-before-build] - outputs: + outputs: PR_head_ref: ${{ fromJSON(steps.comment-branch.outputs.result).ref }} PR_head_sha: ${{ fromJSON(steps.comment-branch.outputs.result).sha }} PR_num: ${{ fromJSON(steps.comment-branch.outputs.result).num }} @@ -73,9 +73,42 @@ jobs: with: checkout-repo: ${{ needs.checkout-branch.outputs.PR_repo }} checkout-ref: ${{ needs.checkout-branch.outputs.PR_head_ref }} + + start-comment: + runs-on: ubuntu-latest + steps: + - name: Capture Date and Time + id: date-time + run: echo "::set-output name=date-time::$(date +'%Y-%m-%d %H:%M:%S')" + - name: Start Comment + uses: thollander/actions-comment-pull-request@v2 + with: + message: | + Workflow started at ${{steps.date-time.outputs.date-time}}. build-and-test: needs: [code-analysis, checkout-branch] + strategy: + matrix: + arch: [amd64, arm64] + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: build-test + uses: ./.github/workflows/ci-build-image.yml + with: + build-arch: ${{ matrix.arch }} + checkout-repo: ${{ needs.checkout-branch.outputs.PR_repo }} + checkout-ref: ${{ needs.checkout-branch.outputs.PR_head_ref }} + skip-itests: ${{ matrix.arch != 'amd64' }} + - name: Set BUILD_TEST_EXECUTED flag + id: set-build-test-executed + run: echo "BUILD_TEST_EXECUTED=true" >> $GITHUB_ENV + + retest-integration: + needs: [code-analysis, checkout-branch, build-and-test] + if: startsWith(github.event.comment.body, '/retest') && env.BUILD_TEST_EXECUTED == 'true' strategy: matrix: arch: [amd64, arm64] @@ -85,6 +118,30 @@ jobs: checkout-repo: ${{ needs.checkout-branch.outputs.PR_repo }} checkout-ref: ${{ needs.checkout-branch.outputs.PR_head_ref }} skip-itests: ${{ matrix.arch != 'amd64' }} + + check-test-results: + runs-on: ubuntu-latest + needs: [build-and-test] + steps: + - name: Check Test Results + id: check-results + run: | + if [ ... ]; then + echo "Tests passed." + echo "::set-output name=test-status::success" + else + echo "Tests failed." + echo "::set-output name=test-status::failure" + continue-on-error: true + - name: Capture Date and Time + id: date-time + run: echo "::set-output name=date-time::$(date +'%Y-%m-%d %H:%M:%S')" + - name: Comment on PR + if: ${{ always() }} + uses: thollander/actions-comment-pull-request@v2 + with: + message: | + Tests status: ${{ steps.check-results.outputs.test-status }} at ${{ steps.date-time.outputs.date-time }}. push-to-ghcr: runs-on: ubuntu-latest @@ -92,7 +149,7 @@ jobs: strategy: matrix: arch: [amd64, arm64] - outputs: + outputs: amd64_image: ${{ steps.amd64_image.outputs.image }} arm64_image: ${{ steps.arm64_image.outputs.image }} env: @@ -138,7 +195,7 @@ jobs: - name: Create markdown table id: md-table uses: petems/csv-to-md-table-action@v3.0.0 - with: + with: csvinput: | ARCH, IMAGE amd64, ${{ env.amd64_image }} @@ -150,7 +207,7 @@ jobs: To run smoketest: ``` - # amd64 + # amd64 CRYOSTAT_IMAGE=${{ env.amd64_image }} sh smoketest.sh # or arm64 From c1c2186fcbee2655f1dd810768618da4cb59e52a Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Mon, 25 Sep 2023 17:48:39 -0400 Subject: [PATCH 06/22] resolved issues --- .github/workflows/ci-build-image.yml | 3 +++ .github/workflows/pr-ci.yml | 10 ++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-build-image.yml b/.github/workflows/ci-build-image.yml index 09c18f24d5..360f4e8d47 100644 --- a/.github/workflows/ci-build-image.yml +++ b/.github/workflows/ci-build-image.yml @@ -14,6 +14,9 @@ on: required: false type: boolean default: false + run-tests-only: + type: boolean + default: false outputs: image-version: description: the Cryostat application version that will be built diff --git a/.github/workflows/pr-ci.yml b/.github/workflows/pr-ci.yml index e6d3fcebcd..a903803834 100644 --- a/.github/workflows/pr-ci.yml +++ b/.github/workflows/pr-ci.yml @@ -76,6 +76,8 @@ jobs: start-comment: runs-on: ubuntu-latest + needs: [check-before-build] + if: ${{ needs.check-before-build.output.result == 'success' }} steps: - name: Capture Date and Time id: date-time @@ -85,9 +87,11 @@ jobs: with: message: | Workflow started at ${{steps.date-time.outputs.date-time}}. + Workflow run [Link](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}). + build-and-test: - needs: [code-analysis, checkout-branch] + needs: [checkout-branch] strategy: matrix: arch: [amd64, arm64] @@ -102,6 +106,7 @@ jobs: checkout-repo: ${{ needs.checkout-branch.outputs.PR_repo }} checkout-ref: ${{ needs.checkout-branch.outputs.PR_head_ref }} skip-itests: ${{ matrix.arch != 'amd64' }} + run-tests-only: true - name: Set BUILD_TEST_EXECUTED flag id: set-build-test-executed run: echo "BUILD_TEST_EXECUTED=true" >> $GITHUB_ENV @@ -118,6 +123,7 @@ jobs: checkout-repo: ${{ needs.checkout-branch.outputs.PR_repo }} checkout-ref: ${{ needs.checkout-branch.outputs.PR_head_ref }} skip-itests: ${{ matrix.arch != 'amd64' }} + run-tests-only: true check-test-results: runs-on: ubuntu-latest @@ -126,7 +132,7 @@ jobs: - name: Check Test Results id: check-results run: | - if [ ... ]; then + if [$? -eq 0]; then echo "Tests passed." echo "::set-output name=test-status::success" else From 2df282434a6880f0168202696bd19f55957193a6 Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Tue, 10 Oct 2023 15:58:45 -0400 Subject: [PATCH 07/22] added separate itest --- .github/workflows/ci-build-image.yml | 57 +++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-build-image.yml b/.github/workflows/ci-build-image.yml index 360f4e8d47..c24cea936c 100644 --- a/.github/workflows/ci-build-image.yml +++ b/.github/workflows/ci-build-image.yml @@ -15,6 +15,7 @@ on: type: boolean default: false run-tests-only: + required: false type: boolean default: false outputs: @@ -22,10 +23,6 @@ on: description: the Cryostat application version that will be built value: ${{ jobs.get-pom-properties.outputs.image-version }} -permissions: - contents: read - packages: read - jobs: get-pom-properties: runs-on: ubuntu-latest @@ -45,6 +42,7 @@ jobs: build-image: runs-on: ubuntu-latest + if: ${{ !inputs.run-tests-only }} needs: [get-pom-properties] steps: - name: Install qemu @@ -74,6 +72,7 @@ jobs: step: restore - run: git submodule init - run: git submodule update + if: ${{ !inputs.run-tests-only }} - run: mvn -B -U -Dbuild.arch=${{ inputs.build-arch }} clean package env: GITHUB_TOKEN_REF: ${{ secrets.GITHUB_TOKEN }} @@ -90,7 +89,7 @@ jobs: integration-tests: runs-on: ubuntu-latest needs: [build-image] - if: ${{ ! inputs.skip-itests }} + if: ${{ !inputs.skip-itests && !inputs.run-tests-only }} steps: - name: Install xpath run: | @@ -132,3 +131,51 @@ jobs: - uses: skjolber/maven-cache-github-action@v1 with: step: save + + retest-integration-test: + runs-on: ubuntu-latest + if: ${{ inputs.run-tests-only && !inputs.skip-itests }} + steps: + - name: Install xpath + run: | + sudo apt-get update + sudo apt-get install -y libxml-xpath-perl + - name: Install qemu + if: ${{ inputs.build-arch != 'amd64' }} + continue-on-error: true + run: | + sudo apt-get update + sudo apt-get install -y qemu-user-static + - uses: actions/checkout@v4 + if: always() + with: + repository: ${{ inputs.checkout-repo }} + ref: ${{ inputs.checkout-ref }} + submodules: true + fetch-depth: 0 + - uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + - name: Download Cryostat Image Artifact + uses: actions/download-artifact@v3 + with: + name: cryostat-${{ inputs.build-arch }} + - name: Load Cryostat Image + run: podman load -i ./cryostat-${{ inputs.build-arch }}.tar + - uses: skjolber/maven-cache-github-action@v1 + with: + step: restore + - name: Run integration tests with the loaded image + run: | + POD_NAME=cryostat-itests + CONTAINER_NAME=cryostat-itest + ITEST_IMG_VERSION=latest + bash repeated-integration-tests.bash + - name: Print itest logs + if: failure() + run: ls -1dt target/cryostat-itest-*.log | head -n1 | xargs cat + - name: Print itest container logs + if: failure() + run: ls -1dt target/cryostat-*.server.log | head -n1 | xargs cat + From 5eaab94a2df86edbd6a5f1a4ccf0b8ea0f09efc4 Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Tue, 10 Oct 2023 16:40:25 -0400 Subject: [PATCH 08/22] added separate itest for /retest --- .github/workflows/pr-ci.yml | 116 ++++++++++++++++++++---------------- 1 file changed, 63 insertions(+), 53 deletions(-) diff --git a/.github/workflows/pr-ci.yml b/.github/workflows/pr-ci.yml index a903803834..8ce38a4a69 100644 --- a/.github/workflows/pr-ci.yml +++ b/.github/workflows/pr-ci.yml @@ -12,7 +12,7 @@ on: jobs: check-before-build: runs-on: ubuntu-latest - if: github.repository_owner == 'cryostatio' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/build_test') || startsWith(github.event.comment.body, '/retest')) + if: github.event.issue.pull_request && (startsWith(github.event.comment.body, '/build_test') || startsWith(github.event.comment.body, '/retest')) permissions: pull-requests: write steps: @@ -73,47 +73,23 @@ jobs: with: checkout-repo: ${{ needs.checkout-branch.outputs.PR_repo }} checkout-ref: ${{ needs.checkout-branch.outputs.PR_head_ref }} - - start-comment: - runs-on: ubuntu-latest - needs: [check-before-build] - if: ${{ needs.check-before-build.output.result == 'success' }} - steps: - - name: Capture Date and Time - id: date-time - run: echo "::set-output name=date-time::$(date +'%Y-%m-%d %H:%M:%S')" - - name: Start Comment - uses: thollander/actions-comment-pull-request@v2 - with: - message: | - Workflow started at ${{steps.date-time.outputs.date-time}}. - Workflow run [Link](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}). - build-and-test: - needs: [checkout-branch] + needs: [code-analysis, checkout-branch] + if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/build_test') strategy: matrix: arch: [amd64, arm64] - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: build-test - uses: ./.github/workflows/ci-build-image.yml - with: - build-arch: ${{ matrix.arch }} - checkout-repo: ${{ needs.checkout-branch.outputs.PR_repo }} - checkout-ref: ${{ needs.checkout-branch.outputs.PR_head_ref }} - skip-itests: ${{ matrix.arch != 'amd64' }} - run-tests-only: true - - name: Set BUILD_TEST_EXECUTED flag - id: set-build-test-executed - run: echo "BUILD_TEST_EXECUTED=true" >> $GITHUB_ENV + uses: ./.github/workflows/ci-build-image.yml + with: + build-arch: ${{ matrix.arch }} + checkout-repo: ${{ needs.checkout-branch.outputs.PR_repo }} + checkout-ref: ${{ needs.checkout-branch.outputs.PR_head_ref }} + skip-itests: ${{ matrix.arch != 'amd64' }} retest-integration: - needs: [code-analysis, checkout-branch, build-and-test] - if: startsWith(github.event.comment.body, '/retest') && env.BUILD_TEST_EXECUTED == 'true' + needs: [checkout-branch] + if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/retest') strategy: matrix: arch: [amd64, arm64] @@ -124,33 +100,66 @@ jobs: checkout-ref: ${{ needs.checkout-branch.outputs.PR_head_ref }} skip-itests: ${{ matrix.arch != 'amd64' }} run-tests-only: true - + + start-comment: + runs-on: ubuntu-latest + needs: [check-before-build] + if: ${{ needs.check-before-build.result == 'success' }} + steps: + - name: Leave Actions Run Comment + uses: actions/github-script@v6 + with: + script: | + const runURL = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${{ github.run_id }}`; + const currentTime = new Date().toLocaleString('en-US', { timeZone: 'America/Toronto' }); + const commentBody = `Workflow started at ${currentTime}. [View Actions Run](${runURL}).`; + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: commentBody + }); + check-test-results: + if: ${{ needs.build-and-test.result == 'success' || needs.retest-integration.result == 'success' }} runs-on: ubuntu-latest - needs: [build-and-test] + needs: [build-and-test, retest-integration] steps: - name: Check Test Results id: check-results run: | - if [$? -eq 0]; then - echo "Tests passed." - echo "::set-output name=test-status::success" - else - echo "Tests failed." - echo "::set-output name=test-status::failure" - continue-on-error: true - - name: Capture Date and Time - id: date-time - run: echo "::set-output name=date-time::$(date +'%Y-%m-%d %H:%M:%S')" - - name: Comment on PR - if: ${{ always() }} - uses: thollander/actions-comment-pull-request@v2 - with: - message: | - Tests status: ${{ steps.check-results.outputs.test-status }} at ${{ steps.date-time.outputs.date-time }}. + echo "All tests passed." + echo "::set-output name=test-status::success" + - name: Check Test Results Failure + if: failure() + id: check-results-failure + run: | + echo "At least one test has failed." + echo "::set-output name=test-status::failure" + continue-on-error: true + + leave-test-status-comment: + if: ${{ needs.check-test-results.result == 'success' }} + runs-on: ubuntu-latest + needs: [check-test-results] + steps: + - name: Leave Test Status Comment + uses: actions/github-script@v6 + with: + script: | + const testStatus = "${{ needs.check-test-results.test-status }}"; + const currentTime = new Date().toLocaleString('en-US', { timeZone: 'America/Toronto' }); + const commentBody = `Tests status: ${testStatus} at ${currentTime}.`; + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: commentBody + }); push-to-ghcr: runs-on: ubuntu-latest + if: startsWith(github.event.comment.body, '/build_test') needs: [build-and-test, checkout-branch] strategy: matrix: @@ -191,6 +200,7 @@ jobs: comment-image: runs-on: ubuntu-latest + if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/build_test') needs: [push-to-ghcr] env: amd64_image: ${{ needs.push-to-ghcr.outputs.amd64_image }} From a1dd2d238784eb24260257b765b6edc268934cf7 Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Tue, 10 Oct 2023 16:47:37 -0400 Subject: [PATCH 09/22] returned pr-request-review.yml to its original state --- .github/workflows/pr-request-review.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-request-review.yml b/.github/workflows/pr-request-review.yml index 049e65f901..79e561feb5 100644 --- a/.github/workflows/pr-request-review.yml +++ b/.github/workflows/pr-request-review.yml @@ -12,7 +12,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} permissions: pull-requests: write - if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/request_review') + if: github.repository_owner == 'cryostatio' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/request_review') steps: - run: | # Adding label 'review-requested' to the PR. Mergify will add reviewers. From cd25c269aa885d2a6724acfdffb5da540b0124cd Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Tue, 10 Oct 2023 16:55:51 -0400 Subject: [PATCH 10/22] added owner --- .github/workflows/pr-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-ci.yml b/.github/workflows/pr-ci.yml index 8ce38a4a69..3b611acae0 100644 --- a/.github/workflows/pr-ci.yml +++ b/.github/workflows/pr-ci.yml @@ -12,7 +12,7 @@ on: jobs: check-before-build: runs-on: ubuntu-latest - if: github.event.issue.pull_request && (startsWith(github.event.comment.body, '/build_test') || startsWith(github.event.comment.body, '/retest')) + if: github.repository_owner == 'cryostatio' && github.event.issue.pull_request && (startsWith(github.event.comment.body, '/build_test') || startsWith(github.event.comment.body, '/retest')) permissions: pull-requests: write steps: From 22d3f47110e579c35a433d09fef1f5d622848a0e Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Wed, 11 Oct 2023 11:23:44 -0400 Subject: [PATCH 11/22] edited workflow to load image that was built --- .github/workflows/ci-build-image.yml | 4 ---- .github/workflows/pr-ci.yml | 7 +++---- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci-build-image.yml b/.github/workflows/ci-build-image.yml index c24cea936c..70a2a0d563 100644 --- a/.github/workflows/ci-build-image.yml +++ b/.github/workflows/ci-build-image.yml @@ -72,7 +72,6 @@ jobs: step: restore - run: git submodule init - run: git submodule update - if: ${{ !inputs.run-tests-only }} - run: mvn -B -U -Dbuild.arch=${{ inputs.build-arch }} clean package env: GITHUB_TOKEN_REF: ${{ secrets.GITHUB_TOKEN }} @@ -112,9 +111,6 @@ jobs: with: java-version: '17' distribution: 'temurin' - - uses: actions/download-artifact@v3 - with: - name: cryostat-${{ inputs.build-arch }} - name: Load cryostat image run: podman load -i cryostat-${{ inputs.build-arch }}.tar - uses: skjolber/maven-cache-github-action@v1 diff --git a/.github/workflows/pr-ci.yml b/.github/workflows/pr-ci.yml index 3b611acae0..2c695b26e4 100644 --- a/.github/workflows/pr-ci.yml +++ b/.github/workflows/pr-ci.yml @@ -121,7 +121,7 @@ jobs: }); check-test-results: - if: ${{ needs.build-and-test.result == 'success' || needs.retest-integration.result == 'success' }} + if: ${{ success(needs.build-and-test) || success(needs.retest-integration) }} runs-on: ubuntu-latest needs: [build-and-test, retest-integration] steps: @@ -139,7 +139,6 @@ jobs: continue-on-error: true leave-test-status-comment: - if: ${{ needs.check-test-results.result == 'success' }} runs-on: ubuntu-latest needs: [check-test-results] steps: @@ -147,9 +146,9 @@ jobs: uses: actions/github-script@v6 with: script: | - const testStatus = "${{ needs.check-test-results.test-status }}"; const currentTime = new Date().toLocaleString('en-US', { timeZone: 'America/Toronto' }); - const commentBody = `Tests status: ${testStatus} at ${currentTime}.`; + const testStatus = "${{ needs.check-test-results.outputs.test-status }}"; + const commentBody = `Tests status: ${test-status } ${currentTime}.`; github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, From f663ecb216835c3b7f00c1d4c744114dfecf584d Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Wed, 11 Oct 2023 13:04:29 -0400 Subject: [PATCH 12/22] testing --- .github/workflows/ci-build-image.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-build-image.yml b/.github/workflows/ci-build-image.yml index 70a2a0d563..c5f81bdf78 100644 --- a/.github/workflows/ci-build-image.yml +++ b/.github/workflows/ci-build-image.yml @@ -23,6 +23,10 @@ on: description: the Cryostat application version that will be built value: ${{ jobs.get-pom-properties.outputs.image-version }} +permissions: + contents: read + packages: read + jobs: get-pom-properties: runs-on: ubuntu-latest @@ -111,6 +115,10 @@ jobs: with: java-version: '17' distribution: 'temurin' + - name: Download Cryostat Image Artifact + uses: actions/download-artifact@v3 + with: + name: cryostat-${{ inputs.build-arch }} - name: Load cryostat image run: podman load -i cryostat-${{ inputs.build-arch }}.tar - uses: skjolber/maven-cache-github-action@v1 @@ -130,7 +138,7 @@ jobs: retest-integration-test: runs-on: ubuntu-latest - if: ${{ inputs.run-tests-only && !inputs.skip-itests }} + if: ${{ inputs.run-tests-only && !inputs.skip-itests}} steps: - name: Install xpath run: | @@ -153,10 +161,6 @@ jobs: with: java-version: '17' distribution: 'temurin' - - name: Download Cryostat Image Artifact - uses: actions/download-artifact@v3 - with: - name: cryostat-${{ inputs.build-arch }} - name: Load Cryostat Image run: podman load -i ./cryostat-${{ inputs.build-arch }}.tar - uses: skjolber/maven-cache-github-action@v1 From 4af155a125620701ab03f2ff2d3347e02b036a9b Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Fri, 13 Oct 2023 17:01:41 -0400 Subject: [PATCH 13/22] added test pass and retest job --- .github/workflows/ci-build-image.yml | 73 ++++++++++++++-------------- .github/workflows/pr-ci.yml | 54 ++++++++++---------- 2 files changed, 64 insertions(+), 63 deletions(-) diff --git a/.github/workflows/ci-build-image.yml b/.github/workflows/ci-build-image.yml index c5f81bdf78..f47b9867b6 100644 --- a/.github/workflows/ci-build-image.yml +++ b/.github/workflows/ci-build-image.yml @@ -18,6 +18,12 @@ on: required: false type: boolean default: false + pr-number: + required: false + type: string + sha-value: + required: false + type: string outputs: image-version: description: the Cryostat application version that will be built @@ -136,46 +142,39 @@ jobs: with: step: save - retest-integration-test: + retest-integration-tests: runs-on: ubuntu-latest - if: ${{ inputs.run-tests-only && !inputs.skip-itests}} + if: ${{ !inputs.skip-itests && inputs.run-tests-only }} steps: - - name: Install xpath - run: | - sudo apt-get update - sudo apt-get install -y libxml-xpath-perl - - name: Install qemu - if: ${{ inputs.build-arch != 'amd64' }} - continue-on-error: true - run: | - sudo apt-get update - sudo apt-get install -y qemu-user-static - - uses: actions/checkout@v4 - if: always() - with: - repository: ${{ inputs.checkout-repo }} + - name: Install xpath + run: | + sudo apt-get update + sudo apt-get install -y libxml-xpath-perl + - name: Install qemu + if: ${{ inputs.build-arch != 'amd64' }} + continue-on-error: true + run: | + sudo apt-get update + sudo apt-get install -y qemu-user-static + - uses: actions/checkout@v4 + with: + repository: ${{ github.repository_owner }}/cryostat ref: ${{ inputs.checkout-ref }} submodules: true fetch-depth: 0 - - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'temurin' - - name: Load Cryostat Image - run: podman load -i ./cryostat-${{ inputs.build-arch }}.tar - - uses: skjolber/maven-cache-github-action@v1 - with: - step: restore - - name: Run integration tests with the loaded image - run: | - POD_NAME=cryostat-itests - CONTAINER_NAME=cryostat-itest - ITEST_IMG_VERSION=latest - bash repeated-integration-tests.bash - - name: Print itest logs - if: failure() - run: ls -1dt target/cryostat-itest-*.log | head -n1 | xargs cat - - name: Print itest container logs - if: failure() - run: ls -1dt target/cryostat-*.server.log | head -n1 | xargs cat + - uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + - name: Pull cryostat image + run: podman pull ghcr.io/${{ github.repository_owner }}/cryostat:pr-${{ inputs.pr-number }}-${{ inputs.sha-value }}-linux-${{ inputs.build-arch }} + - name: Run integration tests + run: POD_NAME=cryostat-itests CONTAINER_NAME=cryostat-itest ITEST_IMG_VERSION=latest bash repeated-integration-tests.bash + - name: Print itest logs + if: failure() + run: ls -1dt target/cryostat-itest-*.log | head -n1 | xargs cat + - name: Print itest container logs + if: failure() + run: ls -1dt target/cryostat-*.server.log | head -n1 | xargs cat + diff --git a/.github/workflows/pr-ci.yml b/.github/workflows/pr-ci.yml index 2c695b26e4..427f7c8b54 100644 --- a/.github/workflows/pr-ci.yml +++ b/.github/workflows/pr-ci.yml @@ -87,19 +87,19 @@ jobs: checkout-ref: ${{ needs.checkout-branch.outputs.PR_head_ref }} skip-itests: ${{ matrix.arch != 'amd64' }} +# Add a new step to use /retest retest-integration: - needs: [checkout-branch] - if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/retest') + needs: [code-analysis, checkout-branch] + if: contains(github.event.comment.body, '/retest') strategy: matrix: arch: [amd64, arm64] uses: ./.github/workflows/ci-build-image.yml with: build-arch: ${{ matrix.arch }} - checkout-repo: ${{ needs.checkout-branch.outputs.PR_repo }} - checkout-ref: ${{ needs.checkout-branch.outputs.PR_head_ref }} - skip-itests: ${{ matrix.arch != 'amd64' }} run-tests-only: true + pr-number: ${{ github.event.issue.number }} + sha-value: ${{ needs.checkout-branch.outputs.PR_head_sha }} start-comment: runs-on: ubuntu-latest @@ -120,35 +120,37 @@ jobs: body: commentBody }); - check-test-results: - if: ${{ success(needs.build-and-test) || success(needs.retest-integration) }} + build-and-test-pass: runs-on: ubuntu-latest - needs: [build-and-test, retest-integration] + needs: [build-and-test] + if: ${{ needs.build-and-test.result == 'success' }} steps: - - name: Check Test Results - id: check-results - run: | - echo "All tests passed." - echo "::set-output name=test-status::success" - - name: Check Test Results Failure - if: failure() - id: check-results-failure - run: | - echo "At least one test has failed." - echo "::set-output name=test-status::failure" - continue-on-error: true + - name: Leave Actions Run Comment + uses: actions/github-script@v6 + if: always() + with: + script: | + const runURL = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${{ github.run_id }}`; + const commentBody = `build-and-test: All tests pass ✅. \n[View Actions Run](${runURL}).`; + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: commentBody + }); - leave-test-status-comment: + retest-integration-pass: runs-on: ubuntu-latest - needs: [check-test-results] + needs: [retest-integration] + if: ${{ needs.retest-integration.result == 'success' }} steps: - - name: Leave Test Status Comment + - name: Leave Actions Run Comment uses: actions/github-script@v6 + if: always() with: script: | - const currentTime = new Date().toLocaleString('en-US', { timeZone: 'America/Toronto' }); - const testStatus = "${{ needs.check-test-results.outputs.test-status }}"; - const commentBody = `Tests status: ${test-status } ${currentTime}.`; + const runURL = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${{ github.run_id }}`; + const commentBody = `retest Integration: All tests pass ✅. \n[View Actions Run](${runURL}).`; github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, From 124db88ddd0fe2ecd9dd15eedbfca323c1c7bf33 Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Fri, 13 Oct 2023 18:31:34 -0400 Subject: [PATCH 14/22] added extra conditions on retest intergration --- .github/workflows/ci-build-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-build-image.yml b/.github/workflows/ci-build-image.yml index f47b9867b6..97d0b27b2d 100644 --- a/.github/workflows/ci-build-image.yml +++ b/.github/workflows/ci-build-image.yml @@ -144,7 +144,7 @@ jobs: retest-integration-tests: runs-on: ubuntu-latest - if: ${{ !inputs.skip-itests && inputs.run-tests-only }} + if: ${{ !inputs.skip-itests && inputs.run-tests-only && inputs.pr-number != '' && inputs.sha-value != '' }} steps: - name: Install xpath run: | From 11b30b6010ca11b70a16a2c381916edfbb3c5832 Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Mon, 16 Oct 2023 10:54:36 -0400 Subject: [PATCH 15/22] removed unnecessary step:always() --- .github/workflows/pr-ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/pr-ci.yml b/.github/workflows/pr-ci.yml index 427f7c8b54..d5759295d5 100644 --- a/.github/workflows/pr-ci.yml +++ b/.github/workflows/pr-ci.yml @@ -127,7 +127,6 @@ jobs: steps: - name: Leave Actions Run Comment uses: actions/github-script@v6 - if: always() with: script: | const runURL = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${{ github.run_id }}`; @@ -146,7 +145,6 @@ jobs: steps: - name: Leave Actions Run Comment uses: actions/github-script@v6 - if: always() with: script: | const runURL = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${{ github.run_id }}`; From b154eae747fa927df45709c24dcd9b0900e867a7 Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Tue, 24 Oct 2023 15:25:45 -0400 Subject: [PATCH 16/22] separated workflows build and itest --- .github/workflows/ci-build-image.yml | 104 ++------------------ .github/workflows/integrated-test.yml | 79 +++++++++++++++ .github/workflows/pr-ci.yml | 136 +++++++++++++------------- 3 files changed, 157 insertions(+), 162 deletions(-) create mode 100644 .github/workflows/integrated-test.yml diff --git a/.github/workflows/ci-build-image.yml b/.github/workflows/ci-build-image.yml index 97d0b27b2d..f73fec7f87 100644 --- a/.github/workflows/ci-build-image.yml +++ b/.github/workflows/ci-build-image.yml @@ -1,3 +1,5 @@ +name: build cryostat image + on: workflow_call: inputs: @@ -10,20 +12,10 @@ on: build-arch: required: true type: string - skip-itests: - required: false - type: boolean - default: false run-tests-only: required: false type: boolean default: false - pr-number: - required: false - type: string - sha-value: - required: false - type: string outputs: image-version: description: the Cryostat application version that will be built @@ -52,6 +44,10 @@ jobs: build-image: runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + permissions: + pull-requests: write if: ${{ !inputs.run-tests-only }} needs: [get-pom-properties] steps: @@ -75,8 +71,8 @@ jobs: - name: maven-settings uses: s4u/maven-settings-action@v2 with: - servers: '[{"id": "github", "username": "dummy", "password": "${env.GITHUB_TOKEN_REF}"}]' - githubServer: false + servers: '[{"id": "github", "username": "dummy", "password": "${env.GITHUB_TOKEN}"}]' + githubServer: true - uses: skjolber/maven-cache-github-action@v1 with: step: restore @@ -94,87 +90,3 @@ jobs: - uses: skjolber/maven-cache-github-action@v1 with: step: save - - integration-tests: - runs-on: ubuntu-latest - needs: [build-image] - if: ${{ !inputs.skip-itests && !inputs.run-tests-only }} - steps: - - name: Install xpath - run: | - sudo apt-get update - sudo apt-get install -y libxml-xpath-perl - - name: Install qemu - if: ${{ inputs.build-arch != 'amd64' }} - continue-on-error: true - run: | - sudo apt-get update - sudo apt-get install -y qemu-user-static - - uses: actions/checkout@v4 - if: always() - with: - repository: ${{ inputs.checkout-repo }} - ref: ${{ inputs.checkout-ref }} - submodules: true - fetch-depth: 0 - - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'temurin' - - name: Download Cryostat Image Artifact - uses: actions/download-artifact@v3 - with: - name: cryostat-${{ inputs.build-arch }} - - name: Load cryostat image - run: podman load -i cryostat-${{ inputs.build-arch }}.tar - - uses: skjolber/maven-cache-github-action@v1 - with: - step: restore - - name: Run integration tests - run: POD_NAME=cryostat-itests CONTAINER_NAME=cryostat-itest ITEST_IMG_VERSION=latest bash repeated-integration-tests.bash - - name: Print itest logs - if: failure() - run: ls -1dt target/cryostat-itest-*.log | head -n1 | xargs cat - - name: Print itest container logs - if: failure() - run: ls -1dt target/cryostat-*.server.log | head -n1 | xargs cat - - uses: skjolber/maven-cache-github-action@v1 - with: - step: save - - retest-integration-tests: - runs-on: ubuntu-latest - if: ${{ !inputs.skip-itests && inputs.run-tests-only && inputs.pr-number != '' && inputs.sha-value != '' }} - steps: - - name: Install xpath - run: | - sudo apt-get update - sudo apt-get install -y libxml-xpath-perl - - name: Install qemu - if: ${{ inputs.build-arch != 'amd64' }} - continue-on-error: true - run: | - sudo apt-get update - sudo apt-get install -y qemu-user-static - - uses: actions/checkout@v4 - with: - repository: ${{ github.repository_owner }}/cryostat - ref: ${{ inputs.checkout-ref }} - submodules: true - fetch-depth: 0 - - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'temurin' - - name: Pull cryostat image - run: podman pull ghcr.io/${{ github.repository_owner }}/cryostat:pr-${{ inputs.pr-number }}-${{ inputs.sha-value }}-linux-${{ inputs.build-arch }} - - name: Run integration tests - run: POD_NAME=cryostat-itests CONTAINER_NAME=cryostat-itest ITEST_IMG_VERSION=latest bash repeated-integration-tests.bash - - name: Print itest logs - if: failure() - run: ls -1dt target/cryostat-itest-*.log | head -n1 | xargs cat - - name: Print itest container logs - if: failure() - run: ls -1dt target/cryostat-*.server.log | head -n1 | xargs cat - - diff --git a/.github/workflows/integrated-test.yml b/.github/workflows/integrated-test.yml new file mode 100644 index 0000000000..79d4e49723 --- /dev/null +++ b/.github/workflows/integrated-test.yml @@ -0,0 +1,79 @@ +name: Retest Integrated Tests + +on: + workflow_call: + inputs: + checkout-repo: + required: false + type: string + checkout-ref: + required: false + type: string + build-arch: + required: true + type: string + pr-number: + required: false + type: string + sha-value: + required: false + type: string + skip-itests: + required: false + type: boolean + default: false + +permissions: + contents: read + packages: read + + +jobs: + integration-tests: #test + runs-on: ubuntu-latest + if: ${{ !inputs.skip-itests }} + steps: + - name: Install xpath + run: | + sudo apt-get update + sudo apt-get install -y libxml-xpath-perl + - name: Install qemu + if: ${{ inputs.build-arch != 'amd64' }} + continue-on-error: true + run: | + sudo apt-get update + sudo apt-get install -y qemu-user-static + - uses: actions/checkout@v4 + with: + repository: ${{ github.repository_owner }}/cryostat + ref: ${{ inputs.checkout-ref }} + submodules: true + fetch-depth: 0 + - uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + - name: maven-settings + uses: s4u/maven-settings-action@v2 + with: + githubServer: true + - name: ghcr login + uses: redhat-actions/podman-login@v1 + with: + registry: ghcr.io/${{ github.repository_owner }} + username: ${{ github.event.comment.user.login }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Pull cryostat image + run: podman pull ghcr.io/${{ github.repository_owner }}/cryostat:pr-${{ inputs.pr-number }}-${{ inputs.sha-value }}-linux-${{ inputs.build-arch }} + - name: retag image as quay + run: podman tag ghcr.io/${{ github.repository_owner }}/cryostat:pr-${{ inputs.pr-number }}-${{ inputs.sha-value }}-linux-${{ inputs.build-arch}} quay.io/cryostat/cryostat + - name: Run integration tests + run: POD_NAME=cryostat-itests CONTAINER_NAME=cryostat-itest ITEST_IMG_VERSION=latest bash repeated-integration-tests.bash + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Print itest logs + if: failure() + run: ls -1dt target/cryostat-itest-*.log | head -n1 | xargs cat + - name: Print itest container logs + if: failure() + run: ls -1dt target/cryostat-*.server.log | head -n1 | xargs catyea diff --git a/.github/workflows/pr-ci.yml b/.github/workflows/pr-ci.yml index d5759295d5..bde6fe9450 100644 --- a/.github/workflows/pr-ci.yml +++ b/.github/workflows/pr-ci.yml @@ -69,42 +69,15 @@ jobs: code-analysis: needs: [checkout-branch] + if: startsWith(github.event.comment.body, '/build_test') uses: ./.github/workflows/ci-code-analysis.yml with: checkout-repo: ${{ needs.checkout-branch.outputs.PR_repo }} checkout-ref: ${{ needs.checkout-branch.outputs.PR_head_ref }} - - build-and-test: - needs: [code-analysis, checkout-branch] - if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/build_test') - strategy: - matrix: - arch: [amd64, arm64] - uses: ./.github/workflows/ci-build-image.yml - with: - build-arch: ${{ matrix.arch }} - checkout-repo: ${{ needs.checkout-branch.outputs.PR_repo }} - checkout-ref: ${{ needs.checkout-branch.outputs.PR_head_ref }} - skip-itests: ${{ matrix.arch != 'amd64' }} - -# Add a new step to use /retest - retest-integration: - needs: [code-analysis, checkout-branch] - if: contains(github.event.comment.body, '/retest') - strategy: - matrix: - arch: [amd64, arm64] - uses: ./.github/workflows/ci-build-image.yml - with: - build-arch: ${{ matrix.arch }} - run-tests-only: true - pr-number: ${{ github.event.issue.number }} - sha-value: ${{ needs.checkout-branch.outputs.PR_head_sha }} start-comment: runs-on: ubuntu-latest needs: [check-before-build] - if: ${{ needs.check-before-build.result == 'success' }} steps: - name: Leave Actions Run Comment uses: actions/github-script@v6 @@ -120,46 +93,21 @@ jobs: body: commentBody }); - build-and-test-pass: - runs-on: ubuntu-latest - needs: [build-and-test] - if: ${{ needs.build-and-test.result == 'success' }} - steps: - - name: Leave Actions Run Comment - uses: actions/github-script@v6 - with: - script: | - const runURL = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${{ github.run_id }}`; - const commentBody = `build-and-test: All tests pass ✅. \n[View Actions Run](${runURL}).`; - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: commentBody - }); - - retest-integration-pass: - runs-on: ubuntu-latest - needs: [retest-integration] - if: ${{ needs.retest-integration.result == 'success' }} - steps: - - name: Leave Actions Run Comment - uses: actions/github-script@v6 - with: - script: | - const runURL = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${{ github.run_id }}`; - const commentBody = `retest Integration: All tests pass ✅. \n[View Actions Run](${runURL}).`; - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: commentBody - }); + build-image: + needs: [checkout-branch] + if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/build_test') + strategy: + matrix: + arch: [amd64, arm64] + uses: ./.github/workflows/ci-build-image.yml + with: + build-arch: ${{ matrix.arch }} + checkout-repo: ${{ needs.checkout-branch.outputs.PR_repo }} + checkout-ref: ${{ needs.checkout-branch.outputs.PR_head_ref }} push-to-ghcr: runs-on: ubuntu-latest - if: startsWith(github.event.comment.body, '/build_test') - needs: [build-and-test, checkout-branch] + needs: [checkout-branch, build-image] strategy: matrix: arch: [amd64, arm64] @@ -199,7 +147,6 @@ jobs: comment-image: runs-on: ubuntu-latest - if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/build_test') needs: [push-to-ghcr] env: amd64_image: ${{ needs.push-to-ghcr.outputs.amd64_image }} @@ -228,3 +175,60 @@ jobs: # or arm64 CRYOSTAT_IMAGE=${{ env.arm64_image }} sh smoketest.sh ``` + + integration-test: + needs: [checkout-branch, push-to-ghcr] + strategy: + matrix: + arch: [amd64, arm64] + uses: ./.github/workflows/integrated-test.yml + with: + build-arch: ${{ matrix.arch }} + pr-number: ${{ github.event.issue.number }} + sha-value: ${{ needs.checkout-branch.outputs.PR_head_sha }} + + retest-integration: + needs: [checkout-branch] + if: contains(github.event.comment.body, '/retest') + strategy: + matrix: + arch: [amd64, arm64] + uses: ./.github/workflows/integrated-test.yml + with: + build-arch: ${{ matrix.arch }} + pr-number: ${{ github.event.issue.number }} + sha-value: ${{ needs.checkout-branch.outputs.PR_head_sha }} + + integration-test-pass: + runs-on: ubuntu-latest + needs: [integration-test] + steps: + - name: Leave Actions Run Comment + uses: actions/github-script@v6 + with: + script: | + const runURL = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${{ github.run_id }}`; + const commentBody = both build and itest completed successfully ✅. \n[View Actions Run](${runURL}).`; + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: commentBody + }); + + retest-integration-pass: + runs-on: ubuntu-latest + needs: [retest-integration] + steps: + - name: Leave Actions Run Comment + uses: actions/github-script@v6 + with: + script: | + const runURL = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${{ github.run_id }}`; + const commentBody = `retest Integration: All tests pass ✅. \n[View Actions Run](${runURL}).`; + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: commentBody + }); From 19105cc1d0428a13f8b713994d759a8643ab395a Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Tue, 24 Oct 2023 18:04:50 -0400 Subject: [PATCH 17/22] resolved issues --- .github/workflows/ci-build-image.yml | 15 ++++++--------- .github/workflows/integrated-test.yml | 2 +- .github/workflows/pr-ci.yml | 2 ++ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci-build-image.yml b/.github/workflows/ci-build-image.yml index f73fec7f87..3edfe81a6e 100644 --- a/.github/workflows/ci-build-image.yml +++ b/.github/workflows/ci-build-image.yml @@ -12,10 +12,6 @@ on: build-arch: required: true type: string - run-tests-only: - required: false - type: boolean - default: false outputs: image-version: description: the Cryostat application version that will be built @@ -44,11 +40,8 @@ jobs: build-image: runs-on: ubuntu-latest - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} permissions: pull-requests: write - if: ${{ !inputs.run-tests-only }} needs: [get-pom-properties] steps: - name: Install qemu @@ -58,7 +51,6 @@ jobs: sudo apt-get update sudo apt-get install -y qemu-user-static - uses: actions/checkout@v4 - if: always() with: repository: ${{ inputs.checkout-repo }} ref: ${{ inputs.checkout-ref }} @@ -71,8 +63,13 @@ jobs: - name: maven-settings uses: s4u/maven-settings-action@v2 with: - servers: '[{"id": "github", "username": "dummy", "password": "${env.GITHUB_TOKEN}"}]' githubServer: true + - name: ghcr login + uses: redhat-actions/podman-login@v1 + with: + registry: ghcr.io/${{ github.repository_owner }} + username: ${{ github.event.comment.user.login }} + password: ${{ secrets.GITHUB_TOKEN }} - uses: skjolber/maven-cache-github-action@v1 with: step: restore diff --git a/.github/workflows/integrated-test.yml b/.github/workflows/integrated-test.yml index 79d4e49723..73ee420886 100644 --- a/.github/workflows/integrated-test.yml +++ b/.github/workflows/integrated-test.yml @@ -45,7 +45,7 @@ jobs: sudo apt-get install -y qemu-user-static - uses: actions/checkout@v4 with: - repository: ${{ github.repository_owner }}/cryostat + repository: ${{ inputs.checkout-repo }} ref: ${{ inputs.checkout-ref }} submodules: true fetch-depth: 0 diff --git a/.github/workflows/pr-ci.yml b/.github/workflows/pr-ci.yml index bde6fe9450..55995e865e 100644 --- a/.github/workflows/pr-ci.yml +++ b/.github/workflows/pr-ci.yml @@ -186,6 +186,7 @@ jobs: build-arch: ${{ matrix.arch }} pr-number: ${{ github.event.issue.number }} sha-value: ${{ needs.checkout-branch.outputs.PR_head_sha }} + skip-itests: ${{ matrix.arch == 'arm64' }} retest-integration: needs: [checkout-branch] @@ -198,6 +199,7 @@ jobs: build-arch: ${{ matrix.arch }} pr-number: ${{ github.event.issue.number }} sha-value: ${{ needs.checkout-branch.outputs.PR_head_sha }} + skip-itests: ${{ matrix.arch == 'arm64' }} integration-test-pass: runs-on: ubuntu-latest From c45c0699b9ce1ff32453d4bd8d47491a5301e761 Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Tue, 24 Oct 2023 19:12:34 -0400 Subject: [PATCH 18/22] missed a backslash --- .github/workflows/pr-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-ci.yml b/.github/workflows/pr-ci.yml index 55995e865e..035aa77c4c 100644 --- a/.github/workflows/pr-ci.yml +++ b/.github/workflows/pr-ci.yml @@ -210,7 +210,7 @@ jobs: with: script: | const runURL = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${{ github.run_id }}`; - const commentBody = both build and itest completed successfully ✅. \n[View Actions Run](${runURL}).`; + const commentBody = `both build and itest completed successfully ✅. \n[View Actions Run](${runURL}).`; github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, From 9372ed0f0c767003a6e05d358ae0071c226deeb7 Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Wed, 25 Oct 2023 11:29:38 -0400 Subject: [PATCH 19/22] resolved more issues --- .github/workflows/integrated-test.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/integrated-test.yml b/.github/workflows/integrated-test.yml index 73ee420886..fdac3aff9f 100644 --- a/.github/workflows/integrated-test.yml +++ b/.github/workflows/integrated-test.yml @@ -27,9 +27,8 @@ permissions: contents: read packages: read - jobs: - integration-tests: #test + integration-tests: runs-on: ubuntu-latest if: ${{ !inputs.skip-itests }} steps: From 4501f4c91fbed41f0508676dc450de078c02b16d Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Thu, 26 Oct 2023 09:47:48 -0400 Subject: [PATCH 20/22] resolved issues --- .github/workflows/ci-build-image.yml | 2 +- .github/workflows/integrated-test.yml | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci-build-image.yml b/.github/workflows/ci-build-image.yml index 3edfe81a6e..a0b20983d0 100644 --- a/.github/workflows/ci-build-image.yml +++ b/.github/workflows/ci-build-image.yml @@ -63,7 +63,7 @@ jobs: - name: maven-settings uses: s4u/maven-settings-action@v2 with: - githubServer: true + githubServer: false - name: ghcr login uses: redhat-actions/podman-login@v1 with: diff --git a/.github/workflows/integrated-test.yml b/.github/workflows/integrated-test.yml index fdac3aff9f..3c34eae58f 100644 --- a/.github/workflows/integrated-test.yml +++ b/.github/workflows/integrated-test.yml @@ -1,4 +1,4 @@ -name: Retest Integrated Tests +name: Retest Integration Tests on: workflow_call: @@ -30,7 +30,6 @@ permissions: jobs: integration-tests: runs-on: ubuntu-latest - if: ${{ !inputs.skip-itests }} steps: - name: Install xpath run: | @@ -55,7 +54,7 @@ jobs: - name: maven-settings uses: s4u/maven-settings-action@v2 with: - githubServer: true + githubServer: false - name: ghcr login uses: redhat-actions/podman-login@v1 with: From 6a4b2fc7f37c47c95f46738c8b80caf3e30560db Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Thu, 26 Oct 2023 15:41:22 -0400 Subject: [PATCH 21/22] added test failure comment --- .github/workflows/integrated-test.yml | 2 +- .github/workflows/pr-ci.yml | 46 +++++++++++++++++++++++---- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/.github/workflows/integrated-test.yml b/.github/workflows/integrated-test.yml index 3c34eae58f..5f60f808f9 100644 --- a/.github/workflows/integrated-test.yml +++ b/.github/workflows/integrated-test.yml @@ -54,7 +54,7 @@ jobs: - name: maven-settings uses: s4u/maven-settings-action@v2 with: - githubServer: false + githubServer: true - name: ghcr login uses: redhat-actions/podman-login@v1 with: diff --git a/.github/workflows/pr-ci.yml b/.github/workflows/pr-ci.yml index 035aa77c4c..52a0b6fbca 100644 --- a/.github/workflows/pr-ci.yml +++ b/.github/workflows/pr-ci.yml @@ -180,26 +180,24 @@ jobs: needs: [checkout-branch, push-to-ghcr] strategy: matrix: - arch: [amd64, arm64] + arch: [amd64] uses: ./.github/workflows/integrated-test.yml with: build-arch: ${{ matrix.arch }} pr-number: ${{ github.event.issue.number }} sha-value: ${{ needs.checkout-branch.outputs.PR_head_sha }} - skip-itests: ${{ matrix.arch == 'arm64' }} - + retest-integration: needs: [checkout-branch] if: contains(github.event.comment.body, '/retest') strategy: matrix: - arch: [amd64, arm64] + arch: [md64] uses: ./.github/workflows/integrated-test.yml with: build-arch: ${{ matrix.arch }} pr-number: ${{ github.event.issue.number }} sha-value: ${{ needs.checkout-branch.outputs.PR_head_sha }} - skip-itests: ${{ matrix.arch == 'arm64' }} integration-test-pass: runs-on: ubuntu-latest @@ -210,7 +208,7 @@ jobs: with: script: | const runURL = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${{ github.run_id }}`; - const commentBody = `both build and itest completed successfully ✅. \n[View Actions Run](${runURL}).`; + const commentBody = `\`/build_test\` completed successfully ✅. \n[View Actions Run](${runURL}).`; github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, @@ -227,7 +225,41 @@ jobs: with: script: | const runURL = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${{ github.run_id }}`; - const commentBody = `retest Integration: All tests pass ✅. \n[View Actions Run](${runURL}).`; + const commentBody = `\`/retest\` Integration: All tests pass ✅. \n[View Actions Run](${runURL}).`; + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: commentBody + }); + + comment-integration-test-fail: + if: (always() && contains(needs.*.result, 'failure')) + needs: [integration-test] + runs-on: ubuntu-latest + steps: + - uses: actions/github-script@v6 + with: + script: | + const runURL = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${{ github.run_id }}`; + const commentBody = `\`/build_test\` : At least one test failed ❌. \n[View Actions Run](${runURL}).`; + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: commentBody + }); + + comment-retest-integration-fail: + if: (always() && contains(needs.*.result, 'failure')) + needs: [retest-integration] + runs-on: ubuntu-latest + steps: + - uses: actions/github-script@v6 + with: + script: | + const runURL = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${{ github.run_id }}`; + const commentBody = `\`/retest\` Integration: At least one test failed ❌. \n[View Actions Run](${runURL}).`; github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, From c7144892d35a0bd79f342b08e54a8d04221d57ab Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Thu, 26 Oct 2023 15:52:06 -0400 Subject: [PATCH 22/22] fixed the failing test --- .github/workflows/pr-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-ci.yml b/.github/workflows/pr-ci.yml index 52a0b6fbca..f3abd44d7d 100644 --- a/.github/workflows/pr-ci.yml +++ b/.github/workflows/pr-ci.yml @@ -192,7 +192,7 @@ jobs: if: contains(github.event.comment.body, '/retest') strategy: matrix: - arch: [md64] + arch: [amd64] uses: ./.github/workflows/integrated-test.yml with: build-arch: ${{ matrix.arch }}