Skip to content

Commit 548fca6

Browse files
committed
Merge branch 'main' into inspector
2 parents 1c10362 + e899fcb commit 548fca6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1555
-715
lines changed

.github/workflows/preview.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Preview
2+
on:
3+
pull_request:
4+
types: [opened, synchronize]
5+
6+
jobs:
7+
preview:
8+
name: Publish Previews
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
with:
13+
fetch-depth: 0
14+
- uses: denoland/setup-deno@v2
15+
with:
16+
deno-version: v2.x
17+
- uses: actions/setup-node@v4
18+
with:
19+
node-version: 20.x
20+
21+
- name: Get changed packages
22+
id: changed
23+
run: deno run -A tasks/preview-matrix.ts
24+
25+
- name: Build and publish previews
26+
if: steps.changed.outputs.workspaces != ''
27+
run: |
28+
for workspace in ${{ steps.changed.outputs.workspaces }}; do
29+
deno run -A tasks/build-npm.ts "$workspace"
30+
done
31+
32+
dirs=""
33+
for workspace in ${{ steps.changed.outputs.workspaces }}; do
34+
dirs="$dirs ./$workspace/build/npm"
35+
done
36+
npx pkg-pr-new publish $dirs

.github/workflows/publish.yaml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@ on:
55
- main
66

77
jobs:
8+
verify-posix:
9+
uses: ./.github/workflows/verify-posix.yaml
10+
11+
verify-windows:
12+
uses: ./.github/workflows/verify-windows.yaml
13+
814
generate-matrix:
15+
needs: [verify-posix, verify-windows]
916
name: Generate Job Matrix
1017
runs-on: ubuntu-latest
1118
outputs:
@@ -23,7 +30,7 @@ jobs:
2330
id: set-matrix
2431

2532
jsr:
26-
if: fromJSON(needs.generate-matrix.outputs.exists)
33+
if: github.ref == 'refs/heads/main' && fromJSON(needs.generate-matrix.outputs.exists)
2734
name: Publish ${{ matrix.name }}@${{matrix.version}} to JSR
2835
runs-on: ubuntu-latest
2936

@@ -46,7 +53,7 @@ jobs:
4653
working-directory: ${{ matrix.workspace }}
4754

4855
npm:
49-
if: fromJSON(needs.generate-matrix.outputs.exists)
56+
if: github.ref == 'refs/heads/main' && fromJSON(needs.generate-matrix.outputs.exists)
5057
name: Publish ${{ matrix.name }}@${{matrix.version}} to NPM
5158
runs-on: ubuntu-latest
5259

@@ -64,20 +71,18 @@ jobs:
6471
steps:
6572
- uses: actions/checkout@v4.2.0
6673
- uses: denoland/setup-deno@v2
67-
- uses: actions/setup-node@v4
74+
- uses: actions/setup-node@v6
6875
with:
69-
node-version: 20.x
76+
node-version: 24
7077
registry-url: https://registry.npmjs.com
7178

7279
- run: deno run -A tasks/build-npm.ts ${{matrix.workspace}}
7380

7481
- run: npm publish --access=public --tag=latest
7582
working-directory: ${{matrix.workspace}}/build/npm
76-
env:
77-
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
7883

7984
tag:
80-
if: fromJSON(needs.generate-matrix.outputs.exists)
85+
if: github.ref == 'refs/heads/main' && fromJSON(needs.generate-matrix.outputs.exists)
8186
name: "Tag Release"
8287
runs-on: ubuntu-latest
8388
needs: [generate-matrix, jsr, npm]

.github/workflows/verify-posix.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
name: Verify (POSIX)
22

33
on:
4-
push:
5-
branches:
6-
- main
4+
workflow_call:
75
pull_request:
86
branches:
97
- main
@@ -34,5 +32,11 @@ jobs:
3432
- run: deno fmt --check
3533

3634
- run: deno lint
35+
- run: deno task generate-importmap "^3" v3.importmap.json
36+
- run: deno task generate-importmap v4 v4.importmap.json
37+
38+
- name: V3 Tests
39+
run: deno test --import-map v3.importmap.json --allow-net --allow-read --allow-write --allow-env --allow-run --allow-ffi
3740

38-
- run: deno test --allow-net --allow-read --allow-write --allow-env --allow-run --allow-ffi
41+
- name: V4 Tests
42+
run: deno test --import-map v4.importmap.json --allow-net --allow-read --allow-write --allow-env --allow-run --allow-ffi --trace-leaks

