Skip to content

Commit

Permalink
Standardize test scripts in projects within Rush workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon Siegel committed May 8, 2019
1 parent 10bd28a commit 0fc1a95
Show file tree
Hide file tree
Showing 20 changed files with 282 additions and 320 deletions.
27 changes: 19 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,29 @@ By default, Rush only displays things written to `STDERR`. If you want to see th

#### Other NPM scripts

Most package scripts are exposed as Rush commands. Use `rush <scriptname>` in place of `npm run <scriptname>` to run the package script in all projects. Navigate to a project's directory and substitute `rushx` for `rush` to run the script for just the current project.
Most package scripts are exposed as Rush commands. Use `rush <scriptname>` in place of `npm run <scriptname>` to run the package script in all projects. Navigate to a project's directory and substitute `rushx` for `rush` to run the script for just the current project. Run `rush <scriptname> --help` for more information about each script.

All projects have at least the following scripts:
- `test`: Run tests (specifics vary by project)
- `audit`: Run `npm audit` on the project (with some workarounds for Rush)
- `build`: Build the project's production artifacts (Node and browser bundles)
- `build:test`: Build the project's test artifacts only
- `check-format`: Show Prettier formatting issues within the project
- `clean`: Remove generated and temporary files
- `lint`: Run tslint / eslint
- `format`: Run Prettier and reformat files to match the formatting guidelines
- `check-format`: Run Prettier display format issues without making any changes
- `pack`: Run `npm pack`
- `format`: Reformat project files with Prettier
- `integration-test:browser`: Execute browser integration tests
- `integration-test:node`: Execute Node integration tests
- `integration-test`: Execute all integration tests
- `lint:fix`: Fix ESLint issues within the project
- `lint`: Show ESLint issues within the project
- `pack`: Run `npm pack` on the project
- `test:browser`: Execute browser dev tests
- `test:node`: Execute Node dev tests
- `test`: Execute all dev tests
- `unit-test:browser`: Execute browser unit tests
- `unit-test:node`: Execute Node unit tests
- `unit-test`: Execute all unit tests

Projects may optionally have the following scripts:
- `unit-node`: Run NodeJS tests against the Node package
- `unit-browser`: Run browser tests against the browser bundle
- `extract-api`: Run API Extractor to show API issues and generate API reports

