Skip to content

Commit

Permalink
fix(startScript): disable throw for Bun and Deno (#242)
Browse files Browse the repository at this point in the history
* fix(startScript): disable throw for Bun and Deno

* debug: increment ports time

* debug: increment ports time

* debug: increment ports time

* chore: remove unused imports

* chore: use await for port

* ci(coverage): improve patch settings

* chore: unlock Bun

* ci(coverage): disable Codecov patch

* chore: adjust timeout according to the docs

* docs: add port example

* docs: include Bun and Deno examples

* ci: include error log

* chore: use await to kill PIDs

* debug: remove quiet option

* debug: use await for bg tests

* debug: disable bg tests

* debug: disable secureEnds

* debug: refactor end process

* debug: restaure secureEnds

* chore: consider port in secureEnds

* chore: restaure non-debug changes

* chore: use for await to kill ports

* debug: overstate the waiting time

* debug: test time threshold

* ci(coverage): add c8 comments to output data

* chore: use port only for Bun and Deno

* docs: improve CONTRIBUTING.md

* docs: improve CONTRIBUTING.md

* docs: improve CONTRIBUTING.md
  • Loading branch information
wellwelwel authored May 14, 2024
1 parent 1901bd6 commit 0619688
Show file tree
Hide file tree
Showing 20 changed files with 386 additions and 201 deletions.
10 changes: 9 additions & 1 deletion .nycrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
{
"all": true,
"include": ["src/**"],
"exclude": ["src/@types/**"],
"exclude": [
"src/@types/**",
"fixtures",
"test",
"tools",
"website",
"ci",
"lib"
],
"extension": ["ts"],
"reporter": ["text", "lcov"],
"clean": true
Expand Down
54 changes: 38 additions & 16 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,71 @@ If you're thinking of contributing, thank you 🎉

You will need these tools installed on your system:

- [**Docker**](https://www.docker.com/products/docker-desktop/)
- [**Node.js**](https://nodejs.org/pt-br/download/current)
- [**Docker**](https://www.docker.com/products/docker-desktop/) (optional)

> **Bun**, **Deno** and **Node.js** are tested using **Docker** official images.
> **Bun**, **Deno** and **Node.js** versions are tested using **Docker** official images.
---

## Developing

Fork this project, download your forked repository locally and create a new branch from `main`.
Then running `npm ci` to install the dependecies from _package-lock.json_.
Then run `npm ci` to clean install the node modules.

> Please, do not change the _package-lock.json_.
### Fixes

Where possible, provide an error test case that your fix covers.

### Features

It's better to discuss an API before actually start implementing it. You can open an issue on **Github**.
We can discuss design of API and implementation ideas.

- Please ensure test cases to cover your features.

---

## Testing

The tests can be easily run:
### General (recommended)

```sh
npm run test
```

### Coverage

### All
Methods that vary according to **Node.js** version, platform or OS aren't tested against the coverage rate.

```sh
npm run test:ci
npm run test:c8
```

### Per Platform
### Compatibility Per Platform (Docker)

> ⚠️ Testing using **Docker** can require a considerable local storage.
```sh
FILTER='node-' npm run test:ci
FILTER='bun-' npm run test:ci
FILTER='deno-' npm run test:ci
npm run test:ci:node
npm run test:ci:bun
npm run test:ci:deno
```

---
- You may prefer to use **GitHub Actions** for compatibility testing.

### Coverage
### Compatibility (All — Docker)

> ⚠️ Slow and heavy
```sh
npm run test:c8
npm run test:ci
```

- You may prefer to use **GitHub Actions** for compatibility testing.

---

### Lint
Expand All @@ -70,9 +93,8 @@ npm run lint:checker
By opening an **Issue** or submit a **Pull Request**, describe your problem or solution. If you can share a basic repro, it will be great.
Please, let's discuss before to submitting a feature.
> Including tests would be great!
- Prefer to talk in **English** for Issues.
- For **Pull Requests**, you're welcome to discuss in both **English** and **Portuguese**.
---
Expand Down
4 changes: 4 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ coverage:
default:
target: 90%
threshold: 2%
patch:
default:
target: 0%
threshold: 100%
6 changes: 6 additions & 0 deletions fixtures/server/bun.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"scripts": {
"start:ts": "bun server-b.ts",
"start:js": "bun server-b.js"
}
}
5 changes: 5 additions & 0 deletions fixtures/server/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"tasks": {
"start:ts": "deno run --allow-net server-b.ts"
}
}
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
"main": "./lib/index.js",
"scripts": {
"test": "tsx src/bin/index.ts --parallel --debug --include=\"test/unit,test/integration,test/e2e\"",
"test:bun": "bun src/bin/index.ts --parallel --platform=bun --debug --include=\"test/unit,test/integration,test/e2e\"",
"test:c8": "c8 npm run test",
"test:ci": "tsx ./test/ci.test.ts",
"test:node": "FILTER='node-' npm run test:ci",
"test:deno": "FILTER='deno-' npm run test:ci",
"test:bun": "FILTER='bun-' npm run test:ci",
"test:ci:node": "FILTER='node-' npm run test:ci",
"test:ci:bun": "FILTER='bun-' npm run test:ci",
"test:ci:deno": "FILTER='deno-' npm run test:ci",
"predocker:deno": "docker compose -f ./test/docker/playground/deno/docker-compose.yml down",
"docker:deno": "docker compose -f ./test/docker/playground/deno/docker-compose.yml up --build",
"clear": "shx rm -rf ./lib ./ci ./coverage",
Expand Down
4 changes: 3 additions & 1 deletion src/@types/background-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type BackgroundProcessOptions = {
*/
startAfter?: string | number;
/**
* Stops the service after:
* Stops the service for neither success nor failure after:
* @default 60000
*/
timeout?: number;
Expand Down Expand Up @@ -46,3 +46,5 @@ export type StartServiceOptions = {
*/
readonly platform?: Configs['platform'];
} & BackgroundProcessOptions;

export type End = (port?: number) => Promise<void>;
Loading

0 comments on commit 0619688

Please sign in to comment.