.github/workflows/verify-windows.yaml

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
name: Verify (Windows)
22

33
on:
4-
push:
5-
branches:
6-
- main
4+
workflow_call:
75
pull_request:
86
branches:
97
- main
@@ -41,20 +39,41 @@ jobs:
4139

4240
- run: deno lint
4341

44-
- name: "Test (${{matrix.shell}})"
42+
- run: deno task generate-importmap "^3" v3.importmap.json
43+
- run: deno task generate-importmap v4 v4.importmap.json
44+
45+
- name: "Test V3 (${{matrix.shell}})"
46+
if: matrix.shell == 'powershell' || matrix.shell == 'pwsh'
47+
run: |
48+
$env:SHELL = "${{matrix.shell}}"
49+
deno test --import-map v3.importmap.json --allow-net --allow-read --allow-write --allow-env --allow-run --allow-ffi --trace-leaks
50+
51+
- name: "Test V4 (${{matrix.shell}})"
4552
if: matrix.shell == 'powershell' || matrix.shell == 'pwsh'
4653
run: |
4754
$env:SHELL = "${{matrix.shell}}"
48-
deno test --allow-net --allow-read --allow-write --allow-env --allow-run --allow-ffi --trace-leaks
55+
deno test --import-map v4.importmap.json --allow-net --allow-read --allow-write --allow-env --allow-run --allow-ffi --trace-leaks
4956
50-
- name: "Test (${{matrix.shell}})"
57+
- name: "Test V3 (${{matrix.shell}})"
5158
if: matrix.shell == 'cmd'
5259
run: |
5360
set SHELL=${{matrix.shell}}
54-
deno test --allow-net --allow-read --allow-write --allow-env --allow-run --allow-ffi --trace-leaks
61+
deno test --import-map v3.importmap.json --allow-net --allow-read --allow-write --allow-env --allow-run --allow-ffi --trace-leaks
62+
63+
- name: "Test V4 (${{matrix.shell}})"
64+
if: matrix.shell == 'cmd'
65+
run: |
66+
set SHELL=${{matrix.shell}}
67+
deno test --import-map v4.importmap.json --allow-net --allow-read --allow-write --allow-env --allow-run --allow-ffi --trace-leaks
68+
69+
- name: "Test V3 (${{matrix.shell}})"
70+
if: matrix.shell == 'bash'
71+
run: |
72+
export SHELL=${{matrix.shell}}
73+
deno test --import-map v3.importmap.json --allow-net --allow-read --allow-write --allow-env --allow-run --allow-ffi --trace-leaks
5574
56-
- name: "Test (${{matrix.shell}})"
75+
- name: "Test V4 (${{matrix.shell}})"
5776
if: matrix.shell == 'bash'
5877
run: |
5978
export SHELL=${{matrix.shell}}
60-
deno test --allow-net --allow-read --allow-write --allow-env --allow-run --allow-ffi --trace-leaks
79+
deno test --import-map v4.importmap.json --allow-net --allow-read --allow-write --allow-env --allow-run --allow-ffi --trace-leaks

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/deno.lock
22
/**/build/
3+
/v3.importmap.json
4+
/v4.importmap.json
35

46
.vscode

AGENTS.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

CLAUDE.md

Lines changed: 0 additions & 11 deletions
This file was deleted.

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,33 @@ more than a few times are welcome.
1515
5. Add doc strings to your source code - they will be used for documentation on
1616
the site.
1717

18+
## Testing
19+
20+
All packages are tested against both effection v3 and v4 to ensure
21+
compatibility.
22+
23+
### Generate import maps
24+
25+
```bash
26+
# Generate v3 import map
27+
deno task generate-importmap "^3" v3.importmap.json
28+
29+
# Generate v4 import map (fetches latest v4 from npm)
30+
deno task generate-importmap v4 v4.importmap.json
31+
```
32+
33+
### Running tests with v3
34+
35+
```bash
36+
deno test --import-map v3.importmap.json -A
37+
```
38+
39+
### Running tests with v4
40+
41+
```bash
42+
deno test --import-map v4.importmap.json -A
43+
```
44+
1845
## To publish a new project
1946