#### Getting back to a clean state
Expand Down
291 changes: 89 additions & 202 deletions common/config/rush/command-line.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,134 +11,66 @@
* "rush my-global-command --help".
*/
"commands": [
// {
// /**
// * (Required) Determines the type of custom command.
// * Rush's "bulk" commands are invoked separately for each project. Rush will look in
// * each project's package.json file for a "scripts" entry whose name matches the
// * command name. By default, the command will run for every project in the repo,
// * according to the dependency graph (similar to how "rush build" works).
// * The set of projects can be restricted e.g. using the "--to" or "--from" parameters.
// */
// "commandKind": "bulk",
//
// /**
// * (Required) The name that will be typed as part of the command line. This is also the name
// * of the "scripts" hook in the project's package.json file.
// * The name should be comprised of lower case words separated by hyphens.
// */
// "name": "my-bulk-command",
//
// /**
// * (Required) A short summary of the custom command to be shown when printing command line
// * help, e.g. "rush --help".
// */
// "summary": "Example bulk custom command",
//
// /**
// * A detailed description of the command to be shown when printing command line
// * help (e.g. "rush --help my-command").
// * If omitted, the "summary" text will be shown instead.
// *
// * Whenever you introduce commands/parameters, taking a little time to write meaningful
// * documentation can make a big difference for the developer experience in your repo.
// */
// "description": "This is an example custom command that runs separately for each project",
//
// /**
// * By default, Rush operations acquire a lock file which prevents multiple commands from executing simultaneously
// * in the same repo folder. (For example, it would be a mistake to run "rush install" and "rush build" at the
// * same time.) If your command makes sense to run concurrently with other operations,
// * set "safeForSimultaneousRushProcesses" to true to disable this protection.
// *
// * In particular, this is needed for custom scripts that invoke other Rush commands.
// */
// "safeForSimultaneousRushProcesses": false,
//
// /**
// * (Required) If true, then this command is safe to be run in parallel, i.e. executed
// * simultaneously for multiple projects. Similar to "rush build", regardless of parallelism
// * projects will not start processing until their dependencies have completed processing.
// */
// "enableParallelism": false,
//
// /**
// * Normally Rush requires that each project's package.json has a "scripts" entry matching
// * the custom command name. To disable this check, set "ignoreMissingScript" to true;
// * projects with a missing definition will be skipped.
// */
// "ignoreMissingScript": false
// },
//
// {
// /**
// * (Required) Determines the type of custom command.
// * Rush's "global" commands are invoked once for the entire repo.
// */
// "commandKind": "global",
//
// "name": "my-global-command",
// "summary": "Example global custom command",
// "description": "This is an example custom command that runs once for the entire repo",
//
// "safeForSimultaneousRushProcesses": false,
//
// /**
// * A script that will be invoked using the OS shell. The working directory will be the folder
// * that contains rush.json. If custom parameters are associated with this command, their
// * values will be appended to the end of this string.
// */
// "shellCommand": "node common/scripts/my-global-command.js"
// }
// Required Scripts
{
"commandKind": "bulk",
"name": "test",
"summary": "Test projects",
"name": "audit",
"summary": "Audit projects",
"enableParallelism": true
},
{
"commandKind": "bulk",
"name": "unit-node",
"summary": "Run live tests for Node packages",
"enableParallelism": true,
"ignoreMissingScript": true
"name": "build:test",
"summary": "Build the test targets only in projects",
"enableParallelism": true
},
{
"commandKind": "bulk",
"name": "unit-browser",
"summary": "Run live tests for browser bundles",
"enableParallelism": true,
"ignoreMissingScript": true
"name": "check-format",
"summary": "Show formatting issues within projects",
"enableParallelism": true
},
{
"commandKind": "bulk",
"name": "extract-api",
"summary": "Run API Extractor on projects",
"enableParallelism": true,
"ignoreMissingScript": true
"name": "clean",
"summary": "Clean projects",
"enableParallelism": true
},
{
"commandKind": "bulk",
"name": "check-format",
"summary": "Show formatting issues within projects",
"name": "format",
"summary": "Reformat projects",
"enableParallelism": true
},
{
"commandKind": "bulk",
"name": "format",
"summary": "Reformat projects",
"name": "integration-test:browser",
"summary": "Execute browser integration tests defined in projects",
"enableParallelism": true
},
{
"commandKind": "bulk",
"name": "lint",
"summary": "Lint projects",
"name": "integration-test:node",
"summary": "Execute Node integration tests defined in projects",
"enableParallelism": true
},
{
"commandKind": "bulk",
"name": "clean",
"summary": "Clean projects",
"name": "integration-test",
"summary": "Execute integration tests defined in projects",
"description": "Execute tests which require an actual service instance (live Azure, emulator, etc). Integration tests typically require service endpoints to be specified via environment variables in order to run.",
"enableParallelism": true
},
{
"commandKind": "bulk",
"name": "lint:fix",
"summary": "Fix linting errors for projects",
"enableParallelism": true
},
{
"commandKind": "bulk",
"name": "lint",
"summary": "Lint projects",
"enableParallelism": true
},
{
Expand All @@ -149,22 +81,58 @@
},
{
"commandKind": "bulk",
"name": "audit",
"summary": "Audit projects",
"name": "test:browser",
"summary": "Execute browser dev tests defined in projects",
"enableParallelism": true
},
{
"commandKind": "global",
"name": "sync-versions",
"summary": "Sync versions among projects",
"shellCommand": "node common/scripts/sync-versions.js"
"commandKind": "bulk",
"name": "test:node",
"summary": "Execute Node dev tests defined in projects",
"enableParallelism": true
},
{
"commandKind": "bulk",
"name": "test",
"summary": "Execute dev tests defined in projects",
"description": "Execute any tests which a developer typically runs in their inner dev loop. Dev tests *should* just refer to other test scripts, but they don't have to. This command is never run by the build server.",
"enableParallelism": true
},
{
"commandKind": "bulk",
"name": "unit-test:browser",
"summary": "Execute browser unit tests defined in projects",
"enableParallelism": true
},
{
"commandKind": "bulk",
"name": "unit-test:node",
"summary": "Execute Node unit tests defined in projects",
"enableParallelism": true
},
{
"commandKind": "bulk",
"name": "unit-test",
"summary": "Execute unit tests defined in projects",
"description": "Execute tests which don't need to connect to any external service.",
"enableParallelism": true
},

// Optional Scripts
{
"commandKind": "bulk",
"name": "extract-api",
"summary": "Run API Extractor on projects",
"enableParallelism": true,
"ignoreMissingScript": true
},

// Global Commands
{
"commandKind": "global",
"name": "uninstall",
"summary": "Unlink dependencies and purge downloaded node_modules",
"safeForSimultaneousRushProcesses": true,
"shellCommand": "rush unlink && rush purge"
"name": "list-files",
"summary": "List files within Rush project directories",
"shellCommand": "node common/scripts/list-files.js"
},
{
"commandKind": "global",
Expand All @@ -175,9 +143,16 @@
},
{
"commandKind": "global",
"name": "list-files",
"summary": "List files within Rush project directories",
"shellCommand": "node common/scripts/list-files.js"
"name": "sync-versions",
"summary": "Sync versions among projects",
"shellCommand": "node common/scripts/sync-versions.js"
},
{
"commandKind": "global",
"name": "uninstall",
"summary": "Unlink dependencies and purge downloaded node_modules",
"safeForSimultaneousRushProcesses": true,
"shellCommand": "rush unlink && rush purge"
}
],

Expand All @@ -186,94 +161,6 @@
* For example, you might define a "--production" parameter for the "rush build" command.
*/
"parameters": [
// {
// /**
// * (Required) Determines the type of custom parameter.
// * A "flag" is a custom command-line parameter whose presence acts as an on/off switch.
// */
// "parameterKind": "flag",
//
// /**
// * (Required) The long name of the parameter. It must be lower-case and use dash delimiters.
// */
// "longName": "--my-flag",
//
// /**
// * An optional alternative short name for the parameter. It must be a dash followed by a single
// * lower-case or upper-case letter, which is case-sensitive.
// *
// * NOTE: The Rush developers recommend that automation scripts should always use the long name
// * to improve readability. The short name is only intended as a convenience for humans.
// * The alphabet letters run out quickly, and are difficult to memorize, so *only* use
// * a short name if you expect the parameter to be needed very often in everyday operations.
// */
// "shortName": "-m",
//
// /**
// * (Required) A long description to be shown in the command-line help.
// *
// * Whenever you introduce commands/parameters, taking a little time to write meaningful
// * documentation can make a big difference for the developer experience in your repo.
// */
// "description": "A custom flag parameter that is passed to the scripts that are invoked when building projects",
//
// /**
// * (Required) A list of custom commands and/or built-in Rush commands that this parameter may
// * be used with. The parameter will be appended to the shell command that Rush invokes.
// */
// "associatedCommands": [ "build", "rebuild" ]
// },
//
// {
// /**
// * (Required) Determines the type of custom parameter.
// * A "flag" is a custom command-line parameter whose presence acts as an on/off switch.
// */
// "parameterKind": "choice",
// "longName": "--my-choice",
// "description": "A custom choice parameter for the \"my-global-command\" custom command",
//
// "associatedCommands": [ "my-global-command" ],
//
// /**
// * Normally if a parameter is omitted from the command line, it will not be passed
// * to the shell command. this value will be inserted by default. Whereas if a "defaultValue"
// * is defined, the parameter will always be passed to the shell command, and will use the
// * default value if unspecified. The value must be one of the defined alternatives.
// */
// "defaultValue": "vanilla",
//
// /**
// * (Required) A list of alternative argument values that can be chosen for this parameter.
// */
// "alternatives": [
// {
// /**
// * A token that is one of the alternatives that can be used with the choice parameter,
// * e.g. "vanilla" in "--flavor vanilla".
// */
// "name": "vanilla",
//
// /**
// * A detailed description for the alternative that can be shown in the command-line help.
// *
// * Whenever you introduce commands/parameters, taking a little time to write meaningful
// * documentation can make a big difference for the developer experience in your repo.
// */
// "description": "Use the vanilla flavor (the default)"
// },
//
// {
// "name": "chocolate",
// "description": "Use the chocolate flavor"
// },
//
// {
// "name": "strawberry",
// "description": "Use the strawberry flavor"
// }
// ]
// }
{
"parameterKind": "flag",
"longName": "--sync-peers",
Expand Down
Loading

0 comments on commit 0fc1a95

Please sign in to comment.