Skip to content

Commit 83caba6

Browse files
Adding action.yaml (#1030)
Signed-off-by: Iryna Boiko <iboiko@habana.ai>
1 parent f7aa899 commit 83caba6

File tree

2 files changed

+260
-0
lines changed

2 files changed

+260
-0
lines changed
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
name: Get PR Details
2+
description: 'Retrieves pull request details for pull_request_target or merge_group events'
3+
4+
inputs:
5+
event_name:
6+
description: 'Event name that triggered the caller workflow'
7+
required: true
8+
pr_number:
9+
description: 'PR number for pull_request_target events'
10+
required: false
11+
merge_group_head_ref:
12+
description: 'Merge group head ref for merge_group events'
13+
required: false
14+
15+
outputs:
16+
pr_number:
17+
description: 'Pull request number'
18+
value: ${{ steps.get_pr_details.outputs.pr_number }}
19+
pr_title:
20+
description: 'Pull request title'
21+
value: ${{ steps.get_pr_details.outputs.pr_title }}
22+
pr_labels:
23+
description: 'Pull request labels (comma-separated)'
24+
value: ${{ steps.get_pr_details.outputs.pr_labels }}
25+
pr_base_ref:
26+
description: 'Pull request base reference'
27+
value: ${{ steps.get_pr_details.outputs.pr_base_ref }}
28+
skip_gaudi_tests:
29+
description: 'Whether to skip Gaudi tests'
30+
value: ${{ steps.get_pr_details.outputs.skip_gaudi_tests }}
31+
32+
runs:
33+
using: 'composite'
34+
steps:
35+
- name: Retrieve Pull Request information
36+
id: get_pr_details
37+
uses: actions/github-script@v7
38+
env:
39+
EVENT_NAME: ${{ inputs.event_name }}
40+
PR_NUMBER: ${{ inputs.pr_number }}
41+
MERGE_GROUP_HEAD_REF: ${{ inputs.merge_group_head_ref }}
42+
with:
43+
script: |
44+
const eventName = process.env.EVENT_NAME;
45+
46+
console.log('Trigger event: %s', eventName);
47+
if (eventName === 'merge_group') {
48+
const headRef = process.env.MERGE_GROUP_HEAD_REF;
49+
50+
if (!headRef || typeof headRef !== 'string') {
51+
console.log('❌ MERGE_GROUP_HEAD_REF is missing or invalid. Received:', headRef);
52+
core.setFailed('MERGE_GROUP_HEAD_REF is missing or invalid for merge_group event');
53+
return;
54+
}
55+
56+
const prMatch = headRef.match(/pr-(\d+)-/);
57+
58+
if (!prMatch) {
59+
console.log('❌ Merge group head ref does not match expected format "pr-<number>-...". Received:', headRef);
60+
core.setFailed('Could not extract PR number from merge group head ref: unexpected format');
61+
return;
62+
}
63+
64+
const prNumber = parseInt(prMatch[1], 10);
65+
console.log('📋 Found source PR number: %s', prNumber);
66+
67+
try {
68+
const { data: pullRequest } = await github.rest.pulls.get({
69+
owner: context.repo.owner,
70+
repo: context.repo.repo,
71+
pull_number: prNumber
72+
});
73+
74+
const prLabels = pullRequest.labels.map(l => l.name).join(', ') || 'None';
75+
76+
console.log('\n✅ Source Pull Request Information:');
77+
console.log('- PR Number: #%s', pullRequest.number);
78+
console.log('- PR Title: %s', pullRequest.title);
79+
console.log('- PR Author: %s', pullRequest.user.login);
80+
console.log('- PR State: %s', pullRequest.state);
81+
console.log('- PR Labels: %s', prLabels);
82+
83+
const skipGaudiTests = pullRequest.labels.some(l => l.name === 'skip-gaudi-tests');
84+
85+
const fs = require('fs');
86+
const outputFile = process.env.GITHUB_OUTPUT;
87+
fs.appendFileSync(outputFile, `pr_number=${pullRequest.number}\n`);
88+
fs.appendFileSync(outputFile, `pr_title=${pullRequest.title}\n`);
89+
fs.appendFileSync(outputFile, `pr_labels=${prLabels}\n`);
90+
fs.appendFileSync(outputFile, `pr_base_ref=${pullRequest.base.ref}\n`);
91+
fs.appendFileSync(outputFile, `skip_gaudi_tests=${skipGaudiTests}\n`);
92+
93+
} catch (error) {
94+
console.error('❌ Error fetching PR details:', error.message);
95+
core.setFailed(error.message);
96+
}
97+
} else if (eventName === 'pull_request_target') {
98+
const prNumber = process.env.PR_NUMBER;
99+
100+
try {
101+
const { data: pullRequest } = await github.rest.pulls.get({
102+
owner: context.repo.owner,
103+
repo: context.repo.repo,
104+
pull_number: prNumber
105+
});
106+
107+
const prLabels = pullRequest.labels.map(l => l.name).join(', ') || 'None';
108+
109+
console.log('\n✅ Pull Request Information:');
110+
console.log('- PR Number: #%s', pullRequest.number);
111+
console.log('- PR Title: %s', pullRequest.title);
112+
console.log('- PR Author: %s', pullRequest.user.login);
113+
console.log('- PR State: %s', pullRequest.state);
114+
console.log('- PR Labels: %s', prLabels);
115+
116+
const skipGaudiTests = pullRequest.labels.some(l => l.name === 'skip-gaudi-tests');
117+
118+
const fs = require('fs');
119+
const outputFile = process.env.GITHUB_OUTPUT;
120+
fs.appendFileSync(outputFile, `pr_number=${pullRequest.number}\n`);
121+
fs.appendFileSync(outputFile, `pr_title=${pullRequest.title}\n`);
122+
fs.appendFileSync(outputFile, `pr_labels=${prLabels}\n`);
123+
fs.appendFileSync(outputFile, `pr_base_ref=${pullRequest.base.ref}\n`);
124+
fs.appendFileSync(outputFile, `skip_gaudi_tests=${skipGaudiTests}\n`);
125+
126+
} catch (error) {
127+
console.error('❌ Error fetching PR details:', error.message);
128+
core.setFailed(error.message);
129+
}
130+
} else {
131+
const errorMessage = "Event not supported. Use 'pull_request_target' or 'merge_group'.";
132+
console.error(errorMessage);
133+
core.setFailed(errorMessage);
134+
}
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
#!/bin/bash
2+
3+
# Exit immediately if a command exits with a non-zero status.
4+
# This ensures that if any test fails, the script will stop.
5+
set -e
6+
7+
# --- Configuration ---
8+
# Defines the path to the vllm-gaudi directory.
9+
VLLM_GAUDI_PREFIX=${VLLM_GAUDI_PREFIX:-"vllm-gaudi"}
10+
echo "VLLM_GAUDI_PREFIX: $VLLM_GAUDI_PREFIX"
11+
12+
# Calibration output directory (cleaned up after each test)
13+
CALIBRATION_OUTPUT_DIR="${VLLM_GAUDI_PREFIX}/tests/calibration_tests/tmp-calibration-output"
14+
15+
# Dataset for calibration (using NeelNanda/pile-10k which auto-downloads)
16+
CALIBRATION_DATASET="NeelNanda/pile-10k"
17+
18+
# Minimal batch size and limit for smoke tests (we only verify the procedure works)
19+
BATCH_SIZE=1
20+
LIMIT=1
21+
22+
cleanup_calibration_output() {
23+
if [ -d "${CALIBRATION_OUTPUT_DIR}" ]; then
24+
echo "Cleaning up calibration output directory..."
25+
rm -rf "${CALIBRATION_OUTPUT_DIR}"
26+
fi
27+
}
28+
29+
# Simple smoke calibration test using granite model
30+
run_granite_calibration_test() {
31+
echo "➡️ Testing calibration procedure on ibm-granite/granite-3.3-2b-instruct..."
32+
cleanup_calibration_output
33+
34+
PT_HPU_LAZY_MODE=1 "${VLLM_GAUDI_PREFIX}/calibration/calibrate_model.sh" \
35+
-m ibm-granite/granite-3.3-2b-instruct \
36+
-d "${CALIBRATION_DATASET}" \
37+
-o "${CALIBRATION_OUTPUT_DIR}" \
38+
-b ${BATCH_SIZE} \
39+
-l ${LIMIT} \
40+
-t 1
41+
42+
if [ $? -ne 0 ]; then
43+
echo "Error: Calibration failed for ibm-granite/granite-3.3-2b-instruct" >&2
44+
exit 1
45+
fi
46+
echo "✅ Calibration for ibm-granite/granite-3.3-2b-instruct passed."
47+
cleanup_calibration_output
48+
}
49+
50+
# Simple smoke calibration test using Qwen-2.5 model
51+
run_qwen_calibration_test() {
52+
echo "➡️ Testing calibration procedure on Qwen/Qwen2.5-0.5B-Instruct..."
53+
cleanup_calibration_output
54+
55+
PT_HPU_LAZY_MODE=1 "${VLLM_GAUDI_PREFIX}/calibration/calibrate_model.sh" \
56+
-m Qwen/Qwen2.5-0.5B-Instruct \
57+
-d "${CALIBRATION_DATASET}" \
58+
-o "${CALIBRATION_OUTPUT_DIR}" \
59+
-b ${BATCH_SIZE} \
60+
-l ${LIMIT} \
61+
-t 1
62+
63+
if [ $? -ne 0 ]; then
64+
echo "Error: Calibration failed for Qwen/Qwen2.5-0.5B-Instruct" >&2
65+
exit 1
66+
fi
67+
echo "✅ Calibration for Qwen/Qwen2.5-0.5B-Instruct passed."
68+
cleanup_calibration_output
69+
}
70+
71+
# Simple smoke test for vision language models calibration using Qwen-2.5-VL
72+
# (afierka) Temporarily disabled due to some issues, will re-enable once fixed. [GAUDISW-246468]
73+
# run_qwen_vl_calibration_test() {
74+
# echo "➡️ Testing VLM calibration procedure on Qwen/Qwen2.5-VL-3B-Instruct..."
75+
# cleanup_calibration_output
76+
77+
# PT_HPU_LAZY_MODE=1 "${VLLM_GAUDI_PREFIX}/calibration/vlm-calibration/calibrate_model.sh" \
78+
# -m Qwen/Qwen2.5-VL-3B-Instruct \
79+
# -o "${CALIBRATION_OUTPUT_DIR}" \
80+
# -b ${BATCH_SIZE} \
81+
# -l ${LIMIT} \
82+
# -t 1
83+
84+
# if [ $? -ne 0 ]; then
85+
# echo "Error: VLM Calibration failed for Qwen/Qwen2.5-VL-3B-Instruct" >&2
86+
# exit 1
87+
# fi
88+
# echo "✅ VLM Calibration for Qwen/Qwen2.5-VL-3B-Instruct passed."
89+
# cleanup_calibration_output
90+
# }
91+
92+
# --- Utility Functions ---
93+
94+
# Function to run all tests sequentially
95+
launch_all_tests() {
96+
echo "🚀 Starting all calibration test suites..."
97+
run_granite_calibration_test
98+
run_qwen_calibration_test
99+
# run_qwen_vl_calibration_test # (afierka) Temporarily disabled due to some issues, will re-enable once fixed. [GAUDISW-246468]
100+
echo "🎉 All calibration test suites passed successfully!"
101+
}
102+
103+
# A simple usage function to guide the user
104+
usage() {
105+
echo "Usage: $0 [function_name]"
106+
echo "If no function_name is provided, all tests will be run."
107+
echo ""
108+
echo "Available functions:"
109+
declare -F | awk '{print " - " $3}' | grep --color=never "run_"
110+
}
111+
112+
# --- Script Entry Point ---
113+
114+
# Default to 'launch_all_tests' if no function name is provided as an argument.
115+
FUNCTION_TO_RUN=${1:-launch_all_tests}
116+
117+
# Check if the provided argument corresponds to a declared function in this script.
118+
if declare -f "$FUNCTION_TO_RUN" > /dev/null
119+
then
120+
"$FUNCTION_TO_RUN"
121+
else
122+
echo "❌ Error: Function '${FUNCTION_TO_RUN}' is not defined."
123+
echo ""
124+
usage
125+
exit 1
126+
fi

0 commit comments

Comments
 (0)