gh: remove ai autolabel test (#7817)

This commit is contained in:
CanbiZ 2025-09-23 09:47:05 +02:00 committed by GitHub
parent 3266962630
commit 3a668870b7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 0 additions and 154 deletions

38
.github/label-priority.json generated vendored
View File

@ -1,38 +0,0 @@
{
"priorities": {
"refactor": 3,
"feature": 2,
"bugfix": 1,
"new script": 3,
"update script": 2,
"delete script": 2,
"json": 3,
"website": 2,
"maintenance": 1,
"documentation": 1,
"core": 2,
"api": 2,
"addon": 2,
"pve-tool": 2,
"vm": 2,
"github": 1
},
"conflicts": {
"bugfix": ["refactor"],
"website": ["json"],
"update script": ["new script", "delete script"],
"new script": ["update script", "delete script"],
"delete script": ["new script", "update script"]
},
"rules": {
"always_combine": [
"maintenance",
"core",
"api",
"addon",
"pve-tool",
"vm",
"github"
]
}
}

116
.github/workflows/autolabeler.yml generated vendored
View File

@ -112,119 +112,3 @@ jobs:
labels: Array.from(labelsToAdd),
});
}
ai-check:
needs: autolabeler
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Load priority config
run: |
echo "PRIORITY_JSON=$(jq -c . .github/label-priority.json)" >> $GITHUB_ENV
- name: Fetch PR metadata
id: pr
uses: actions/github-script@v7
with:
script: |
const pr = context.payload.pull_request;
const files = await github.rest.pulls.listFiles({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr.number
});
const prData = {
title: pr.title || "",
body: pr.body || "",
files: files.data.map(f => f.filename)
};
require('fs').writeFileSync(process.env.GITHUB_ENV, `PR_DATA=${JSON.stringify(prData)}\n`, {flag: 'a'});
- name: AI Label Review
id: ai
uses: actions/github-script@v7
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
with:
script: |
const prData = JSON.parse(process.env.PR_DATA);
const prompt = `
You are a GitHub labeling bot.
Task:
- Analyze PR title, body, and file list.
- For each possible label, return a confidence score (01).
- If both bugfix and refactor apply, prefer refactor.
- Output JSON: {"labels":[{"name":"bugfix","score":0.9},{"name":"refactor","score":0.6}]}
Valid labels: [new script, update script, delete script, bugfix, feature, maintenance, refactor, website, json, api, core, github, addon, pve-tool, vm].
PR data: ${JSON.stringify(prData)}
`;
const response = await fetch("https://api.openai.com/v1/chat/completions", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer " + process.env.OPENAI_API_KEY,
},
body: JSON.stringify({
model: "gpt-4.1-mini",
messages: [{ role: "user", content: prompt }],
temperature: 0
})
});
const data = await response.json();
const labels = JSON.parse(data.choices[0].message.content).labels;
core.setOutput("labels", JSON.stringify(labels));
- name: Apply AI Labels
uses: actions/github-script@v7
with:
script: |
const raw = JSON.parse('${{ steps.ai.outputs.labels }}');
const prNumber = context.payload.pull_request.number;
const config = JSON.parse(process.env.PRIORITY_JSON);
let toApply = [];
let toSuggest = [];
raw.forEach(l => {
if (l.score >= 0.8) {
const conflicts = config.conflicts[l.name] || [];
const hasStrongerConflict = conflicts.some(c =>
raw.some(x =>
x.name === c &&
x.score >= 0.6 &&
(config.priorities[c] || 0) >= (config.priorities[l.name] || 0)
)
);
if (!hasStrongerConflict) {
toApply.push(l.name);
}
} else if (l.score >= 0.5) {
toSuggest.push(`${l.name} (${Math.round(l.score*100)}%)`);
}
});
if (toApply.length > 0) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
labels: toApply
});
}
if (toSuggest.length > 0) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: `🤖 AI suggests these possible labels (uncertain): ${toSuggest.join(", ")}`
});
}