Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
1147c5c
Services: Documentation and config (#460)
aomarks Oct 14, 2022
525b625
Services: Config types, events, stub execution class, and started pro…
aomarks Oct 17, 2022
35d0980
Services: Add service-related analysis properties (#466)
aomarks Oct 19, 2022
0377bdb
Services: Refactoring to surface more Execution API to other scripts …
aomarks Oct 20, 2022
d8e3e76
Services: Track when services are not needed (#473)
aomarks Oct 21, 2022
0566c95
Services: Integrate into standard scripts (#474)
aomarks Oct 21, 2022
b81bd8f
Services: State diagram (#475)
aomarks Oct 22, 2022
1a1f7b5
Services: Support for very basic consumer/service test case (#476)
aomarks Oct 24, 2022
81af6b3
Services: Stdout/stderr and various error case handling (#483)
aomarks Oct 26, 2022
822a5a3
Services: Handle more starting/stopping scenarios (#486)
aomarks Oct 28, 2022
55eccf3
Services: Pass running services across watch iterations (#488)
aomarks Oct 28, 2022
a3be5aa
Shut down services that have been deleted between watch iterations (#…
aomarks Oct 29, 2022
6ed5b5e
Allow service consumers to cache (#490)
aomarks Oct 30, 2022
94990ab
Services: Make services of services also be persistent (#493)
aomarks Oct 30, 2022
cb1e4b6
Add missing promise resolution for graceful stop case (#497)
aomarks Nov 1, 2022
a09a030
More graceful shutdown of stale services (#500)
aomarks Nov 1, 2022
f593a51
Services: Fix memory leaks in watch mode (#504)
aomarks Nov 4, 2022
e30f98a
Services: Misc fixes mostly related to error handling (#507)
aomarks Nov 5, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,17 @@ jobs:
- run: npm ci
- run: npm run lint
- run: npm run format:check

test-garbage-collection:
timeout-minutes: 5
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
cache: npm
- uses: google/wireit@setup-github-actions-caching/v1

- run: npm ci
- run: npm run test:gc
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic
Versioning](https://semver.org/spec/v2.0.0.html).

<!-- ## [Unreleased] -->
## [Unreleased]

### Added

- Added `"service": true` setting, which is well suited for long-running
processes like servers. A service is started either when it is invoked directly,
or when another script that depends on it is ready to run. A service is stopped
when all scripts that depend on it have finished, or when Wireit is exited.

### Fixed

- Fixed memory leak in watch mode.

## [0.7.2] - 2022-09-25

Expand Down
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
- [GitHub Actions caching](#github-actions-caching)
- [Cleaning output](#cleaning-output)
- [Watch mode](#watch-mode)
- [Services](#services)
- [Failures and errors](#failures-and-errors)
- [Package locks](#package-locks)
- [Recipes](#recipes)
Expand Down Expand Up @@ -388,6 +389,46 @@ The benefit of Wireit's watch mode over built-in watch modes are:
simultaneously, such as build steps being triggered before all preceding steps
have finished.

## Services

By default, Wireit assumes that your scripts will eventually exit by themselves.
This is well suited for build and test scripts, but not for long-running
processes like servers. To tell Wireit that a process is long-running and not
expected to exit by itself, set `"service": true`.

```json
{
"scripts": {
"serve": "wireit",
"build:server": "wireit",
"build:assets": "wireit"
},
"wireit": {
"serve": {
"command": "node my-server.js",
"service": true,
"files": ["server-config.json"],
"dependencies": ["build:server", "build:assets"]
}
}
}
```

If a service is run _directly_ (e.g. `npm run serve`), then it will stay running
until the user kills Wireit (e.g. `Ctrl-C`).

If a service is a _dependency_ of one or more other scripts, then it will start
up before any depending script runs, and will shut down after all depending
scripts finish.

In watch mode, a service will be restarted whenever one of its input files or
dependencies change.

Services cannot have `output` files, because there is no way for Wireit to know
when a service has finished writing its output. If you have a service that
produces output, you should define a non-service script that depends on it, and
which exits when the service's output is complete.

## Failures and errors

By default, when a script fails (meaning it returned with a non-zero exit code),
Expand Down
67 changes: 48 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"format:check": "prettier . -c",
"test": "wireit",
"test:headless": "wireit",
"test:analysis": "wireit",
"test:basic": "wireit",
"test:cache-github": "wireit",
"test:cache-local": "wireit",
Expand All @@ -43,10 +44,12 @@
"test:failures": "wireit",
"test:freshness": "wireit",
"test:ide": "wireit",
"test:gc": "wireit",
"test:glob": "wireit",
"test:json-schema": "wireit",
"test:optimize-mkdirs": "wireit",
"test:parallelism": "wireit",
"test:service": "wireit",
"test:watch": "wireit"
},
"wireit": {
Expand All @@ -70,6 +73,7 @@
},
"test:headless": {
"dependencies": [
"test:analysis",
"test:basic",
"test:cache-github",
"test:cache-local",
Expand All @@ -88,6 +92,7 @@
"test:json-schema",
"test:optimize-mkdirs",
"test:parallelism",
"test:service",
"test:watch"
]
},
Expand All @@ -105,128 +110,144 @@
],
"output": []
},
"test:analysis": {
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"^analysis\\.test\\.js$\"",
"dependencies": [
"build"
],
"files": [],
"output": []
},
"test:basic": {
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"basic\\.test\\.js$\"",
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"^basic\\.test\\.js$\"",
"dependencies": [
"build"
],
"files": [],
"output": []
},
"test:cache-github": {
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"cache-github\\.test\\.js$\"",
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"^cache-github\\.test\\.js$\"",
"dependencies": [
"build"
],
"files": [],
"output": []
},
"test:cache-local": {
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"cache-local\\.test\\.js$\"",
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"^cache-local\\.test\\.js$\"",
"dependencies": [
"build"
],
"files": [],
"output": []
},
"test:clean": {
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"clean\\.test\\.js$\"",
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"^clean\\.test\\.js$\"",
"dependencies": [
"build"
],
"files": [],
"output": []
},
"test:cli-options": {
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"cli-options\\.test\\.js$\"",
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"^cli-options\\.test\\.js$\"",
"dependencies": [
"build"
],
"files": [],
"output": []
},
"test:codeactions": {
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"codeactions\\.test\\.js$\"",
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"^codeactions\\.test\\.js$\"",
"dependencies": [
"build"
],
"files": [],
"output": []
},
"test:copy": {
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"copy\\.test\\.js$\"",
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"^copy\\.test\\.js$\"",
"dependencies": [
"build"
],
"files": [],
"output": []
},
"test:delete": {
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"delete\\.test\\.js$\"",
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"^delete\\.test\\.js$\"",
"dependencies": [
"build"
],
"files": [],
"output": []
},
"test:diagnostic": {
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"diagnostic\\.test\\.js$\"",
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"^diagnostic\\.test\\.js$\"",
"dependencies": [
"build"
],
"files": [],
"output": []
},
"test:errors-analysis": {
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"errors-analysis\\.test\\.js$\"",
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"^errors-analysis\\.test\\.js$\"",
"dependencies": [
"build"
],
"files": [],
"output": []
},
"test:errors-usage": {
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"errors-usage\\.test\\.js$\"",
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"^errors-usage\\.test\\.js$\"",
"dependencies": [
"build"
],
"files": [],
"output": []
},
"test:failures": {
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"failures\\.test\\.js$\"",
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"^failures\\.test\\.js$\"",
"dependencies": [
"build"
],
"files": [],
"output": []
},
"test:freshness": {
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"freshness\\.test\\.js$\"",
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"^freshness\\.test\\.js$\"",
"dependencies": [
"build"
],
"files": [],
"output": []
},
"test:gc": {
"command": "cross-env NODE_OPTIONS=--enable-source-maps node --expose-gc node_modules/uvu/bin.js lib/test \"^gc\\.test\\.js$\"",
"dependencies": [
"build"
],
"files": [],
"output": []
},
"test:glob": {
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"glob\\.test\\.js$\"",
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"^glob\\.test\\.js$\"",
"dependencies": [
"build"
],
"files": [],
"output": []
},
"test:ide": {
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"ide\\.test\\.js$\"",
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"^ide\\.test\\.js$\"",
"dependencies": [
"build"
],
"files": [],
"output": []
},
"test:json-schema": {
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"json-schema\\.test\\.js$\"",
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"^json-schema\\.test\\.js$\"",
"dependencies": [
"build"
],
Expand All @@ -236,23 +257,31 @@
"output": []
},
"test:optimize-mkdirs": {
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"optimize-mkdirs\\.test\\.js$\"",
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"^optimize-mkdirs\\.test\\.js$\"",
"dependencies": [
"build"
],
"files": [],
"output": []
},
"test:parallelism": {
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"parallelism\\.test\\.js$\"",
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"^parallelism\\.test\\.js$\"",
"dependencies": [
"build"
],
"files": [],
"output": []
},
"test:service": {
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"^service\\.test\\.js$\"",
"dependencies": [
"build"
],
"files": [],
"output": []
},
"test:watch": {
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"watch\\.test\\.js$\"",
"command": "cross-env NODE_OPTIONS=--enable-source-maps uvu lib/test \"^watch\\.test\\.js$\"",
"dependencies": [
"build"
],
Expand Down
4 changes: 4 additions & 0 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
"type": "string"
},
"type": "array"
},
"service": {
"markdownDescription": "If true, treat this script as a long-running process.\nServices are automatically brought up and down as they are depended upon by other scripts. If invoked directly, services continue running until Wireit is killed with Ctrl-C.\nFor more info, see: https://github.com/google/wireit#services",
"type": "boolean"
}
},
"type": "object"
Expand Down
Loading