|
| 1 | +name: Check TestHub results |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +jobs: |
| 7 | + request_status: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + steps: |
| 10 | + - name: Get branch name and latest commit SHA |
| 11 | + id: vars |
| 12 | + run: | |
| 13 | + BRANCH_NAME="${{ github.event.pull_request.head.ref }}" |
| 14 | + # Replace "/" with "%2F" in branch name |
| 15 | + BRANCH_NAME="${BRANCH_NAME//\//%2F}" |
| 16 | + COMMIT_SHA="${{ github.event.pull_request.head.sha }}" |
| 17 | + echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV |
| 18 | + echo "COMMIT_SHA=$COMMIT_SHA" >> $GITHUB_ENV |
| 19 | +
|
| 20 | + - name: Fetch test results |
| 21 | + id: fetch_results |
| 22 | + run: | |
| 23 | + TEST_URL="https://testhub.mesastar.org/${{ env.BRANCH_NAME }}/commits/${{ env.COMMIT_SHA }}" |
| 24 | + if [ -z "$BRANCH_NAME" ]; then |
| 25 | + TEST_URL="https://testhub.mesastar.org" |
| 26 | + fi |
| 27 | + echo "Fetching test results from: $TEST_URL" |
| 28 | + |
| 29 | + RESPONSE=$(curl -s -o response.json -w "%{http_code}" "$TEST_URL") |
| 30 | + |
| 31 | + if [[ "$RESPONSE" -ne 200 ]]; then |
| 32 | + echo "Test results not found or server error." |
| 33 | + exit 1 |
| 34 | + fi |
| 35 | +
|
| 36 | + # cat response.json |
| 37 | +
|
| 38 | + PASS_COUNT=$(grep -B 1 "tests where all computers report passing." response.json | sed -n -E -e 's/<b>([0-9]+)<\/b>.*/\1/p') |
| 39 | + echo "Number of passing tests: $PASS_COUNT" |
| 40 | +
|
| 41 | + FAIL_COUNT=$(grep -B 1 "tests where all computers report failing." response.json | sed -n -E -e 's/<b>([0-9]+)<\/b>.*/\1/p') |
| 42 | + echo "Number of failing tests: $FAIL_COUNT" |
| 43 | +
|
| 44 | + MIXED_COUNT=$(grep -B 1 "tests where some computers report passing and others report failing." response.json | sed -n -E -e 's/<b>([0-9]+)<\/b>.*/\1/p') |
| 45 | + echo "Number of mixed tests: $MIXED_COUNT" |
| 46 | +
|
| 47 | + UNTESTED_COUNT=$(grep -B 1 "tests with no submission data." response.json | sed -n -E -e 's/<b>([0-9]+)<\/b>.*/\1/p') |
| 48 | + echo "Number of untested tests: $UNTESTED_COUNT" |
| 49 | +
|
| 50 | + echo "" |
| 51 | + |
| 52 | + # Check that there are no failing or mixed tests |
| 53 | + if [[ "$FAIL_COUNT" -gt 0 || "$MIXED_COUNT" -gt 0 ]]; then |
| 54 | + echo "Some tests are failing or mixed!" |
| 55 | + exit 1 |
| 56 | + fi |
| 57 | + # Check that there are at least 106 passing tests |
| 58 | + if [[ "$PASS_COUNT" -lt 106 ]]; then |
| 59 | + echo "Not enough passing tests!" |
| 60 | + exit 1 |
| 61 | + else |
| 62 | + echo "All tests are passing!" |
| 63 | + fi |
| 64 | +
|
| 65 | + - name: Allow merge if tests pass |
| 66 | + if: success() |
| 67 | + run: echo "All tests passed. PR is good to merge!" |
0 commit comments