@dashevo/dapi-grpc 0.21.0-dev.8 → 0.21.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/README.md +109 -0
- package/browser.js +5 -5
- package/clients/core/v0/nodejs/core_protoc.js +3 -0
- package/clients/core/v0/web/core_pb.js +3 -0
- package/clients/platform/v0/nodejs/platform_protoc.js +3 -0
- package/clients/platform/v0/web/platform_pb.js +3 -0
- package/node.js +9 -7
- package/package.json +11 -11
- package/scripts/build.sh +4 -4
- package/test/unit/clients/core/v0/nodejs/CorePromiseClient.spec.js +1 -1
- package/test/unit/clients/platform/v0/nodejs/PlatformPromiseClient.spec.js +1 -1
- package/.editorconfig +0 -9
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -27
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -32
- package/.github/workflows/test_and_release.yml +0 -91
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
+
# [0.21.1](https://github.com/dashevo/dapi-grpc/compare/v0.20.0...v0.21.0) (2021-10-12)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* cannot read properties of undefined (reading 'MethodInfo') ([#152](https://github.com/dashevo/dapi-grpc/pull/152))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# [0.21.0](https://github.com/dashevo/dapi-grpc/compare/v0.20.0...v0.21.0) (2021-10-12)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* support returning of a multiproof ([#127](https://github.com/dashevo/dapi-grpc/issues/127))
|
|
16
|
+
* implement getConsensusParams method ([#126](https://github.com/dashevo/dapi-grpc/issues/126), [#130](https://github.com/dashevo/dapi-grpc/issues/130), [#132](https://github.com/dashevo/dapi-grpc/issues/132), [#134](https://github.com/dashevo/dapi-grpc/issues/134))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
* height type was uint32 instead of int64 ([#123](https://github.com/dashevo/dapi-grpc/issues/123))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### BREAKING CHANGES
|
|
25
|
+
|
|
26
|
+
* `getStoreTreeProof` now returns `StoreTreeProof` message instead of `Buffer`
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
1
30
|
# [0.20.0](https://github.com/dashevo/dapi-grpc/compare/v0.19.0...v0.20.0) (2021-07-08)
|
|
2
31
|
|
|
3
32
|
|
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/dashevo/dapi-grpc/actions/workflows/test_and_release.yml)
|
|
4
4
|
[](https://npmjs.org/package/@dashevo/dapi-grpc)
|
|
5
|
+
[](https://github.com/dashevo/dapi-grpc/releases/latest)
|
|
6
|
+
[](LICENSE)
|
|
5
7
|
|
|
6
8
|
Decentralized API GRPC definition files and generated clients
|
|
7
9
|
|
|
@@ -14,12 +16,119 @@ Decentralized API GRPC definition files and generated clients
|
|
|
14
16
|
|
|
15
17
|
## Install
|
|
16
18
|
|
|
19
|
+
Ensure you have the latest [NodeJS](https://nodejs.org/en/download/) installed.
|
|
20
|
+
|
|
21
|
+
#### From repository
|
|
22
|
+
|
|
23
|
+
Clone the repo:
|
|
24
|
+
|
|
25
|
+
```shell
|
|
26
|
+
git clone https://github.com/dashevo/dapi-grpc
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Install npm packages:
|
|
30
|
+
|
|
31
|
+
```shell
|
|
32
|
+
npm install
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
#### From NPM
|
|
36
|
+
|
|
17
37
|
```sh
|
|
18
38
|
npm install @dashevo/dapi-grpc
|
|
19
39
|
```
|
|
20
40
|
|
|
21
41
|
## Usage
|
|
22
42
|
|
|
43
|
+
Node users are able to access exported elements by requiring them under v0 property.
|
|
44
|
+
|
|
45
|
+
### Core Client
|
|
46
|
+
|
|
47
|
+
Provide a client to perform core request.
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
const {
|
|
51
|
+
v0: {
|
|
52
|
+
CorePromiseClient,
|
|
53
|
+
},
|
|
54
|
+
} = require('@dashevo/dapi-grpc');
|
|
55
|
+
|
|
56
|
+
const client = new CorePromiseClient(url);
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Provided method allow to then perform the request, by passing a specific request parameter (see below example).
|
|
60
|
+
All methods share the same API :
|
|
61
|
+
- First parameter expect a specific request instance of a Request class (such as GetBlockRequest, GetTransactionRequest).
|
|
62
|
+
- Second parameter is optional for metadata object.
|
|
63
|
+
- Third parameter is optional for options.
|
|
64
|
+
|
|
65
|
+
Here is a usage example for requesting a Block by its hash and handling its response :
|
|
66
|
+
|
|
67
|
+
```js
|
|
68
|
+
const {
|
|
69
|
+
v0: {
|
|
70
|
+
CorePromiseClient,
|
|
71
|
+
GetBlockRequest,
|
|
72
|
+
GetBlockResponse,
|
|
73
|
+
},
|
|
74
|
+
} = require('@dashevo/dapi-grpc');
|
|
75
|
+
|
|
76
|
+
const client = new CorePromiseClient(url);
|
|
77
|
+
|
|
78
|
+
async function getBlockByHash(hash, options = {}) {
|
|
79
|
+
const getBlockRequest = new GetBlockRequest();
|
|
80
|
+
getBlockRequest.setHash(hash);
|
|
81
|
+
|
|
82
|
+
const response = await client.getBlock(
|
|
83
|
+
getBlockRequest,
|
|
84
|
+
{},
|
|
85
|
+
options,
|
|
86
|
+
);
|
|
87
|
+
const blockBinaryArray = response.getBlock();
|
|
88
|
+
|
|
89
|
+
return Buffer.from(blockBinaryArray);
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Available methods :
|
|
94
|
+
|
|
95
|
+
- getStatus
|
|
96
|
+
- getBlock
|
|
97
|
+
- broadcastTransaction
|
|
98
|
+
- getTransaction
|
|
99
|
+
- getEstimatedTransactionFee
|
|
100
|
+
- subscribeToBlockHeadersWithChainLocks
|
|
101
|
+
- subscribeToTransactionsWithProofs
|
|
102
|
+
|
|
103
|
+
For streams, such as subscribeToTransactionsWithProofs and subscribeToBlockHeadersWithChainLocks, a [grpc-web stream](https://github.com/grpc/grpc-web) will be returned.
|
|
104
|
+
More info on their usage can be read over their repository.
|
|
105
|
+
|
|
106
|
+
### Platform Client
|
|
107
|
+
|
|
108
|
+
Provide a client to perform platform request.
|
|
109
|
+
Method's API and usage is similar to CorePromiseClient.
|
|
110
|
+
|
|
111
|
+
```js
|
|
112
|
+
const {
|
|
113
|
+
v0: {
|
|
114
|
+
PlatformPromiseClient,
|
|
115
|
+
},
|
|
116
|
+
} = require('@dashevo/dapi-grpc');
|
|
117
|
+
|
|
118
|
+
const client = new PlatformPromiseClient(url);
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Available methods :
|
|
122
|
+
|
|
123
|
+
- broadcastStateTransition
|
|
124
|
+
- getIdentity
|
|
125
|
+
- getDataContract
|
|
126
|
+
- getDocuments
|
|
127
|
+
- getIdentitiesByPublicKeyHashes
|
|
128
|
+
- getIdentityIdsByPublicKeyHashes
|
|
129
|
+
- waitForStateTransitionResult
|
|
130
|
+
- getConsensusParams
|
|
131
|
+
- setProtocolVersion
|
|
23
132
|
|
|
24
133
|
## Maintainer
|
|
25
134
|
|
package/browser.js
CHANGED
|
@@ -2,9 +2,9 @@ const core = require('./clients/core/v0/web/core_grpc_web_pb');
|
|
|
2
2
|
const platform = require('./clients/platform/v0/web/platform_grpc_web_pb');
|
|
3
3
|
|
|
4
4
|
module.exports = {
|
|
5
|
-
v0:
|
|
6
|
-
|
|
7
|
-
core,
|
|
8
|
-
platform,
|
|
9
|
-
|
|
5
|
+
v0: {
|
|
6
|
+
|
|
7
|
+
...core,
|
|
8
|
+
...platform,
|
|
9
|
+
},
|
|
10
10
|
};
|
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* @fileoverview
|
|
4
4
|
* @enhanceable
|
|
5
|
+
* @suppress {missingRequire} reports error on implicit type usages.
|
|
5
6
|
* @suppress {messageConventions} JS Compiler reports an error if a variable or
|
|
6
7
|
* field starts with 'MSG_' and isn't a translatable message.
|
|
7
8
|
* @public
|
|
8
9
|
*/
|
|
9
10
|
// GENERATED CODE -- DO NOT EDIT!
|
|
11
|
+
/* eslint-disable */
|
|
12
|
+
// @ts-nocheck
|
|
10
13
|
|
|
11
14
|
var jspb = require('google-protobuf');
|
|
12
15
|
var goog = jspb;
|
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* @fileoverview
|
|
4
4
|
* @enhanceable
|
|
5
|
+
* @suppress {missingRequire} reports error on implicit type usages.
|
|
5
6
|
* @suppress {messageConventions} JS Compiler reports an error if a variable or
|
|
6
7
|
* field starts with 'MSG_' and isn't a translatable message.
|
|
7
8
|
* @public
|
|
8
9
|
*/
|
|
9
10
|
// GENERATED CODE -- DO NOT EDIT!
|
|
11
|
+
/* eslint-disable */
|
|
12
|
+
// @ts-nocheck
|
|
10
13
|
|
|
11
14
|
var jspb = require('google-protobuf');
|
|
12
15
|
var goog = jspb;
|
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* @fileoverview
|
|
4
4
|
* @enhanceable
|
|
5
|
+
* @suppress {missingRequire} reports error on implicit type usages.
|
|
5
6
|
* @suppress {messageConventions} JS Compiler reports an error if a variable or
|
|
6
7
|
* field starts with 'MSG_' and isn't a translatable message.
|
|
7
8
|
* @public
|
|
8
9
|
*/
|
|
9
10
|
// GENERATED CODE -- DO NOT EDIT!
|
|
11
|
+
/* eslint-disable */
|
|
12
|
+
// @ts-nocheck
|
|
10
13
|
|
|
11
14
|
var jspb = require('google-protobuf');
|
|
12
15
|
var goog = jspb;
|
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* @fileoverview
|
|
4
4
|
* @enhanceable
|
|
5
|
+
* @suppress {missingRequire} reports error on implicit type usages.
|
|
5
6
|
* @suppress {messageConventions} JS Compiler reports an error if a variable or
|
|
6
7
|
* field starts with 'MSG_' and isn't a translatable message.
|
|
7
8
|
* @public
|
|
8
9
|
*/
|
|
9
10
|
// GENERATED CODE -- DO NOT EDIT!
|
|
11
|
+
/* eslint-disable */
|
|
12
|
+
// @ts-nocheck
|
|
10
13
|
|
|
11
14
|
var jspb = require('google-protobuf');
|
|
12
15
|
var goog = jspb;
|
package/node.js
CHANGED
|
@@ -34,13 +34,15 @@ const {
|
|
|
34
34
|
module.exports = {
|
|
35
35
|
getCoreDefinition,
|
|
36
36
|
getPlatformDefinition,
|
|
37
|
-
v0:
|
|
37
|
+
v0: {
|
|
38
38
|
CorePromiseClient,
|
|
39
39
|
PlatformPromiseClient,
|
|
40
|
-
pbjs:
|
|
41
|
-
|
|
42
|
-
pbjsCoreMessages,
|
|
43
|
-
pbjsPlatformMessages,
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
pbjs: {
|
|
41
|
+
|
|
42
|
+
...pbjsCoreMessages,
|
|
43
|
+
...pbjsPlatformMessages,
|
|
44
|
+
},
|
|
45
|
+
...protocCoreMessages,
|
|
46
|
+
...protocPlatformMessages,
|
|
47
|
+
},
|
|
46
48
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dashevo/dapi-grpc",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.4",
|
|
4
4
|
"description": "DAPI GRPC definition file and generated clients",
|
|
5
5
|
"browser": "browser.js",
|
|
6
6
|
"main": "node.js",
|
|
@@ -33,22 +33,22 @@
|
|
|
33
33
|
},
|
|
34
34
|
"homepage": "https://github.com/dashevo/dapi-grpc#readme",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@dashevo/grpc-common": "
|
|
37
|
-
"@grpc/grpc-js": "^1.3.
|
|
36
|
+
"@dashevo/grpc-common": "~0.21.4",
|
|
37
|
+
"@grpc/grpc-js": "^1.3.7",
|
|
38
38
|
"google-protobuf": "^3.12.2",
|
|
39
|
-
"grpc-web": "
|
|
39
|
+
"grpc-web": "1.2.1",
|
|
40
40
|
"protobufjs": "github:jawid-h/protobuf.js#fix/buffer-conversion"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"chai": "^4.
|
|
43
|
+
"chai": "^4.3.4",
|
|
44
44
|
"chai-as-promised": "^7.1.1",
|
|
45
45
|
"dirty-chai": "^2.0.1",
|
|
46
|
-
"eslint": "^
|
|
47
|
-
"eslint-config-airbnb-base": "^
|
|
48
|
-
"eslint-plugin-import": "^2.
|
|
49
|
-
"mocha": "^
|
|
46
|
+
"eslint": "^7.32.0",
|
|
47
|
+
"eslint-config-airbnb-base": "^14.2.1",
|
|
48
|
+
"eslint-plugin-import": "^2.24.2",
|
|
49
|
+
"mocha": "^9.1.2",
|
|
50
50
|
"mocha-sinon": "^2.1.2",
|
|
51
|
-
"sinon": "^
|
|
52
|
-
"sinon-chai": "^3.
|
|
51
|
+
"sinon": "^11.1.2",
|
|
52
|
+
"sinon-chai": "^3.7.0"
|
|
53
53
|
}
|
|
54
54
|
}
|
package/scripts/build.sh
CHANGED
|
@@ -28,7 +28,7 @@ rm -rf "$CORE_WEB_OUT_PATH/*"
|
|
|
28
28
|
docker run -v "$CORE_PROTO_PATH:$CORE_PROTO_PATH" \
|
|
29
29
|
-v "$CORE_WEB_OUT_PATH:$CORE_WEB_OUT_PATH" \
|
|
30
30
|
--rm \
|
|
31
|
-
|
|
31
|
+
dashpay/grpc-web-common \
|
|
32
32
|
protoc -I="$CORE_PROTO_PATH" "core.proto" \
|
|
33
33
|
--js_out="import_style=commonjs:$CORE_WEB_OUT_PATH" \
|
|
34
34
|
--grpc-web_out="import_style=commonjs,mode=grpcwebtext:$CORE_WEB_OUT_PATH"
|
|
@@ -43,7 +43,7 @@ rm -rf "$CORE_CLIENTS_PATH/nodejs/*_pbjs.js"
|
|
|
43
43
|
cp "$CORE_WEB_OUT_PATH/core_pb.js" "$CORE_CLIENTS_PATH/nodejs/core_protoc.js"
|
|
44
44
|
|
|
45
45
|
# Generate node message classes
|
|
46
|
-
|
|
46
|
+
pbjs \
|
|
47
47
|
-t static-module \
|
|
48
48
|
-w commonjs \
|
|
49
49
|
-r core_root \
|
|
@@ -59,7 +59,7 @@ rm -rf "$PLATFORM_WEB_OUT_PATH/*"
|
|
|
59
59
|
docker run -v "$PLATFORM_PROTO_PATH:$PLATFORM_PROTO_PATH" \
|
|
60
60
|
-v "$PLATFORM_WEB_OUT_PATH:$PLATFORM_WEB_OUT_PATH" \
|
|
61
61
|
--rm \
|
|
62
|
-
|
|
62
|
+
dashpay/grpc-web-common \
|
|
63
63
|
protoc -I="$PLATFORM_PROTO_PATH" "platform.proto" \
|
|
64
64
|
--js_out="import_style=commonjs:$PLATFORM_WEB_OUT_PATH" \
|
|
65
65
|
--grpc-web_out="import_style=commonjs,mode=grpcwebtext:$PLATFORM_WEB_OUT_PATH"
|
|
@@ -73,7 +73,7 @@ rm -rf "$PLATFORM_CLIENTS_PATH/nodejs/*_pbjs.js"
|
|
|
73
73
|
|
|
74
74
|
cp "$PLATFORM_WEB_OUT_PATH/platform_pb.js" "$PLATFORM_CLIENTS_PATH/nodejs/platform_protoc.js"
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
pbjs \
|
|
77
77
|
-t static-module \
|
|
78
78
|
-w commonjs \
|
|
79
79
|
-r platform_root \
|
package/.editorconfig
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Bug report
|
|
3
|
-
about: Create a report to help us improve
|
|
4
|
-
title: ''
|
|
5
|
-
labels: 'bug'
|
|
6
|
-
assignees: ''
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
<!--- Provide a general summary of the issue in the Title above -->
|
|
11
|
-
|
|
12
|
-
## Expected Behavior
|
|
13
|
-
<!--- Tell us what should happen -->
|
|
14
|
-
|
|
15
|
-
## Current Behavior
|
|
16
|
-
<!--- Tell us what happens instead of the expected behavior -->
|
|
17
|
-
|
|
18
|
-
## Possible Solution
|
|
19
|
-
<!--- Not obligatory, but suggest a fix/reason for the bug -->
|
|
20
|
-
|
|
21
|
-
## Steps to Reproduce (for bugs)
|
|
22
|
-
<!--- Provide a link to a live example, or an unambiguous set of steps to -->
|
|
23
|
-
<!--- reproduce this bug. Include code to reproduce, if relevant -->
|
|
24
|
-
1.
|
|
25
|
-
2.
|
|
26
|
-
3.
|
|
27
|
-
4.
|
|
28
|
-
|
|
29
|
-
## Context
|
|
30
|
-
<!--- How has this issue affected you? What are you trying to accomplish? -->
|
|
31
|
-
<!--- Providing context helps us come up with a solution that is most useful in the real world -->
|
|
32
|
-
|
|
33
|
-
## Your Environment
|
|
34
|
-
<!--- Include as many relevant details about the environment you experienced the bug in -->
|
|
35
|
-
* Version used:
|
|
36
|
-
* Environment name and version (e.g. Chrome 39, node.js 5.4):
|
|
37
|
-
* Operating System and version (desktop, server, or mobile):
|
|
38
|
-
* Link to your project:
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Feature request
|
|
3
|
-
about: Suggest an idea for this project
|
|
4
|
-
title: ''
|
|
5
|
-
labels: 'enhancement'
|
|
6
|
-
assignees: ''
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
<!--- Provide a general summary of the feature request in the Title above -->
|
|
11
|
-
|
|
12
|
-
## Expected Behavior
|
|
13
|
-
<!--- A clear and concise description of what you want to happen -->
|
|
14
|
-
|
|
15
|
-
## Current Behavior
|
|
16
|
-
<!--- Explain the difference from current behavior -->
|
|
17
|
-
|
|
18
|
-
## Possible Solution
|
|
19
|
-
<!--- Suggest ideas of how to implement the addition or change -->
|
|
20
|
-
|
|
21
|
-
## Alternatives Considered
|
|
22
|
-
<!--- A clear and concise description of any alternative solutions or features you've considered -->
|
|
23
|
-
|
|
24
|
-
## Additional Context
|
|
25
|
-
<!--- Add any other context or screenshots about the feature request here. -->
|
|
26
|
-
|
|
27
|
-
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
<!--- Provide a general summary of your changes in the Title above -->
|
|
2
|
-
<!--- Pull request titles must use the [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/#summary) format -->
|
|
3
|
-
|
|
4
|
-
## Issue being fixed or feature implemented
|
|
5
|
-
<!--- Why is this change required? What problem does it solve? -->
|
|
6
|
-
<!--- If it fixes an open issue, please link to the issue here. -->
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## What was done?
|
|
10
|
-
<!--- Describe your changes in detail -->
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
## How Has This Been Tested?
|
|
14
|
-
<!--- Please describe in detail how you tested your changes. -->
|
|
15
|
-
<!--- Include details of your testing environment, and the tests you ran to -->
|
|
16
|
-
<!--- see how your change affects other areas of the code, etc. -->
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
## Breaking Changes
|
|
20
|
-
<!--- Please describe any breaking changes your code introduces and verify that -->
|
|
21
|
-
<!--- the title includes "!" following the conventional commit type (e.g. "feat!: ..."-->
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
## Checklist:
|
|
25
|
-
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
|
|
26
|
-
- [ ] I have performed a self-review of my own code
|
|
27
|
-
- [ ] I have commented my code, particularly in hard-to-understand areas
|
|
28
|
-
- [ ] I have added or updated relevant unit/integration/functional/e2e tests
|
|
29
|
-
- [ ] I have made corresponding changes to the documentation
|
|
30
|
-
|
|
31
|
-
**For repository code-owners and collaborators only**
|
|
32
|
-
- [ ] I have assigned this pull request to a milestone
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
name: Test and Release
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
workflow_dispatch:
|
|
5
|
-
schedule:
|
|
6
|
-
- cron: '49 */160 * * *'
|
|
7
|
-
release:
|
|
8
|
-
types:
|
|
9
|
-
- published
|
|
10
|
-
pull_request:
|
|
11
|
-
branches:
|
|
12
|
-
- master
|
|
13
|
-
- v[0-9]+.[0-9]+-dev
|
|
14
|
-
|
|
15
|
-
jobs:
|
|
16
|
-
test:
|
|
17
|
-
name: Run DAPI GRPC tests
|
|
18
|
-
runs-on: ubuntu-20.04
|
|
19
|
-
timeout-minutes: 10
|
|
20
|
-
steps:
|
|
21
|
-
- uses: actions/checkout@v2
|
|
22
|
-
|
|
23
|
-
- uses: actions/setup-node@v2
|
|
24
|
-
with:
|
|
25
|
-
node-version: '12'
|
|
26
|
-
|
|
27
|
-
- name: Enable NPM cache
|
|
28
|
-
uses: actions/cache@v2
|
|
29
|
-
with:
|
|
30
|
-
path: '~/.npm'
|
|
31
|
-
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
|
32
|
-
restore-keys: |
|
|
33
|
-
${{ runner.os }}-node-
|
|
34
|
-
|
|
35
|
-
- name: Check NPM package lock version is updated
|
|
36
|
-
uses: dashevo/gh-action-check-package-lock@v1
|
|
37
|
-
|
|
38
|
-
- name: Install NPM dependencies
|
|
39
|
-
run: npm ci
|
|
40
|
-
|
|
41
|
-
- name: Run build
|
|
42
|
-
run: npm run build
|
|
43
|
-
|
|
44
|
-
- name: Run ESLinter
|
|
45
|
-
run: npm run lint
|
|
46
|
-
|
|
47
|
-
- name: Run tests
|
|
48
|
-
run: npm run test
|
|
49
|
-
|
|
50
|
-
release:
|
|
51
|
-
name: Release NPM package
|
|
52
|
-
runs-on: ubuntu-20.04
|
|
53
|
-
needs: test
|
|
54
|
-
if: ${{ github.event_name == 'release' }}
|
|
55
|
-
steps:
|
|
56
|
-
- uses: actions/checkout@v2
|
|
57
|
-
|
|
58
|
-
- name: Check package version matches tag
|
|
59
|
-
uses: geritol/match-tag-to-package-version@0.1.0
|
|
60
|
-
env:
|
|
61
|
-
TAG_PREFIX: refs/tags/v
|
|
62
|
-
|
|
63
|
-
- name: Enable NPM cache
|
|
64
|
-
uses: actions/cache@v2
|
|
65
|
-
with:
|
|
66
|
-
path: '~/.npm'
|
|
67
|
-
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
|
68
|
-
restore-keys: |
|
|
69
|
-
${{ runner.os }}-node-
|
|
70
|
-
|
|
71
|
-
- name: Install NPM dependencies
|
|
72
|
-
run: npm ci
|
|
73
|
-
|
|
74
|
-
- name: Run build
|
|
75
|
-
run: npm run build
|
|
76
|
-
|
|
77
|
-
- name: Set release tag
|
|
78
|
-
uses: actions/github-script@v3
|
|
79
|
-
id: tag
|
|
80
|
-
with:
|
|
81
|
-
result-encoding: string
|
|
82
|
-
script: |
|
|
83
|
-
const tag = context.payload.release.tag_name;
|
|
84
|
-
const [, major, minor] = tag.match(/^v([0-9]+)\.([0-9]+)/);
|
|
85
|
-
return (tag.includes('dev') ? `${major}.${minor}-dev` : 'latest');
|
|
86
|
-
|
|
87
|
-
- name: Publish NPM package
|
|
88
|
-
uses: JS-DevTools/npm-publish@v1
|
|
89
|
-
with:
|
|
90
|
-
token: ${{ secrets.NPM_TOKEN }}
|
|
91
|
-
tag: ${{ steps.tag.outputs.result }}
|