|
| 1 | +name: "ondemand test" |
| 2 | + |
| 3 | +on: |
| 4 | + issue_comment: |
| 5 | + types: [created] |
| 6 | + |
| 7 | +permissions: |
| 8 | + pull-requests: write |
| 9 | + checks: read |
| 10 | + contents: read |
| 11 | + |
| 12 | +jobs: |
| 13 | + preprocess: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + outputs: |
| 16 | + continue: ${{ steps.check.outputs.continue }} |
| 17 | + op: ${{ steps.parse-command.outputs.OP_ID}} |
| 18 | + runner: ${{ steps.parse-command.outputs.RUNNER }} |
| 19 | + pull: ${{ steps.parse-command.outputs.PR_NUMBER }} |
| 20 | + existing: ${{ steps.parse-command.outputs.EXISTING_OP }} |
| 21 | + steps: |
| 22 | + - id: check |
| 23 | + uses: github.qkg1.topmand@v2.0.3 |
| 24 | + with: |
| 25 | + command: "/test" |
| 26 | + allowed_contexts: pull_request |
| 27 | + allow_forks: "true" |
| 28 | + skip_reviews: "true" |
| 29 | + fork_review_bypass: "true" |
| 30 | + permissions: "write,admin" |
| 31 | + |
| 32 | + - id: parse-command |
| 33 | + if: ${{ steps.check.outputs.continue == 'true' }} |
| 34 | + env: |
| 35 | + PULL_NUMBER: ${{ github.event.issue.number }} |
| 36 | + run: | |
| 37 | + # Parse command arguments |
| 38 | + params=${{ steps.check.outputs.params }} |
| 39 | + op=$(echo $params | cut -d ':' -f 1) |
| 40 | + runner=$(echo $params | cut -d ':' -f 2) |
| 41 | + echo "OP_ID=${op}" >> $GITHUB_OUTPUT |
| 42 | + echo "RUNNER=${runner}" >> $GITHUB_OUTPUT |
| 43 | + echo "PR_NUMBER=${PULL_NUMBER}" >> $GITHUB_OUTPUT |
| 44 | +
|
| 45 | + # Detect if operator exists before |
| 46 | + num=$(grep "pytest.mark.${{ needs.preprocess.outputs.op }}" -r tests | wc -l) |
| 47 | + if [ "$num" -eq "0" ]; then |
| 48 | + echo "EXISTING_OP=1" >> $GITHUB_ENV |
| 49 | + else |
| 50 | + echo "EXISTING_OP=0" >> $GITHUB_ENV |
| 51 | + fi |
| 52 | +
|
| 53 | + test-operator: |
| 54 | + needs: preprocess |
| 55 | + if: needs.preprocess.outputs.continue == 'true' |
| 56 | + runs-on: ${{ needs.preprocess.outputs.runner }} |
| 57 | + steps: |
| 58 | + - id: checkout-attempt-1 |
| 59 | + uses: actions/checkout@v6 |
| 60 | + continue-on-error: true |
| 61 | + - id: sleep-1 |
| 62 | + if: steps.checkout-attempt-1.outcome == 'failure' |
| 63 | + shell: bash |
| 64 | + run: sleep 30s |
| 65 | + |
| 66 | + - id: checkout-attempt-2 |
| 67 | + if: steps.checkout-attempt-1.outcome == 'failure' |
| 68 | + uses: actions/checkout@v6 |
| 69 | + continue-on-error: true |
| 70 | + - id: sleep-2 |
| 71 | + if: steps.checkout-attempt-2.outcome == 'failure' |
| 72 | + shell: bash |
| 73 | + run: sleep 30s |
| 74 | + |
| 75 | + - id: checkout-attempt-3 |
| 76 | + if: steps.checkout-attempt-2.outcome == 'failure' |
| 77 | + uses: actions/checkout@v6 |
| 78 | + |
| 79 | + - id: checkout-pr |
| 80 | + env: |
| 81 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 82 | + run: | |
| 83 | + echo "checking out ${{ needs.preprocess.outputs.pull }}" |
| 84 | + gh pr checkout ${{ needs.preprocess.outputs.pull }} |
| 85 | +
|
| 86 | + - name: Setup FlagGems |
| 87 | + shell: bash |
| 88 | + env: |
| 89 | + RUNNER_LABEL: ${{ needs.preprocess.outputs.runner }} |
| 90 | + run: | |
| 91 | + # Validate vendor names |
| 92 | + case "${RUNNER_LABEL}" in |
| 93 | + h20) |
| 94 | + VENDOR="nvidia" |
| 95 | + ;; |
| 96 | + moore) |
| 97 | + VENDOR="mthreads" |
| 98 | + ;; |
| 99 | + *) |
| 100 | + VENDOR="${RUNNER_LABEL}" |
| 101 | + ;; |
| 102 | + esac |
| 103 | +
|
| 104 | + echo "VENDOR=${VENDOR}" |
| 105 | + echo "VENDOR=${VENDOR}" >> $GITHUB_ENV |
| 106 | +
|
| 107 | + ./setup.sh ${VENDOR} |
| 108 | +
|
| 109 | + - name: Check GPU availability |
| 110 | + shell: bash |
| 111 | + run: | |
| 112 | + bash "tools/gpu_check_${VENDOR}.sh" |
| 113 | +
|
| 114 | + - name: Run tests |
| 115 | + shell: bash |
| 116 | + env: |
| 117 | + EXISTING_OP: ${{ needs.preprocess.outputs.existing }} |
| 118 | + run: | |
| 119 | + source .venv/bin/activate |
| 120 | + source tools/set-env.sh ${VENDOR} |
| 121 | + tools/run_tests.py --ops ${{ needs.preprocess.outputs.op }} \ |
| 122 | + --dump-output \ |
| 123 | + --output-dir results_new |
| 124 | +
|
| 125 | + if [ "$EXISTING_OP" == "0" ]; then |
| 126 | + tools/psum_text --format markdown \ |
| 127 | + --output report.md \ |
| 128 | + --single \ |
| 129 | + results_new |
| 130 | + mv results_new results |
| 131 | + else |
| 132 | + git checkout master |
| 133 | + tools/run_tests.py --ops ${{ needs.preprocess.outputs.op }} \ |
| 134 | + --dump-output \ |
| 135 | + --output-dir results_old |
| 136 | +
|
| 137 | + # merge two data sets into one directory |
| 138 | + mkdir results |
| 139 | + mv results_old results/before |
| 140 | + mv results_new results/after |
| 141 | +
|
| 142 | + tools/psum_text --format markdown \ |
| 143 | + --single \ |
| 144 | + --compare \ |
| 145 | + --output report.md \ |
| 146 | + results |
| 147 | + fi |
| 148 | +
|
| 149 | + - name: Upload results |
| 150 | + uses: actions/upload-artifact@v7 |
| 151 | + with: |
| 152 | + name: ondemand-test |
| 153 | + path: results/ |
| 154 | + |
| 155 | + - name: comment |
| 156 | + uses: mshick/add-pr-comment@v3 |
| 157 | + with: |
| 158 | + message-path: report.md |
| 159 | + message-id: ${{ needs.preprocess.outputs.op }}-${{ needs.preprocess.outputs.runner }} |
| 160 | + allow-repeats: True |
| 161 | + attach-path: results/* |
| 162 | + attach-name: report-${{ needs.preprocess.outputs.op }}-${{ needs.preprocess.outputs.runner }} |
| 163 | + attach-text: '📎 [Download %ATTACH_NAME%](%ARTIFACT_URL%)' |
0 commit comments