mirror of
https://github.com/esphome/esphome.git
synced 2026-06-01 01:19:45 +08:00
[ci] Add medium-pr label for PRs with ≤100 lines changed (#14628)
This commit is contained in:
@@ -14,6 +14,7 @@ module.exports = {
|
|||||||
'chained-pr',
|
'chained-pr',
|
||||||
'core',
|
'core',
|
||||||
'small-pr',
|
'small-pr',
|
||||||
|
'medium-pr',
|
||||||
'dashboard',
|
'dashboard',
|
||||||
'github-actions',
|
'github-actions',
|
||||||
'by-code-owner',
|
'by-code-owner',
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ async function detectCoreChanges(changedFiles) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Strategy: PR size detection
|
// Strategy: PR size detection
|
||||||
async function detectPRSize(prFiles, totalAdditions, totalDeletions, totalChanges, isMegaPR, SMALL_PR_THRESHOLD, TOO_BIG_THRESHOLD) {
|
async function detectPRSize(prFiles, totalAdditions, totalDeletions, totalChanges, isMegaPR, SMALL_PR_THRESHOLD, MEDIUM_PR_THRESHOLD, TOO_BIG_THRESHOLD) {
|
||||||
const labels = new Set();
|
const labels = new Set();
|
||||||
|
|
||||||
if (totalChanges <= SMALL_PR_THRESHOLD) {
|
if (totalChanges <= SMALL_PR_THRESHOLD) {
|
||||||
@@ -111,6 +111,11 @@ async function detectPRSize(prFiles, totalAdditions, totalDeletions, totalChange
|
|||||||
return labels;
|
return labels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (totalChanges <= MEDIUM_PR_THRESHOLD) {
|
||||||
|
labels.add('medium-pr');
|
||||||
|
return labels;
|
||||||
|
}
|
||||||
|
|
||||||
const testAdditions = prFiles
|
const testAdditions = prFiles
|
||||||
.filter(file => file.filename.startsWith('tests/'))
|
.filter(file => file.filename.startsWith('tests/'))
|
||||||
.reduce((sum, file) => sum + (file.additions || 0), 0);
|
.reduce((sum, file) => sum + (file.additions || 0), 0);
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ async function fetchApiData() {
|
|||||||
module.exports = async ({ github, context }) => {
|
module.exports = async ({ github, context }) => {
|
||||||
// Environment variables
|
// Environment variables
|
||||||
const SMALL_PR_THRESHOLD = parseInt(process.env.SMALL_PR_THRESHOLD);
|
const SMALL_PR_THRESHOLD = parseInt(process.env.SMALL_PR_THRESHOLD);
|
||||||
|
const MEDIUM_PR_THRESHOLD = parseInt(process.env.MEDIUM_PR_THRESHOLD);
|
||||||
const MAX_LABELS = parseInt(process.env.MAX_LABELS);
|
const MAX_LABELS = parseInt(process.env.MAX_LABELS);
|
||||||
const TOO_BIG_THRESHOLD = parseInt(process.env.TOO_BIG_THRESHOLD);
|
const TOO_BIG_THRESHOLD = parseInt(process.env.TOO_BIG_THRESHOLD);
|
||||||
const COMPONENT_LABEL_THRESHOLD = parseInt(process.env.COMPONENT_LABEL_THRESHOLD);
|
const COMPONENT_LABEL_THRESHOLD = parseInt(process.env.COMPONENT_LABEL_THRESHOLD);
|
||||||
@@ -120,7 +121,7 @@ module.exports = async ({ github, context }) => {
|
|||||||
detectNewComponents(prFiles),
|
detectNewComponents(prFiles),
|
||||||
detectNewPlatforms(prFiles, apiData),
|
detectNewPlatforms(prFiles, apiData),
|
||||||
detectCoreChanges(changedFiles),
|
detectCoreChanges(changedFiles),
|
||||||
detectPRSize(prFiles, totalAdditions, totalDeletions, totalChanges, isMegaPR, SMALL_PR_THRESHOLD, TOO_BIG_THRESHOLD),
|
detectPRSize(prFiles, totalAdditions, totalDeletions, totalChanges, isMegaPR, SMALL_PR_THRESHOLD, MEDIUM_PR_THRESHOLD, TOO_BIG_THRESHOLD),
|
||||||
detectDashboardChanges(changedFiles),
|
detectDashboardChanges(changedFiles),
|
||||||
detectGitHubActionsChanges(changedFiles),
|
detectGitHubActionsChanges(changedFiles),
|
||||||
detectCodeOwner(github, context, changedFiles),
|
detectCodeOwner(github, context, changedFiles),
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ permissions:
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
SMALL_PR_THRESHOLD: 30
|
SMALL_PR_THRESHOLD: 30
|
||||||
|
MEDIUM_PR_THRESHOLD: 100
|
||||||
MAX_LABELS: 15
|
MAX_LABELS: 15
|
||||||
TOO_BIG_THRESHOLD: 1000
|
TOO_BIG_THRESHOLD: 1000
|
||||||
COMPONENT_LABEL_THRESHOLD: 10
|
COMPONENT_LABEL_THRESHOLD: 10
|
||||||
|
|||||||
Reference in New Issue
Block a user