-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Various improvements to the /wattsi endpoint
In the course of working on adding a full /html-build endpoint, a few improvements came up which we can apply ahead of time to just the /wattsi endpoint: * Improve README documentation. * Abstract out the code for turning query parameters into boolean arguments. * Use more modern JS features. * Put temporary directories inside the OS temp directory. * Add a new helper for spawning a command-line program while capturing its output. This fixes #3. * Perform cleanup file deletions in parallel and log errors if they occur while deleting. * Move from deprecated --production npm install argument to modern --omit=dev.
- Loading branch information
Showing
3 changed files
with
94 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,46 +2,43 @@ | |
|
||
This app is a build server to allow you to run [Wattsi](https://github.com/whatwg/wattsi) without having to actually install it locally. Which is really useful, since not everyone has a Free Pascal compiler lying around. | ||
|
||
Currently it is hosted on build.whatwg.org. You can use it as follows: | ||
Currently it is hosted on build.whatwg.org.Currently it is hosted on build.whatwg.org. | ||
|
||
1. Get a local copy of `html.json` from <https://raw.githubusercontent.com/w3c/mdn-spec-links/master/html.json>. | ||
1. Get the HTML spec source file `source` by checking out [whatwg/html](https://github.com/whatwg/html). | ||
1. Run the following command: | ||
## Endpoints | ||
|
||
```sh | ||
curl https://build.whatwg.org/wattsi --verbose \ | ||
--form build=default \ | ||
--form sha=d3adb33f \ | ||
--form source=@source \ | ||
--form [email protected] \ | ||
--output output.zip | ||
``` | ||
### `/wattsi` | ||
|
||
The result will be a ZIP file containing the output of Wattsi! It will also contain an `output.txt` file containing the stdout output of Wattsi, which might contain warnings or similar things you want to check out. | ||
The `/wattsi` endpoint accepts POSTs with the following request body fields: | ||
|
||
(NOTE: if you get a non-200 response, the resulting zip file will actually be a text file containing some error text. To account for this, you may want to use [a more complicated incantation](https://github.com/whatwg/html-build/blob/18bdae0a716c47e326abb6312357fcc8d696a7f2/build.sh#L655-L677).) | ||
- `source`, a file, which you can get from [whatwg/html](https://github.com/whatwg/html) | ||
- `mdn`, a file, which you can get from <https://raw.githubusercontent.com/w3c/mdn-spec-links/master/html.json> | ||
- `sha`, a string, the Git commit hash of the whatwg/html repository | ||
- `build`, a string, either `"default"` or `"review"` | ||
|
||
## Other Features | ||
You can also send the following query string parameters, which correspond to the same-named Wattsi options: | ||
|
||
You can send the query string parameter `quiet` to pass the `--quiet` option to Wattsi. | ||
- `quiet` | ||
- `single-page-only` | ||
|
||
You can send the query string paramter `single-page-only` to pass the `--single-page-only` option to Wattsi. | ||
If the resulting status code is 200, the result will be a ZIP file containing the output, as well as an `output.txt` containing the stdout/stderr output. If the resulting status code is 400, the body text will be the error message. | ||
|
||
The response will have a header, `Wattsi-Exit-Code`, which gives the exit code of Wattsi. This will always be `0` for a 200 OK response, but a 400 Bad Request could give a variety of different values, depending on how Wattsi failed. | ||
|
||
You can hit the `/version` endpoint with a GET to check to see if the server is working. It should return the `text/plain` response of the latest-deployed Git commit SHA. | ||
### `/version` | ||
|
||
This endpoint responds to GET requests so you can check to see if the server is working. It returns a `text/plain` response of the latest-deployed Git commit SHA. | ||
|
||
## Server Development Info | ||
|
||
This server requires the following to run: | ||
|
||
- [Node.js](https://nodejs.org/) 11.4.0 or later | ||
- [Node.js](https://nodejs.org/) 18.17.1 or later | ||
- [7zip](http://www.7-zip.org/) in your path as `7za` | ||
- And, of course, [Wattsi](https://github.com/whatwg/wattsi), in your `$PATH` as `wattsi` | ||
|
||
It will expose itself on the port given by the `$PORT` environment variable. | ||
|
||
To set up the server remember to do `npm install --production`. Then, to start it running, just do `npm start`. | ||
To set up the server remember to do `npm install --omit=dev`. Then, to start it running, just do `npm start`. | ||
|
||
Alternately, you can use Docker: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters