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