Skip to content

Commit

Permalink
added test pass and retest job
Browse files Browse the repository at this point in the history
  • Loading branch information
aali309 committed Oct 13, 2023
1 parent ace6887 commit bb9a36d
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 63 deletions.
73 changes: 36 additions & 37 deletions .github/workflows/ci-build-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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


54 changes: 28 additions & 26 deletions .github/workflows/pr-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down

0 comments on commit bb9a36d

Please sign in to comment.