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,