mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	[CI] Base `too-big` label on new additions only (#10307)
				
					
				
			This commit is contained in:
		
							
								
								
									
										28
									
								
								.github/workflows/auto-label-pr.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										28
									
								
								.github/workflows/auto-label-pr.yml
									
									
									
									
										vendored
									
									
								
							| @@ -105,7 +105,9 @@ jobs: | |||||||
|  |  | ||||||
|             // Calculate data from PR files |             // Calculate data from PR files | ||||||
|             const changedFiles = prFiles.map(file => file.filename); |             const changedFiles = prFiles.map(file => file.filename); | ||||||
|             const totalChanges = prFiles.reduce((sum, file) => sum + (file.additions || 0) + (file.deletions || 0), 0); |             const totalAdditions = prFiles.reduce((sum, file) => sum + (file.additions || 0), 0); | ||||||
|  |             const totalDeletions = prFiles.reduce((sum, file) => sum + (file.deletions || 0), 0); | ||||||
|  |             const totalChanges = totalAdditions + totalDeletions; | ||||||
|  |  | ||||||
|             console.log('Current labels:', currentLabels.join(', ')); |             console.log('Current labels:', currentLabels.join(', ')); | ||||||
|             console.log('Changed files:', changedFiles.length); |             console.log('Changed files:', changedFiles.length); | ||||||
| @@ -231,16 +233,21 @@ jobs: | |||||||
|             // Strategy: PR size detection |             // Strategy: PR size detection | ||||||
|             async function detectPRSize() { |             async function detectPRSize() { | ||||||
|               const labels = new Set(); |               const labels = new Set(); | ||||||
|               const testChanges = prFiles |  | ||||||
|                 .filter(file => file.filename.startsWith('tests/')) |  | ||||||
|                 .reduce((sum, file) => sum + (file.additions || 0) + (file.deletions || 0), 0); |  | ||||||
|  |  | ||||||
|               const nonTestChanges = totalChanges - testChanges; |  | ||||||
|  |  | ||||||
|               if (totalChanges <= SMALL_PR_THRESHOLD) { |               if (totalChanges <= SMALL_PR_THRESHOLD) { | ||||||
|                 labels.add('small-pr'); |                 labels.add('small-pr'); | ||||||
|  |                 return labels; | ||||||
|               } |               } | ||||||
|  |  | ||||||
|  |               const testAdditions = prFiles | ||||||
|  |                 .filter(file => file.filename.startsWith('tests/')) | ||||||
|  |                 .reduce((sum, file) => sum + (file.additions || 0), 0); | ||||||
|  |               const testDeletions = prFiles | ||||||
|  |                 .filter(file => file.filename.startsWith('tests/')) | ||||||
|  |                 .reduce((sum, file) => sum + (file.deletions || 0), 0); | ||||||
|  |  | ||||||
|  |               const nonTestChanges = (totalAdditions - testAdditions) - (totalDeletions - testDeletions); | ||||||
|  |  | ||||||
|               // Don't add too-big if mega-pr label is already present |               // Don't add too-big if mega-pr label is already present | ||||||
|               if (nonTestChanges > TOO_BIG_THRESHOLD && !isMegaPR) { |               if (nonTestChanges > TOO_BIG_THRESHOLD && !isMegaPR) { | ||||||
|                 labels.add('too-big'); |                 labels.add('too-big'); | ||||||
| @@ -412,10 +419,13 @@ jobs: | |||||||
|  |  | ||||||
|               // Too big message |               // Too big message | ||||||
|               if (finalLabels.includes('too-big')) { |               if (finalLabels.includes('too-big')) { | ||||||
|                 const testChanges = prFiles |                 const testAdditions = prFiles | ||||||
|                   .filter(file => file.filename.startsWith('tests/')) |                   .filter(file => file.filename.startsWith('tests/')) | ||||||
|                   .reduce((sum, file) => sum + (file.additions || 0) + (file.deletions || 0), 0); |                   .reduce((sum, file) => sum + (file.additions || 0), 0); | ||||||
|                 const nonTestChanges = totalChanges - testChanges; |                 const testDeletions = prFiles | ||||||
|  |                   .filter(file => file.filename.startsWith('tests/')) | ||||||
|  |                   .reduce((sum, file) => sum + (file.deletions || 0), 0); | ||||||
|  |                 const nonTestChanges = (totalAdditions - testAdditions) - (totalDeletions - testDeletions); | ||||||
|  |  | ||||||
|                 const tooManyLabels = finalLabels.length > MAX_LABELS; |                 const tooManyLabels = finalLabels.length > MAX_LABELS; | ||||||
|                 const tooManyChanges = nonTestChanges > TOO_BIG_THRESHOLD; |                 const tooManyChanges = nonTestChanges > TOO_BIG_THRESHOLD; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user