2047
1. Member of [jsr.io/@effectionx](https://jsr.io/@effectionx) has to add that

bdd/deno.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "@effectionx/bdd",
33
"exports": "./mod.ts",
4-
"version": "0.2.2",
4+
"version": "0.3.1",
55
"license": "MIT",
66
"imports": {
77
"effection": "npm:effection@^3",
8-
"@effectionx/test-adapter": "jsr:@effectionx/test-adapter@^0.1.0",
8+
"@effectionx/test-adapter": "jsr:@effectionx/test-adapter@^0.6.0",
99
"@std/testing": "jsr:@std/testing@^1"
1010
}
1111
}

bdd/mod.ts

Lines changed: 74 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,65 @@ import {
66
it as $it,
77
} from "@std/testing/bdd";
88

9+
/**
10+
* Sanitization options for test cases and test suites.
11+
* These options control Deno's test sanitizers.
12+
*/
13+
export interface SanitizeOptions {
14+
/** Ensure the test case does not prematurely cause the process to exit. Defaults to true. */
15+
sanitizeExit?: boolean;
16+
/** Check that the number of async completed ops after the test is the same as number of dispatched ops. Defaults to true. */
17+
sanitizeOps?: boolean;
18+
/** Ensure the test case does not "leak" resources - ie. the resource table after the test has exactly the same contents as before the test. Defaults to true. */
19+
sanitizeResources?: boolean;
20+
}
21+
922
let current: TestAdapter | undefined;
1023

11-
export function describe(name: string, body: () => void) {
24+
export function describe(
25+
name: string,
26+
body: () => void,
27+
options?: SanitizeOptions,
28+
) {
1229
const original = current;
1330
try {
1431
const child = current = createTestAdapter({ name, parent: original });
1532

16-
$describe(name, () => {
17-
$afterAll(() => child.destroy());
18-
body();
33+
$describe({
34+
name,
35+
fn: () => {
36+
$afterAll(() => child.destroy());
37+
body();
38+
},
39+
...options,
1940
});
2041
} finally {
2142
current = original;
2243
}
2344
}
2445

2546
describe.skip = $describe.skip;
26-
describe.only = $describe.only;
47+
describe.only = function (
48+
name: string,
49+
body: () => void,
50+
options?: SanitizeOptions,
51+
): void {
52+
const original = current;
53+
try {
54+
const child = current = createTestAdapter({ name, parent: original });
55+
56+
$describe.only({
57+
name,
58+
fn: () => {
59+
$afterAll(() => child.destroy());
60+
body();
61+
},
62+
...options,
63+
});
64+
} finally {
65+
current = original;
66+
}
67+
};
2768

2869
export function beforeAll(body: () => Operation<void>) {
2970
current?.addOnetimeSetup(body);
@@ -33,17 +74,25 @@ export function beforeEach(body: () => Operation<void>) {
3374
current?.addSetup(body);
3475
}
3576

36-
export function it(desc: string, body?: () => Operation<void>): void {
77+
export function it(
78+
desc: string,
79+
body?: () => Operation<void>,
80+
options?: SanitizeOptions,
81+
): void {
3782
const adapter = current!;
3883
if (!body) {
3984
$it.skip(desc, () => {});
4085
return;
4186
}
42-
$it(desc, async () => {
43-
const result = await adapter.runTest(body);
44-
if (!result.ok) {
45-
throw result.error;
46-
}
87+
$it({
88+
name: desc,
89+
fn: async () => {
90+
const result = await adapter.runTest(body);
91+
if (!result.ok) {
92+
throw result.error;
93+
}
94+
},
95+
...options,
4796
});
4897
}
4998

@@ -52,12 +101,20 @@ it.skip = (...args: Parameters<typeof it>): ReturnType<typeof it> => {
52101
return $it.skip(desc, () => {});
53102
};
54103

55-
it.only = (desc: string, body: () => Operation<void>): void => {
104+
it.only = (
105+
desc: string,
106+
body: () => Operation<void>,
107+
options?: SanitizeOptions,
108+
): void => {
56109
const adapter = current!;
57-
$it.only(desc, async () => {
58-
const result = await adapter.runTest(body);
59-
if (!result.ok) {
60-
throw result.error;
61-
}
110+
$it.only({
111+
name: desc,
112+
fn: async () => {
113+
const result = await adapter.runTest(body);
114+
if (!result.ok) {
115+
throw result.error;
116+
}
117+
},
118+
...options,
62119
});
63120
};

0 commit comments

Comments
 (0)