77 * This script determines which benchmark components need to run based on changed files.
88 */
99
10- const process = require ( ' process' ) ;
11- const { getChangedFiles } = require ( ' ./get-changed-files.js' ) ;
12- const { getCrateDependencies } = require ( ' ./utils.js' ) ;
10+ const process = require ( " process" ) ;
11+ const { getChangedFiles } = require ( " ./get-changed-files.js" ) ;
12+ const { getCrateDependencies } = require ( " ./utils.js" ) ;
1313
1414// All available benchmark components
15- const ALL_COMPONENTS = [ 'lexer' , 'parser' , 'transformer' , 'semantic' , 'minifier' , 'codegen' , 'formatter' , 'linter' ] ;
15+ const ALL_COMPONENTS = [
16+ "lexer" ,
17+ "parser" ,
18+ "transformer" ,
19+ "semantic" ,
20+ "minifier" ,
21+ "codegen" ,
22+ "formatter" ,
23+ "linter" ,
24+ ] ;
1625
1726// Files that when changed affect all benchmarks
1827const GLOBAL_FILES = [
19- ' Cargo.lock' ,
20- ' rust-toolchain.toml' ,
21- ' .github/workflows/benchmark.yml' ,
22- ' .github/scripts/generate-benchmark-matrix.js' ,
28+ " Cargo.lock" ,
29+ " rust-toolchain.toml" ,
30+ " .github/workflows/benchmark.yml" ,
31+ " .github/scripts/generate-benchmark-matrix.js" ,
2332] ;
2433
2534/**
@@ -48,10 +57,10 @@ function checkGlobalChanges(changedFiles) {
4857 * @returns {string } Feature name
4958 */
5059function getFeatureForComponent ( component ) {
51- if ( component === ' linter' ) {
52- return ' linter' ;
60+ if ( component === " linter" ) {
61+ return " linter" ;
5362 }
54- return ' compiler' ;
63+ return " compiler" ;
5564}
5665
5766/**
@@ -61,7 +70,7 @@ function getFeatureForComponent(component) {
6170 */
6271function getComponentDependencies ( component ) {
6372 const feature = getFeatureForComponent ( component ) ;
64- const deps = getCrateDependencies ( ' oxc_benchmark' , {
73+ const deps = getCrateDependencies ( " oxc_benchmark" , {
6574 features : feature ,
6675 noDefaultFeatures : true ,
6776 } ) ;
@@ -86,7 +95,7 @@ function isComponentAffected(component, changedFiles) {
8695
8796 // Get component dependencies
8897 const dependencies = getComponentDependencies ( component ) ;
89- console . error ( `Component ${ component } dependencies: ${ dependencies . join ( ', ' ) } ` ) ;
98+ console . error ( `Component ${ component } dependencies: ${ dependencies . join ( ", " ) } ` ) ;
9099
91100 // Check if any dependency files changed
92101 for ( const dep of dependencies ) {
@@ -98,7 +107,11 @@ function isComponentAffected(component, changedFiles) {
98107 }
99108
100109 // Check benchmark and common task files
101- if ( changedFiles . some ( ( file ) => file . startsWith ( 'tasks/benchmark/' ) || file . startsWith ( 'tasks/common/' ) ) ) {
110+ if (
111+ changedFiles . some (
112+ ( file ) => file . startsWith ( "tasks/benchmark/" ) || file . startsWith ( "tasks/common/" ) ,
113+ )
114+ ) {
102115 console . error ( ` Component ${ component } affected by benchmark/common file changes` ) ;
103116 return true ;
104117 }
@@ -123,7 +136,7 @@ async function determineAffectedComponents() {
123136
124137 // Check for global changes
125138 if ( checkGlobalChanges ( changedFiles ) ) {
126- console . error ( ' Global changes detected - will run all benchmarks' ) ;
139+ console . error ( " Global changes detected - will run all benchmarks" ) ;
127140 return ALL_COMPONENTS . map ( ( component ) => ( {
128141 component,
129142 feature : getFeatureForComponent ( component ) ,
@@ -144,9 +157,11 @@ async function determineAffectedComponents() {
144157 }
145158
146159 if ( affectedComponents . length === 0 ) {
147- console . error ( ' \nNo components were affected by the changes' ) ;
160+ console . error ( " \nNo components were affected by the changes" ) ;
148161 } else {
149- console . error ( `\nAffected components: ${ affectedComponents . map ( ( obj ) => obj . component ) . join ( ', ' ) } ` ) ;
162+ console . error (
163+ `\nAffected components: ${ affectedComponents . map ( ( obj ) => obj . component ) . join ( ", " ) } ` ,
164+ ) ;
150165 }
151166
152167 return affectedComponents ;
@@ -165,15 +180,17 @@ async function main() {
165180
166181 // Set GitHub Actions notice
167182 if ( affectedComponents . length === 0 ) {
168- console . error ( '::notice title=No benchmarks to run::No components were affected by the changes' ) ;
183+ console . error (
184+ "::notice title=No benchmarks to run::No components were affected by the changes" ,
185+ ) ;
169186 } else {
170- const componentNames = affectedComponents . map ( ( obj ) => obj . component ) . join ( ', ' ) ;
187+ const componentNames = affectedComponents . map ( ( obj ) => obj . component ) . join ( ", " ) ;
171188 console . error ( `::notice title=Running benchmarks::Affected components: ${ componentNames } ` ) ;
172189 }
173190
174191 process . exit ( 0 ) ;
175192 } catch ( error ) {
176- console . error ( ' Error generating benchmark matrix:' , error ) ;
193+ console . error ( " Error generating benchmark matrix:" , error ) ;
177194 // On error, run all benchmarks as a fallback
178195 const fallbackMatrix = ALL_COMPONENTS . map ( ( component ) => ( {
179196 component,
0 commit comments