Skip to content

Commit

Permalink
Github actions and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
julienmalard committed Jan 20, 2024
1 parent c806485 commit 4dc6542
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 69 deletions.
20 changes: 0 additions & 20 deletions .github/ISSUE_TEMPLATE/requ-te-de-fonctionnalit-.md

This file was deleted.

34 changes: 0 additions & 34 deletions .github/ISSUE_TEMPLATE/signaler-un-probl-me.md

This file was deleted.

26 changes: 26 additions & 0 deletions .github/workflows/npm-publish-next.yml
Original file line number Diff line number Diff line change
@@ -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}}
22 changes: 22 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -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}}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches:
- main
jobs:
tests-et-couverture:
tests-and-coverage:
name: Node.js test
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// Generated by genversion.
export const version = "0.1.0";
export const version = "1.0.0";
23 changes: 11 additions & 12 deletions test/set.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { deepStrictEqual, strictEqual, notStrictEqual } from "assert";
import { type Helia } from "helia";

import { rimraf } from "rimraf";
Expand Down Expand Up @@ -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 () => {
Expand All @@ -69,7 +68,7 @@ describe("Set Database", () => {
all.unshift(item);
}

strictEqual(all.length, 0);
expect(all.length).to.equal(0);
});
});

Expand Down Expand Up @@ -170,7 +169,7 @@ describe("Set Database", () => {
all.unshift(pair);
}

deepStrictEqual(all, keyvalue);
expect(all).to.deep.equal(keyvalue);
});
});

Expand All @@ -191,16 +190,16 @@ 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 () => {
const all = [];
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 () => {
Expand All @@ -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 () => {
Expand All @@ -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 () => {
Expand All @@ -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 () => {
Expand All @@ -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);
});
});
});

0 comments on commit 4dc6542

Please sign in to comment.