From b4bb56dd8906ecee1a4e20de94f861cb2f796d3d Mon Sep 17 00:00:00 2001 From: Michael Kauzmann Date: Mon, 30 Sep 2024 11:06:18 -0600 Subject: [PATCH] updates to aqua grunt tasks to get working, and combine Gruntfiles, https://github.com/phetsims/chipper/issues/1464 --- Gruntfile.js | 21 +++++++++++++--- js/grunt/Gruntfile.js | 20 ---------------- js/grunt/tasks/client-server.ts | 37 ----------------------------- js/grunt/tasks/continuous-server.ts | 12 ++++------ js/grunt/tasks/ct-node-client.ts | 19 +++++++-------- js/grunt/tasks/quick-server.ts | 8 +++---- js/grunt/tasks/test-aqua-grunt.ts | 23 ------------------ 7 files changed, 33 insertions(+), 107 deletions(-) delete mode 100644 js/grunt/Gruntfile.js delete mode 100644 js/grunt/tasks/client-server.ts delete mode 100644 js/grunt/tasks/test-aqua-grunt.ts diff --git a/Gruntfile.js b/Gruntfile.js index 8bcc9b5..566231d 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,5 +1,20 @@ -// Copyright 2017, University of Colorado Boulder +// Copyright 2017-2024, University of Colorado Boulder +/** + * Aqua-specific grunt configuration + * + * @author Jonathan Olson + */ -// use aqua's gruntfile -module.exports = require( './js/grunt/Gruntfile.js' ); \ No newline at end of file +// AQUA wants to opt out of global SIGINT handling so that it can handle it itself. +global.processEventOptOut = true; + +const Gruntfile = require( '../chipper/js/grunt/Gruntfile' ); +const registerTasks = require( '../perennial-alias/js/grunt/util/registerTasks' ); + +// Stream winston logging to the console +module.exports = grunt => { + Gruntfile( grunt ); + + registerTasks( grunt, `${__dirname}/js/grunt/tasks` ); +}; \ No newline at end of file diff --git a/js/grunt/Gruntfile.js b/js/grunt/Gruntfile.js deleted file mode 100644 index 70b5282..0000000 --- a/js/grunt/Gruntfile.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2020-2024, University of Colorado Boulder - -/** - * Aqua-specific grunt configuration - * - * @author Jonathan Olson - */ - -// AQUA wants to opt out of global SIGINT handling so that it can handle it itself. -global.processEventOptOut = true; - -const Gruntfile = require( '../../../chipper/js/grunt/Gruntfile' ); -const registerTasks = require( '../../../perennial-alias/js/grunt/util/registerTasks' ); - -// Stream winston logging to the console -module.exports = grunt => { - Gruntfile( grunt ); - - registerTasks( grunt, __dirname + '/tasks' ); -}; \ No newline at end of file diff --git a/js/grunt/tasks/client-server.ts b/js/grunt/tasks/client-server.ts deleted file mode 100644 index c291460..0000000 --- a/js/grunt/tasks/client-server.ts +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2024, University of Colorado Boulder -/** - * @deprecated - * Launches puppeteer clients to run tests for CT with the following options: - * --puppeteerClients=number : specify how many puppeteer clients to run with, defaults to 16 - * --firefoxClients=number : specify how many playwright firefox clients to run with, defaults to 0 - * --ctID=string : specify id to give to continuous-loop.html, in URL string, defaults to "Sparky". Will have the platform appended like "ID%20Puppeteer" - * --serverURL=string : defaults to "https://sparky.colorado.edu/" - * - * @author Sam Reid (PhET Interactive Simulations) - * @author Michael Kauzmann (PhET Interactive Simulations) - * @deprecated - * TODO: Delete this https://github.com/phetsims/chipper/issues/1463 - */ - -import grunt from '../../../../perennial/js/import-shared/grunt'; -import ContinuousServerClient from '../../server/ContinuousServerClient'; - -// We don't finish! Don't tel l grunt this... -grunt.task.current.async(); - -const options: any = {}; -if ( grunt.option( 'puppeteerClients' ) ) { - options.numberOfPuppeteers = grunt.option( 'puppeteerClients' ); -} -if ( grunt.option( 'firefoxClients' ) ) { - options.numberOfFirefoxes = grunt.option( 'firefoxClients' ); -} -if ( grunt.option( 'ctID' ) ) { - options.ctID = grunt.option( 'ctID' ); -} -if ( grunt.option( 'serverURL' ) ) { - options.serverURL = grunt.option( 'serverURL' ); -} - -const server = new ContinuousServerClient( options ); -server.startMainLoop(); \ No newline at end of file diff --git a/js/grunt/tasks/continuous-server.ts b/js/grunt/tasks/continuous-server.ts index 97bb4d7..58119f1 100644 --- a/js/grunt/tasks/continuous-server.ts +++ b/js/grunt/tasks/continuous-server.ts @@ -11,17 +11,13 @@ */ import assert from 'assert'; -import getOption from '../../../../perennial/js/grunt/tasks/util/getOption'; -import grunt from '../../../../perennial/js/import-shared/grunt'; -import _ from '../../../../perennial/js/import-shared/lodash'; -import winston from '../../../../perennial/js/import-shared/winston'; -import ContinuousServer from '../../server/ContinuousServer'; +import getOption from '../../../../perennial/js/grunt/tasks/util/getOption.js'; +import _ from '../../../../perennial/js/import-shared/lodash.js'; +import winston from '../../../../perennial/js/import-shared/winston.js'; +import ContinuousServer from '../../server/ContinuousServer.js'; winston.default.transports.console.level = 'info'; -// We don't finish! Don't tell grunt this... -grunt.task.current.async(); - assert( getOption( 'localCount' ), 'Please specify --localCount=NUMBER, for specifying the number of local threads running things like grunt tasks' ); const port = getOption( 'port' ) ? Number( getOption( 'port' ) ) : 45366; diff --git a/js/grunt/tasks/ct-node-client.ts b/js/grunt/tasks/ct-node-client.ts index 70b83ae..bc850b7 100644 --- a/js/grunt/tasks/ct-node-client.ts +++ b/js/grunt/tasks/ct-node-client.ts @@ -12,17 +12,14 @@ import assert from 'assert'; import playwright from 'playwright'; -import grunt from '../../../../perennial/js/import-shared/grunt'; +import getOption from '../../../../perennial/js/grunt/tasks/util/getOption'; import winston from '../../../../perennial/js/import-shared/winston'; import runNextTest from '../../node-client/runNextTest'; winston.default.transports.console.level = 'info'; -// We don't finish! Don't tell grunt this... -grunt.task.current.async(); - const options: any = {}; -const browser = grunt.option( 'browser' ); +const browser = getOption( 'browser' ); if ( browser ) { if ( browser === 'firefox' ) { @@ -35,14 +32,14 @@ if ( browser ) { assert( browser === 'puppeteer', 'supported browsers: puppeteer or firefox or webkit' ); } } -if ( grunt.option( 'ctID' ) ) { - options.ctID = grunt.option( 'ctID' ); +if ( getOption( 'ctID' ) ) { + options.ctID = getOption( 'ctID' ); } -if ( grunt.option( 'serverURL' ) ) { - options.serverURL = grunt.option( 'serverURL' ); +if ( getOption( 'serverURL' ) ) { + options.serverURL = getOption( 'serverURL' ); } -if ( grunt.option( 'fileServerURL' ) ) { - options.fileServerURL = grunt.option( 'fileServerURL' ); +if ( getOption( 'fileServerURL' ) ) { + options.fileServerURL = getOption( 'fileServerURL' ); } winston.info( 'Starting node client' ); diff --git a/js/grunt/tasks/quick-server.ts b/js/grunt/tasks/quick-server.ts index 42574fa..45e61ac 100644 --- a/js/grunt/tasks/quick-server.ts +++ b/js/grunt/tasks/quick-server.ts @@ -12,12 +12,8 @@ */ import getOption from '../../../../perennial/js/grunt/tasks/util/getOption'; -import grunt from '../../../../perennial/js/import-shared/grunt'; import QuickServer from '../../server/QuickServer'; -// We don't finish! Don't tell grunt this... -grunt.task.current.async(); - const port = getOption( 'port' ) ? Number( getOption( 'port' ) ) : 45367; const testing = getOption( 'testing' ); @@ -25,4 +21,6 @@ const server = new QuickServer( { isTestMode: testing } ); server.startServer( port ); -server.startMainLoop(); \ No newline at end of file +server.startMainLoop().catch( e => { + throw new Error( `Error in CTQ main loop: ${e}` ); +} ); \ No newline at end of file diff --git a/js/grunt/tasks/test-aqua-grunt.ts b/js/grunt/tasks/test-aqua-grunt.ts deleted file mode 100644 index 2c1ce92..0000000 --- a/js/grunt/tasks/test-aqua-grunt.ts +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2024, University of Colorado Boulder -/** - * Run internal tests for the Gruntfile. Note the output is reported over console.log, so be careful what you output. - * The command invoked is something like this: execSync( `${gruntCommand} test-grunt --brands=a,b,c --lint=false --noTSC` ) - * - * - * @author Sam Reid (PhET Interactive Simulations) - */ - -import getOption from '../../../../perennial/js/grunt/tasks/util/getOption'; - -// grunt test-grunt --brands=a,b,c --lint=false --noTSC -const brands = getOption( 'brands' ); -const lint = getOption( 'lint' ); -const noTSC = getOption( 'noTSC' ); -const omitted = getOption( 'omitted' ); - -console.log( '' ); -console.log( `brands: ${brands}` ); -console.log( `lint: ${lint}` ); -console.log( `noTSC: ${noTSC}` ); -console.log( `omitted: ${omitted}` ); -console.log( '' ); \ No newline at end of file