Skip to content

Commit

Permalink
[CI] yml engineering run tests that isolate current deno.json depende…
Browse files Browse the repository at this point in the history
…ncies

[CHORE] fmt
[FIX] service test that is sensitive to cwd
  • Loading branch information
aricart committed Jul 2, 2024
1 parent 8726c71 commit bfc4560
Show file tree
Hide file tree
Showing 20 changed files with 113 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/core.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: core release
name: @nats-io/nats-core release

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/jetstream.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: core release
name: @nats-io/jetstream release

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/kv.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: core release
name: @nats-io/kv release

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/obj.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: core release
name: @nats-io/obj release

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/services.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: core release
name: @nats-io/services release

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: NATS.deno
name: Test nats.js

on:
push:
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
![Test NATS.deno](https://github.com/nats-io/nats.deno/workflows/NATS.deno/badge.svg)
[![Coverage Status](https://coveralls.io/repos/github/nats-io/nats.deno/badge.svg?branch=main)](https://coveralls.io/github/nats-io/nats.deno?branch=main)


> [!CAUTION]
> This project is still working in progress and not yet released. Currently supported Javascript are
> [!CAUTION] This project is still working in progress and not yet released.
> Currently supported Javascript are
>
> - [nats.deno](https://github.com/nats-io/nats.deno)
> - [nats.js](https://github.com/nats-io/nats.js)
> - [nats.ws](https://github.com/nats-io/nats.ws)


Welcome to the new NATS.js repository! Beginning with the v3 release of the
JavaScript clients, the NATS.js repository reorganizes the NATS JavaScript
client libraries into a formal mono-repo.
Expand Down
3 changes: 2 additions & 1 deletion core/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
]
},
"tasks": {
"clean": "rm -rf ./lib ./cjs ./esm"
"clean": "rm -rf ./lib ./cjs ./esm",
"test": "deno test -A --parallel --reload --quiet tests/ --import-map=./import_map.json"
},
"imports": {
"@nats-io/nkeys": "jsr:@nats-io/[email protected]",
Expand Down
8 changes: 8 additions & 0 deletions core/import_map.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"imports": {
"test_helpers": "../test_helpers/mod.ts",
"@nats-io/nats-core": "./src/mod.ts",
"@nats-io/nats-core/internal": "./src/internal_mod.ts",
"@std/io": "jsr:@std/[email protected]"
}
}
12 changes: 10 additions & 2 deletions jetstream/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,20 @@
},
"publish": {
"include": [
"./**/*"
"./src"
],
"exclude": [
"./**/tests"
"./tests",
"./examples",
"./import_map.json",
"./package.json",
"./package.lock",
"./tsconfig.json"
]
},
"tasks": {
"test": "deno test -A --parallel --reload --quiet tests/ --import-map=import_map.json"
},
"imports": {
"@nats-io/nats-core": "jsr:@nats-io/[email protected]"
}
Expand Down
9 changes: 9 additions & 0 deletions jetstream/import_map.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"imports": {
"@nats-io/nkeys": "jsr:@nats-io/[email protected]",
"@nats-io/nuid": "jsr:@nats-io/[email protected]",
"@nats-io/jetstream/internal": "./src/internal_mod.ts",
"test_helpers": "../test_helpers/mod.ts",
"@std/io": "jsr:@std/[email protected]"
}
}
22 changes: 0 additions & 22 deletions jetstream/tests/jscluster_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
StreamUpdateConfig,
} from "../src/jsapi_types.ts";
import { nanos } from "@nats-io/nats-core/internal";
import { Kvm } from "../../kv/src/kv.ts";

import {
assertArrayIncludes,
Expand Down Expand Up @@ -173,24 +172,3 @@ Deno.test("streams - mirrors", async () => {
await nc.close();
await NatsServer.stopAll(cluster, true);
});

Deno.test("kv - replicas", async () => {
const servers = await NatsServer.jetstreamCluster(3);
const nc = await connect({ port: servers[0].port });
const js = jetstream(nc);

const b = await new Kvm(js).create("a", { replicas: 3 });
const status = await b.status();

const jsm = await jetstreamManager(nc);
let si = await jsm.streams.info(status.streamInfo.config.name);
assertEquals(si.config.num_replicas, 3);

si = await jsm.streams.update(status.streamInfo.config.name, {
num_replicas: 1,
});
assertEquals(si.config.num_replicas, 1);

await nc.close();
await NatsServer.stopAll(servers, true);
});
8 changes: 6 additions & 2 deletions kv/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@
},
"publish": {
"include": [
"./src/*"
"./src"
],
"exclude": [
"./**/tests"
"./tests",
"./import_map.json"
]
},
"tasks": {
"test": "deno test -A --parallel --reload --quiet tests/ --import-map=import_map.json"
},
"imports": {
"@nats-io/nats-core": "jsr:@nats-io/[email protected]",
"@nats-io/jetstream": "jsr:@nats-io/[email protected]"
Expand Down
12 changes: 12 additions & 0 deletions kv/import_map.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"imports": {
"@nats-io/nats-core": "jsr:@nats-io/[email protected]",
"@nats-io/nats-core/internal": "jsr:@nats-io/[email protected]/internal",
"@nats-io/jetstream": "jsr:@nats-io/[email protected]",
"@nats-io/jetstream/internal": "jsr:@nats-io/[email protected]/internal",
"test_helpers": "../test_helpers/mod.ts",
"@nats-io/nkeys": "jsr:@nats-io/[email protected]",
"@nats-io/nuid": "jsr:@nats-io/[email protected]",
"@std/io": "jsr:@std/[email protected]"
}
}
21 changes: 21 additions & 0 deletions kv/tests/kv_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2248,3 +2248,24 @@ Deno.test("kv - keys filter", async () => {

await cleanup(ns, nc);
});

Deno.test("kv - replicas", async () => {
const servers = await NatsServer.jetstreamCluster(3);
const nc = await connect({ port: servers[0].port });
const js = jetstream(nc);

const b = await new Kvm(js).create("a", { replicas: 3 });
const status = await b.status();

const jsm = await jetstreamManager(nc);
let si = await jsm.streams.info(status.streamInfo.config.name);
assertEquals(si.config.num_replicas, 3);

si = await jsm.streams.update(status.streamInfo.config.name, {
num_replicas: 1,
});
assertEquals(si.config.num_replicas, 1);

await nc.close();
await NatsServer.stopAll(servers, true);
});
7 changes: 5 additions & 2 deletions obj/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
},
"publish": {
"include": [
"./src/*"
"./src"
],
"exclude": [
"./**/tests"
"./tests"
]
},
"tasks": {
"test": "deno test -A --parallel --reload --quiet tests/ --import-map=import_map.json"
},
"imports": {
"@nats-io/nats-core": "jsr:@nats-io/[email protected]",
"@nats-io/jetstream": "jsr:@nats-io/[email protected]"
Expand Down
12 changes: 12 additions & 0 deletions obj/import_map.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"imports": {
"@nats-io/nats-core": "jsr:@nats-io/[email protected]",
"@nats-io/nats-core/internal": "jsr:@nats-io/[email protected]/internal",
"@nats-io/jetstream": "jsr:@nats-io/[email protected]",
"@nats-io/jetstream/internal": "jsr:@nats-io/[email protected]/internal",
"test_helpers": "../test_helpers/mod.ts",
"@nats-io/nkeys": "jsr:@nats-io/[email protected]",
"@nats-io/nuid": "jsr:@nats-io/[email protected]",
"@std/io": "jsr:@std/[email protected]"
}
}
3 changes: 3 additions & 0 deletions services/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
"./tests"
]
},
"tasks": {
"test": "deno test -A --parallel --reload --quiet tests/ --import-map=import_map.json"
},
"imports": {
"@nats-io/nats-core": "jsr:@nats-io/[email protected]"
}
Expand Down
10 changes: 10 additions & 0 deletions services/import_map.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"imports": {
"@nats-io/nats-core": "jsr:@nats-io/[email protected]",
"@nats-io/nats-core/internal": "jsr:@nats-io/[email protected]/internal",
"test_helpers": "../test_helpers/mod.ts",
"@nats-io/nkeys": "jsr:@nats-io/[email protected]",
"@nats-io/nuid": "jsr:@nats-io/[email protected]",
"@std/io": "jsr:@std/[email protected]"
}
}
7 changes: 6 additions & 1 deletion services/tests/service_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -700,10 +700,15 @@ Deno.test("service - cross platform service test", async () => {
},
});

// running from root?
const scheck = Deno.cwd().endsWith("nats.js")
? "./services/tests/service-check.ts"
: "./tests/service-check.ts";

const args = [
"run",
"-A",
"./services/tests/service-check.ts",
scheck,
"--name",
name,
"--server",
Expand Down

0 comments on commit bfc4560

Please sign in to comment.