Skip to content

Commit

Permalink
Updated file-storage (#5)
Browse files Browse the repository at this point in the history
* updated readme files

* updated readme files

* added short description

* added definitions

* updated tests

* updated packages versions and README files

* updated file-storage README.md

* added core package

* added core package

* fixed imports

* added more types for file-storage

* added more types for file-storage

* added tests

* fixed CI

* clean up

* updated test config

* fixed dependencies
  • Loading branch information
svalasovich authored May 18, 2022
1 parent b9166bf commit 919d4f5
Show file tree
Hide file tree
Showing 43 changed files with 11,129 additions and 5,649 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: 'CI'
on:
pull_request:
branches:
- main
types:
- opened
- synchronize
- edited
workflow_call:

jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- name: Install packages
run: npm install
- name: Compile
run: npm run compile
- name: Run tests
run: npm run test
18 changes: 11 additions & 7 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: Continuous deployment
name: 'CD release'
on:
push:
branches:
- publish
release:
types: [prereleased, released]

env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand All @@ -16,6 +15,11 @@ jobs:
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- run: npm install
- run: npm run compile
- run: npm publish --workspaces --access public
- name: Install packages
run: npm install
- name: Compile
run: npm run compile
- name: Run tests
run: npm run test
- name: Publish package
run: npm publish --workspaces --access public
31 changes: 28 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,37 @@
# Cere DDC SDK for JavaScript

## Packages

- [content-addressable-storage](packages/content-addressable-storage/README.md)
- [key-value-storage](packages/key-value-storage/README.md)
- [file-storage](packages/file-storage/README.md)
- [proto](packages/proto/README.md)
- [core](packages/core/README.md)

## Use case

- `content-addressable-storage` use when need simple upload data to DDC as 1 unit
- `key-value-storage` use when need store data by key
- `file-storage` use when need to upload large data by chunks

## Definitions

- `DDC` - decentralized data cloud, product of cerebellum network for storing data
- `piece` - abstraction which represents a unit of data stored in the DDC.
Doesn't have fixed size and can represent fully logically completed data or part of it.

## Dependencies

- protobuf compiler (`protoc`) for compiling *.proto model files.
- typescript `4.5.5+`

## Compilation

To compile the code in bulk:

```shell
npm run compile -ws
```
- clone repository
- download required modules ```npm install```
- compile files ```npm run compile```

## Testing

Expand Down
70 changes: 70 additions & 0 deletions docker-compose/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
version: "3"

services:
ddc-cdn-node:
container_name: "ddc-cdn-node"
image: 'cerebellumnetwork/ddc-gateway-node:dev-latest'
environment:
- 'HTTP_PORT=8080'
- 'HTTP_ADDRESS=http://localhost:8080'
- 'LOG_LEVEL=debug'
- 'LOG_JSON_FORMAT=false'
- 'TEST_ENABLED=true'
ports:
- '8080:8080'
healthcheck:
test: wget --no-verbose --tries=1 --spider http://localhost:8080/info || exit 1
interval: 3s
timeout: 1s
retries: 5

ddc-storage-node-0:
container_name: "ddc-storage-node-0"
image: 'cerebellumnetwork/ddc-storage-node:dev-latest'
environment:
- 'HTTP_PORT=8090'
- 'HTTP_ADDRESS=http://localhost:8090'
- 'LOG_LEVEL=info'
- 'LOG_JSON_FORMAT=false'
- 'TEST_ENABLED=true'
ports:
- '8090:8090'
healthcheck:
test: wget --no-verbose --tries=1 --spider http://localhost:8090/info || exit 1
interval: 3s
timeout: 1s
retries: 5

ddc-storage-node-1:
container_name: "ddc-storage-node-1"
image: 'cerebellumnetwork/ddc-storage-node:dev-latest'
environment:
- 'HTTP_PORT=8091'
- 'HTTP_ADDRESS=http://localhost:8091'
- 'LOG_LEVEL=info'
- 'LOG_JSON_FORMAT=false'
- 'TEST_ENABLED=true'
ports:
- '8091:8091'
healthcheck:
test: wget --no-verbose --tries=1 --spider http://localhost:8091/info || exit 1
interval: 3s
timeout: 1s
retries: 5

ddc-storage-node-2:
container_name: "ddc-storage-node-2"
image: 'cerebellumnetwork/ddc-storage-node:dev-latest'
environment:
- 'HTTP_PORT=8092'
- 'HTTP_ADDRESS=http://localhost:8092'
- 'LOG_LEVEL=info'
- 'LOG_JSON_FORMAT=false'
- 'TEST_ENABLED=true'
ports:
- '8092:8092'
healthcheck:
test: wget --no-verbose --tries=1 --spider http://localhost:8092/info || exit 1
interval: 3s
timeout: 1s
retries: 5
10 changes: 9 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,16 @@ module.exports = {
"jest.config.js",
"/node_modules/",
"/build/",
"/dist/"
],
testPathIgnorePatterns: [
"/node_modules/",
"/build/",
"/dist/"
],
moduleNameMapper: {
'^@cere-ddc-sdk/(.*)$': '<rootDir>/packages/$1/'
}
},
globalSetup: "./jest.setup.js",
globalTeardown: "./jest.teardown.js",
};
14 changes: 14 additions & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const {DockerComposeEnvironment, Wait} = require("testcontainers");
const {composeFilePath, composeFile} = require("./jest.variables");

module.exports = async function (globalConfig) {
console.log(`Start ${composeFilePath}/${composeFile}`);
globalThis.__DOCKER_COMPOSE__ = await new DockerComposeEnvironment(composeFilePath, composeFile)
.withWaitStrategy("ddc-cdn-node", Wait.forHealthCheck())
.withWaitStrategy("ddc-storage-node-0", Wait.forHealthCheck())
.withWaitStrategy("ddc-storage-node-1", Wait.forHealthCheck())
.withWaitStrategy("ddc-storage-node-2", Wait.forHealthCheck())
.up();

console.log(`Docker-compose is UP`);
};
7 changes: 7 additions & 0 deletions jest.teardown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const {composeFilePath, composeFile} = require("./jest.variables");

module.exports = async function (globalConfig) {
console.log(`Stop ${composeFilePath}/${composeFile}`);
await globalThis.__DOCKER_COMPOSE__.down();
console.log(`Docker-compose is DOWN`);
};
4 changes: 4 additions & 0 deletions jest.variables.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const path = require("path");

module.exports.composeFilePath = path.resolve("docker-compose");
module.exports.composeFile = "docker-compose.yml";
Loading

0 comments on commit 919d4f5

Please sign in to comment.