From 4dc654205e383df87679f182d2cfa31c782b3207 Mon Sep 17 00:00:00 2001 From: julienmalard Date: Sat, 20 Jan 2024 10:07:28 -0500 Subject: [PATCH] Github actions and tests --- .../requ-te-de-fonctionnalit-.md | 20 ----------- .../ISSUE_TEMPLATE/signaler-un-probl-me.md | 34 ------------------- .github/workflows/npm-publish-next.yml | 26 ++++++++++++++ .github/workflows/npm-publish.yml | 22 ++++++++++++ .github/workflows/{tests.yml => run-test.yml} | 2 +- README.md | 2 +- src/version.ts | 2 +- test/set.spec.ts | 23 ++++++------- 8 files changed, 62 insertions(+), 69 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/requ-te-de-fonctionnalit-.md delete mode 100644 .github/ISSUE_TEMPLATE/signaler-un-probl-me.md create mode 100644 .github/workflows/npm-publish-next.yml create mode 100644 .github/workflows/npm-publish.yml rename .github/workflows/{tests.yml => run-test.yml} (96%) diff --git a/.github/ISSUE_TEMPLATE/requ-te-de-fonctionnalit-.md b/.github/ISSUE_TEMPLATE/requ-te-de-fonctionnalit-.md deleted file mode 100644 index 515c8f2..0000000 --- a/.github/ISSUE_TEMPLATE/requ-te-de-fonctionnalit-.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -name: Requête de fonctionnalité -about: Proposer une nouvelle idée -title: '' -labels: '' -assignees: '' - ---- - -**Votre suggestion est-elle liée à un problème spécifique ? Veuillez décrire ci-dessous :** -Une explication claire, nette et précise du problème. Par exemple, "cela me frustre lorsque [...]" - -**Décrire la solution telle que vous l'envisagez** -Une description claire et précise du comportement que vous préfériez voir. - -**Décrire les alternatives** -Une brève description des solutions alternatives que vous avez considéré (si applicable). - -**Contexte additionnel** -Vous pouvez ajouter d'autres informations ou même des prises d'écran si vous le souhaitez. diff --git a/.github/ISSUE_TEMPLATE/signaler-un-probl-me.md b/.github/ISSUE_TEMPLATE/signaler-un-probl-me.md deleted file mode 100644 index 86fcf54..0000000 --- a/.github/ISSUE_TEMPLATE/signaler-un-probl-me.md +++ /dev/null @@ -1,34 +0,0 @@ ---- -name: Signaler un problème -about: Signalez-le et nous y travaillerons -title: '' -labels: '' -assignees: '' - ---- - -**Décrire le problème** -Une description claire, nette et précise du problème. - -**Comment le reproduire** -Instructions détaillées pour reproduire le problème. - -**Comportement attendu** -Une brève description du comportement auquel vous vous attendez. - -**Prises d'écran** -Si cela s'applique, incluez des prises d'écran du problème. - -**Pour ordinateurs :** - - SO: [p. ex. iOS, Windows 11, Linux, ...] - - Navigateur [p.ex. firefox, brave, chrome, safari] - - Version [p. ex. 22] - -**Pour téléphones intelligents :** - - Dispositig: [p. ex. iPhone6] - - SO: [p. ex. iOS8.1] - - Navigateur [p.ex. firefox, brave, chrome, safari] - - Version [p. ex. 22] - -**Contexte additionnel** -Inclure toute autre information utile. diff --git a/.github/workflows/npm-publish-next.yml b/.github/workflows/npm-publish-next.yml new file mode 100644 index 0000000..52c0e26 --- /dev/null +++ b/.github/workflows/npm-publish-next.yml @@ -0,0 +1,26 @@ +--- +name: Node.js Package (next tag) + +on: + push: + branches: + - main + +jobs: + publish-npm: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 'lts/*' + registry-url: https://registry.npmjs.org/ + - run: npm ci + - run: npm run lint + - run: npm test + - run: | + npm version prerelease --no-git-tag-version \ + --preid=`git rev-parse --short HEAD` + npm publish --tag next + env: + NODE_AUTH_TOKEN: ${{secrets.npm_token}} \ No newline at end of file diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 0000000..64fe762 --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,22 @@ +--- +name: Node.js Package + +on: + push: + tags: + - 'v*' + +jobs: + publish-npm: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 'lts/*' + registry-url: https://registry.npmjs.org/ + - run: npm ci + - run: npm test + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.npm_token}} \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/run-test.yml similarity index 96% rename from .github/workflows/tests.yml rename to .github/workflows/run-test.yml index e9abe49..b47925f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/run-test.yml @@ -7,7 +7,7 @@ on: branches: - main jobs: - tests-et-couverture: + tests-and-coverage: name: Node.js test runs-on: ubuntu-latest steps: diff --git a/README.md b/README.md index a88792e..b1488ca 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # orbit-db-set Set database type for orbit-db. -[![orbit-db-set tests](https://github.com/reseau-constellation/set/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/reseau-constellation/set/actions/workflows/tests.yml) +[![orbit-db-set tests](https://github.com/reseau-constellation/set/actions/workflows/run-test.yml/badge.svg?branch=main)](https://github.com/reseau-constellation/set/actions/workflows/run-test.yml) [![codecov](https://codecov.io/gh/reseau-constellation/set/graph/badge.svg?token=7OZK4BJDej)](https://codecov.io/gh/reseau-constellation/set) ## Installation diff --git a/src/version.ts b/src/version.ts index 9227a66..4c5cb31 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1,2 +1,2 @@ // Generated by genversion. -export const version = "0.1.0"; +export const version = "1.0.0"; diff --git a/test/set.spec.ts b/test/set.spec.ts index 897da5e..1df99f3 100644 --- a/test/set.spec.ts +++ b/test/set.spec.ts @@ -1,4 +1,3 @@ -import { deepStrictEqual, strictEqual, notStrictEqual } from "assert"; import { type Helia } from "helia"; import { rimraf } from "rimraf"; @@ -59,8 +58,8 @@ describe("Set Database", () => { }); it("creates a set store", async () => { - strictEqual(db.address.toString(), databaseId); - strictEqual(db.type, "set"); + expect(db.address.toString()).to.equal(databaseId); + expect(db.type).to.equal("set"); }); it("returns 0 items when it's a fresh database", async () => { @@ -69,7 +68,7 @@ describe("Set Database", () => { all.unshift(item); } - strictEqual(all.length, 0); + expect(all.length).to.equal(0); }); }); @@ -170,7 +169,7 @@ describe("Set Database", () => { all.unshift(pair); } - deepStrictEqual(all, keyvalue); + expect(all).to.deep.equal(keyvalue); }); }); @@ -191,8 +190,8 @@ describe("Set Database", () => { }); it("has an iterator function", async () => { - notStrictEqual(db.iterator, undefined); - strictEqual(typeof db.iterator, "function"); + expect(db.iterator).to.be.undefined(); + expect(typeof db.iterator).to.equal("function"); }); it("returns no values when the database is empty", async () => { @@ -200,7 +199,7 @@ describe("Set Database", () => { for await (const { hash, value } of db.iterator()) { all.unshift({ hash, value }); } - strictEqual(all.length, 0); + expect(all.length).to.equal(0); }); it("returns all values when the database is not empty", async () => { @@ -222,7 +221,7 @@ describe("Set Database", () => { for await (const { hash, value } of db.iterator()) { all.unshift({ hash, value }); } - strictEqual(all.length, 5); + expect(all.length).to.equal(5); }); it("returns only the amount of values given as a parameter", async () => { @@ -231,7 +230,7 @@ describe("Set Database", () => { for await (const { hash, value } of db.iterator({ amount })) { all.unshift({ hash, value }); } - strictEqual(all.length, amount); + expect(all.length).to.equal(amount); }); it("returns only two values if amount given as a parameter is 2", async () => { @@ -240,7 +239,7 @@ describe("Set Database", () => { for await (const { hash, value } of db.iterator({ amount })) { all.unshift({ hash, value }); } - strictEqual(all.length, amount); + expect(all.length).to.equal(amount); }); it("returns only one value if amount given as a parameter is 1", async () => { @@ -249,7 +248,7 @@ describe("Set Database", () => { for await (const { hash, value } of db.iterator({ amount })) { all.unshift({ hash, value }); } - strictEqual(all.length, amount); + expect(all.length).to.equal(amount); }); }); });