281 lines
11 KiB
YAML
281 lines
11 KiB
YAML
name: Slash Commands
|
|
|
|
on:
|
|
issue_comment:
|
|
types: [created]
|
|
|
|
permissions:
|
|
contents: read
|
|
pull-requests: write
|
|
statuses: write
|
|
|
|
jobs:
|
|
handle-merge:
|
|
if: >-
|
|
github.event.issue.pull_request != null
|
|
&& startsWith(github.event.comment.body, '/merge')
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check write permission
|
|
id: perm
|
|
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
|
with:
|
|
script: |
|
|
const { data: perm } = await github.rest.repos.getCollaboratorPermissionLevel({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
username: context.payload.comment.user.login,
|
|
});
|
|
const hasWrite = ['admin', 'write'].includes(perm.permission);
|
|
if (!hasWrite) {
|
|
core.setFailed(`User ${context.payload.comment.user.login} lacks write permission (has: ${perm.permission}).`);
|
|
}
|
|
core.setOutput('has_write', String(hasWrite));
|
|
|
|
- name: Add ready label and react
|
|
id: label
|
|
if: steps.perm.outputs.has_write == 'true'
|
|
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
|
with:
|
|
script: |
|
|
const owner = context.repo.owner;
|
|
const repo = context.repo.repo;
|
|
const prNumber = context.payload.issue.number;
|
|
try { await github.rest.issues.removeLabel({ owner, repo, issue_number: prNumber, name: 'ready' }); } catch {}
|
|
await github.rest.issues.addLabels({ owner, repo, issue_number: prNumber, labels: ['ready'] });
|
|
await github.rest.reactions.createForIssueComment({
|
|
owner, repo,
|
|
comment_id: context.payload.comment.id,
|
|
content: 'rocket',
|
|
});
|
|
const { data: pr } = await github.rest.pulls.get({ owner, repo, pull_number: prNumber });
|
|
core.setOutput('pr_sha', pr.head.sha);
|
|
core.setOutput('pr_branch', pr.head.ref);
|
|
core.setOutput('pr_number', String(prNumber));
|
|
core.setOutput('pr_title', pr.title);
|
|
|
|
- name: Trigger Full Suite
|
|
if: steps.perm.outputs.has_write == 'true'
|
|
env:
|
|
BUILDKITE_API_TOKEN: ${{ secrets.BUILDKITE_API_TOKEN }}
|
|
PR_SHA: ${{ steps.label.outputs.pr_sha }}
|
|
PR_BRANCH: ${{ steps.label.outputs.pr_branch }}
|
|
PR_NUMBER: ${{ steps.label.outputs.pr_number }}
|
|
PR_TITLE: ${{ steps.label.outputs.pr_title }}
|
|
BK_ORG: ${{ vars.BUILDKITE_ORG_SLUG }}
|
|
BK_PIPELINE: ${{ vars.BUILDKITE_PIPELINE_SLUG }}
|
|
run: |
|
|
curl -sS --fail-with-body -X POST \
|
|
"https://api.buildkite.com/v2/organizations/${BK_ORG}/pipelines/${BK_PIPELINE}/builds" \
|
|
-H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
--data-raw "$(jq -n \
|
|
--arg commit "$PR_SHA" \
|
|
--arg branch "$PR_BRANCH" \
|
|
--arg message "Full Suite for PR #${PR_NUMBER} (via /merge)" \
|
|
--arg pr_title "$PR_TITLE" \
|
|
--argjson pr_id "$PR_NUMBER" \
|
|
'{
|
|
commit: $commit,
|
|
branch: $branch,
|
|
message: $message,
|
|
ignore_pipeline_branch_filters: true,
|
|
pull_request_id: $pr_id,
|
|
pull_request_base_branch: "main",
|
|
env: {
|
|
TEST_SCOPE: "full",
|
|
FULL_SUITE: "true",
|
|
PR_NUMBER: ($pr_id | tostring),
|
|
PR_TITLE: $pr_title
|
|
}
|
|
}')"
|
|
|
|
parse-command:
|
|
if: >-
|
|
github.event.issue.pull_request != null
|
|
&& startsWith(github.event.comment.body, '/test')
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
test_type: ${{ steps.parse.outputs.test_type }}
|
|
test_scope: ${{ steps.parse.outputs.test_scope }}
|
|
full_suite: ${{ steps.parse.outputs.full_suite }}
|
|
pr_sha: ${{ steps.pr.outputs.sha }}
|
|
pr_branch: ${{ steps.pr.outputs.branch }}
|
|
has_write: ${{ steps.perm.outputs.has_write }}
|
|
steps:
|
|
- name: Check write permission
|
|
id: perm
|
|
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
|
with:
|
|
script: |
|
|
const { data: perm } = await github.rest.repos.getCollaboratorPermissionLevel({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
username: context.payload.comment.user.login,
|
|
});
|
|
const hasWrite = ['admin', 'write'].includes(perm.permission);
|
|
core.setOutput('has_write', String(hasWrite));
|
|
if (!hasWrite) {
|
|
core.info(`User ${context.payload.comment.user.login} lacks write permission — ignoring.`);
|
|
}
|
|
|
|
- name: Parse /test command
|
|
id: parse
|
|
if: steps.perm.outputs.has_write == 'true'
|
|
shell: bash
|
|
env:
|
|
COMMENT: ${{ github.event.comment.body }}
|
|
run: |
|
|
set -euo pipefail
|
|
TEST_NAME=$(echo "$COMMENT" | grep -oP '(?<=/test\s)\S+' | head -1 || true)
|
|
|
|
VALID="encoder vae transformer kernel unit dreamverse ssim golden-gate training lora-inference lora-training lora-extraction distillation self-forcing vsa vmoba performance api train-framework eval full fastcheck pre-commit"
|
|
if [ -z "$TEST_NAME" ] || ! echo "$VALID" | grep -qw "$TEST_NAME"; then
|
|
echo "Unknown test: '$TEST_NAME'. Valid: $VALID"
|
|
exit 1
|
|
fi
|
|
|
|
declare -A MAP=(
|
|
[encoder]=encoder [vae]=vae [transformer]=transformer
|
|
[kernel]=kernel_tests [unit]=unit_test [dreamverse]=dreamverse_app
|
|
[ssim]=ssim [golden-gate]=golden_gate [training]=training
|
|
[lora-inference]=inference_lora [lora-training]=training_lora
|
|
[lora-extraction]=lora_extraction
|
|
[distillation]=distillation_dmd [self-forcing]=self_forcing
|
|
[vsa]=training_vsa [vmoba]=inference_vmoba
|
|
[performance]=performance [api]=api_server
|
|
[train-framework]=train_framework [eval]=eval
|
|
)
|
|
|
|
if [ "$TEST_NAME" = "full" ]; then
|
|
{
|
|
echo "test_type=all"
|
|
echo "test_scope=full"
|
|
echo "full_suite=true"
|
|
} >> "$GITHUB_OUTPUT"
|
|
elif [ "$TEST_NAME" = "fastcheck" ]; then
|
|
{
|
|
echo "test_type=fastcheck"
|
|
echo "test_scope=fastcheck"
|
|
echo "full_suite=false"
|
|
} >> "$GITHUB_OUTPUT"
|
|
elif [ "$TEST_NAME" = "pre-commit" ]; then
|
|
{
|
|
echo "test_type="
|
|
echo "test_scope=precommit"
|
|
echo "full_suite=false"
|
|
} >> "$GITHUB_OUTPUT"
|
|
else
|
|
{
|
|
echo "test_type=${MAP[$TEST_NAME]}"
|
|
echo "test_scope=direct"
|
|
echo "full_suite=false"
|
|
} >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
- name: Get PR details
|
|
id: pr
|
|
if: steps.perm.outputs.has_write == 'true'
|
|
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
|
with:
|
|
script: |
|
|
const { data: pr } = await github.rest.pulls.get({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
pull_number: context.payload.issue.number,
|
|
});
|
|
core.setOutput('sha', pr.head.sha);
|
|
core.setOutput('branch', pr.head.ref);
|
|
|
|
- name: React to comment
|
|
if: steps.perm.outputs.has_write == 'true'
|
|
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
|
with:
|
|
script: |
|
|
await github.rest.reactions.createForIssueComment({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
comment_id: context.payload.comment.id,
|
|
content: 'rocket',
|
|
});
|
|
|
|
pre-commit:
|
|
needs: parse-command
|
|
if: >-
|
|
needs.parse-command.outputs.has_write == 'true'
|
|
&& needs.parse-command.outputs.test_scope == 'precommit'
|
|
uses: ./.github/workflows/ci-precommit.yml
|
|
with:
|
|
ref: refs/pull/${{ github.event.issue.number }}/merge
|
|
|
|
post-precommit-status:
|
|
needs: [parse-command, pre-commit]
|
|
if: always() && needs.parse-command.outputs.test_scope == 'precommit'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
|
env:
|
|
PR_SHA: ${{ needs.parse-command.outputs.pr_sha }}
|
|
RESULT: ${{ needs.pre-commit.result }}
|
|
with:
|
|
script: |
|
|
const state = process.env.RESULT === 'success' ? 'success' : 'failure';
|
|
await github.rest.repos.createCommitStatus({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
sha: process.env.PR_SHA,
|
|
state,
|
|
context: 'pre-commit',
|
|
description: `Triggered via /test pre-commit (${state})`,
|
|
});
|
|
|
|
trigger-buildkite:
|
|
needs: parse-command
|
|
if: >-
|
|
needs.parse-command.outputs.has_write == 'true'
|
|
&& needs.parse-command.outputs.test_type != ''
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Trigger Buildkite
|
|
env:
|
|
BUILDKITE_API_TOKEN: ${{ secrets.BUILDKITE_API_TOKEN }}
|
|
PR_SHA: ${{ needs.parse-command.outputs.pr_sha }}
|
|
PR_BRANCH: ${{ needs.parse-command.outputs.pr_branch }}
|
|
PR_NUMBER: ${{ github.event.issue.number }}
|
|
TEST_SCOPE: ${{ needs.parse-command.outputs.test_scope }}
|
|
FULL_SUITE: ${{ needs.parse-command.outputs.full_suite }}
|
|
TEST_TYPE: ${{ needs.parse-command.outputs.test_type }}
|
|
PR_TITLE: ${{ github.event.issue.title }}
|
|
BK_ORG: ${{ vars.BUILDKITE_ORG_SLUG }}
|
|
BK_PIPELINE: ${{ vars.BUILDKITE_PIPELINE_SLUG }}
|
|
run: |
|
|
curl -sS --fail-with-body -X POST \
|
|
"https://api.buildkite.com/v2/organizations/${BK_ORG}/pipelines/${BK_PIPELINE}/builds" \
|
|
-H "Authorization: Bearer $BUILDKITE_API_TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
--data-raw "$(jq -n \
|
|
--arg commit "$PR_SHA" \
|
|
--arg branch "$PR_BRANCH" \
|
|
--arg message "/test ${TEST_TYPE} on PR #${PR_NUMBER}" \
|
|
--argjson pr_id "$PR_NUMBER" \
|
|
--arg test_scope "$TEST_SCOPE" \
|
|
--arg full_suite "$FULL_SUITE" \
|
|
--arg test_type "$TEST_TYPE" \
|
|
--arg pr_number "$PR_NUMBER" \
|
|
--arg pr_title "$PR_TITLE" \
|
|
'{
|
|
commit: $commit,
|
|
branch: $branch,
|
|
message: $message,
|
|
ignore_pipeline_branch_filters: true,
|
|
pull_request_id: $pr_id,
|
|
pull_request_base_branch: "main",
|
|
env: {
|
|
TEST_SCOPE: $test_scope,
|
|
FULL_SUITE: $full_suite,
|
|
TEST_TYPE: $test_type,
|
|
PR_NUMBER: $pr_number,
|
|
PR_TITLE: $pr_title
|
|
}
|
|
}')"
|