diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0da38800..ce48e11d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -54,7 +54,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Install qemu - if: ${{ inputs.build-arch != 'amd64' }} + if: ${{ matrix.arch != 'amd64' }} continue-on-error: true run: | sudo apt-get update @@ -98,7 +98,7 @@ jobs: strategy: matrix: arch: [amd64, arm64] - outputs: + outputs: amd64_image: ${{ steps.amd64_image.outputs.image }} arm64_image: ${{ steps.arm64_image.outputs.image }} permissions: @@ -141,7 +141,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 }} @@ -153,7 +153,7 @@ jobs: To run smoketest: ``` - # amd64 + # amd64 CRYOSTAT_IMAGE=${{ env.amd64_image }} sh smoketest.sh # or arm64 diff --git a/.github/workflows/cryostat-test.yml b/.github/workflows/cryostat-test.yml index cb9c0c05..6c1c6921 100644 --- a/.github/workflows/cryostat-test.yml +++ b/.github/workflows/cryostat-test.yml @@ -41,10 +41,10 @@ jobs: 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 }} @@ -97,6 +97,7 @@ jobs: username: ${{ github.event.comment.user.login }} password: ${{ secrets.GITHUB_TOKEN }} - name: pull cryostat image + id: pull-image run: podman pull ghcr.io/${{ github.repository_owner }}/cryostat-core:pr-${{ needs.checkout-branch.outputs.PR_num }}-${{ needs.checkout-branch.outputs.PR_head_sha }}-linux-${{ env.build_arch }} - name: tag cryostat image run: podman tag ghcr.io/${{ github.repository_owner }}/cryostat-core:pr-${{ needs.checkout-branch.outputs.PR_num }}-${{ needs.checkout-branch.outputs.PR_head_sha }}-linux-${{ env.build_arch }} quay.io/cryostat/cryostat @@ -110,3 +111,40 @@ jobs: - name: Print itest container logs if: failure() run: ls -1dt target/cryostat-*.server.log | head -n1 | xargs cat + - name: Add workflow result as comment on PR + uses: actions/github-script@v6 + if: always() + with: + script: | + const name = '${{ github.workflow }}'; + const url = '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'; + const success = '${{ job.status }}' === 'success'; + const body = `${name}: ${success ? 'All tests pass ✅' : 'At least one test failed ❌'}\n${url}`; + + await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: body + }) + + - name: Leave a comment on pull failure + uses: actions/github-script@v6 + if: always() && steps.pull-image.outcome != 'success' + with: + script: | + const body = `Image does not exist! Please wait for the initial build and push to complete before using \`/build_test\` command.`; + await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: body + }) + + - name: Set latest commit status as ${{ job.status }} + uses: myrotvorets/set-commit-status-action@master + if: always() + with: + sha: ${{ needs.checkout-branch.outputs.PR_head_sha}} + token: ${{ secrets.GITHUB_TOKEN }} + status: ${{ job.status }}