Skip to content

Commit ac5bcef

Browse files
docs: .pubnub.yml updates.
1 parent 06d6336 commit ac5bcef

File tree

3 files changed

+199
-25
lines changed

3 files changed

+199
-25
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: validate-pubnub-yml
2+
3+
# Controls when the action will run. Workflow runs when manually triggered using the UI
4+
# or API.
5+
on: [push]
6+
7+
jobs:
8+
build:
9+
name: Validate PubNub yml
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: Use Node.js
14+
uses: actions/setup-node@v1
15+
with:
16+
node-version: '12.x'
17+
- name: Install dependencies
18+
run: |
19+
npm install [email protected]
20+
npm install [email protected]
21+
npm install [email protected]
22+
npm install [email protected]
23+
- name: Validate
24+
run: GITHUB_TOKEN=${{ secrets.GH_TOKEN }} node ./.github/workflows/validate-yml.js

.github/workflows/validate-yml.js

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
const YAML = require('yaml')
2+
const Ajv = require('ajv');
3+
const fetch = require('node-fetch');
4+
const fs = require('fs');
5+
const chalk = require('chalk');
6+
7+
const ghToken = process.env.GITHUB_TOKEN;
8+
const ghHeaders = {'User-Agent': 'sdk-bot', 'Authorization': 'token ' + ghToken,'Accept': 'application/vnd.github.v3.raw'};
9+
10+
const sdkReposJSONBranch = "develop";
11+
let sdkReposJSONPath = "http://api.github.com/repos/pubnub/documentation-resources/contents/website-common/tools/build/sdk-repos.json?ref=" + sdkReposJSONBranch;
12+
startExecution(sdkReposJSONPath);
13+
14+
async function startExecution(sdkReposJSONPath){
15+
var sdkRepos = await requestGetFromGithub(sdkReposJSONPath);
16+
var sdkReposAndFeatureMappingArray = parseReposAndFeatureMapping(sdkRepos);
17+
var schemaText = await requestGetFromGithub(sdkReposAndFeatureMappingArray[2]);
18+
19+
schema = JSON.parse(schemaText);
20+
var yaml = fs.readFileSync(".pubnub.yml", 'utf8');
21+
22+
if(yaml != null){
23+
yml = YAML.parse(yaml);
24+
var ajv = new Ajv({schemaId: 'id', "verbose":true, "allErrors": true});
25+
const validate = ajv.compile(schema);
26+
const valid = validate(yml);
27+
if (validate.errors!= null) {
28+
console.log(chalk.cyan("==================================="));
29+
console.log(chalk.red(yml["version"] + " validation errors..."));
30+
console.log(chalk.cyan("==================================="));
31+
console.log(validate.errors);
32+
console.log(chalk.cyan("==================================="));
33+
var result = {code:1, repo: yml["version"], msg: "validation errors"};
34+
printResult(result);
35+
process.exit(1);
36+
}
37+
else {
38+
var result = {code: 0, repo: yml["version"], msg: "validation pass"};
39+
printResult(result);
40+
}
41+
} else {
42+
var result = {code:1, repo: "yml null", msg: "validation errors"};
43+
printResult(result);
44+
process.exit(1);
45+
}
46+
}
47+
48+
function printResult(result){
49+
var str = result.repo + ", " + result.msg;
50+
if(result.code === 0){
51+
console.log(chalk.green(str) + ", Code: " + result.code);
52+
} else {
53+
console.log(chalk.red(str) + ", Code: " + result.code);
54+
}
55+
}
56+
57+
async function requestGetFromGithub(url){
58+
try {
59+
const response = await fetch(url, {
60+
headers: ghHeaders,
61+
method: 'get',
62+
});
63+
if(response.status == 200){
64+
const json = await response.text();
65+
return json;
66+
} else {
67+
console.error(chalk.red("res.status: " + response.status + "\n URL: " + url));
68+
return null;
69+
}
70+
71+
} catch (error) {
72+
console.error(chalk.red("requestGetFromGithub: " + error + "\n URL: " + url));
73+
return null;
74+
}
75+
}
76+
77+
function parseReposAndFeatureMapping(body){
78+
if(body != null){
79+
var sdkRepos = JSON.parse(body);
80+
var locations = sdkRepos["locations"];
81+
if(locations!=null){
82+
var sdkURLs = locations["sdks"];
83+
var featureMappingURL = locations["featureMapping"];
84+
var pubnubYAMLSchemaURL = locations["pubnubYAMLSchema"];
85+
return [sdkURLs, featureMappingURL, pubnubYAMLSchemaURL];
86+
} else {
87+
console.log(chalk.red("response locations null"));
88+
return null;
89+
}
90+
} else {
91+
console.log(chalk.red("response body null"));
92+
return null;
93+
}
94+
}

.pubnub.yml

Lines changed: 81 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ changelog:
99
-
1010
text: "BREAKING CHANGE - IV used for encryption is now random by default."
1111
type: improvement
12-
date: Apr 12, 21
12+
date: 2021-04-12
1313
version: v5.0.0
1414
-
1515
changes:
@@ -598,42 +598,70 @@ sdks:
598598
- Mobile
599599
- Game Engine
600600
source-repository: https://github.com/pubnub/unity
601-
documentation: https://www.pubnub.com/docs/unity3d-c-sharp/pubnub-c-sharp-sdk
601+
documentation: https://www.pubnub.com/docs/sdks/unity
602602
distributions:
603603
-
604604
distribution-type: package
605605
distribution-repository: git release
606606
package-name: PubNub.unitypackage
607-
location: https://github.com/pubnub/unity/releases/download/v4.9.0/PubNub.unitypackage
607+
location: https://github.com/pubnub/unity/releases/download/v5.0.0/PubNub.unitypackage
608608
requires:
609609
-
610-
name: "Pathfinding.Serialization.JsonFx"
611-
min-version: ""
612-
license: "MIT"
610+
name: "UnityEditor"
611+
min-version: "2018.4.26f1"
612+
license: "https://unity3d.com/legal"
613+
license-url: "https://unity3d.com/legal"
614+
location: "Should be installed on computer"
615+
is-required: "Required"
616+
-
617+
name: "JSON .NET For Unity"
618+
min-version: "2.0.1"
619+
license: "Unity's standard Unity Asset Store End User License Agreement"
613620
license-url: ""
614621
location: "Shipped within package"
615622
is-required: "Optional, one JSON serialization library is required"
616623
-
617624
name: "PeterO.Cbor"
618625
min-version: ""
619-
license: "MIT"
626+
license: "Creative Commons"
620627
license-url: ""
621628
location: "Shipped within package"
622629
is-required: "Required"
623630
-
624-
name: "Pathfinding.Serialization.JsonFx"
631+
name: "MiniJSON"
625632
min-version: ""
626633
license: "MIT"
627634
license-url: ""
628635
location: "Shipped within package"
629636
is-required: "Optional, one JSON serialization library is required"
630637
-
631-
name: "MiniJSON"
638+
name: "MarkerMetro.Unity.WinLegacy"
639+
min-version: "1.8.0.18"
640+
license: "MIT"
641+
license-url: "https://raw.githubusercontent.com/MarkerMetro/MarkerMetro.Unity.WinLegacy/master/LICENSE"
642+
location: "Shipped within package"
643+
is-required: "Optional, only applicable for Metro"
644+
-
645+
name: "BouncyCastle"
646+
min-version: "1.8.1.0"
647+
license: "MIT"
648+
license-url: ""
649+
location: "Shipped within package"
650+
is-required: "Optional, only applicable for Metro"
651+
-
652+
name: "BouncyCastle.Crypto"
653+
min-version: "1.8.1.0"
654+
license: "MIT"
655+
license-url: ""
656+
location: "Shipped within package"
657+
is-required: "Optional, only applicable for Metro"
658+
-
659+
name: "JsonFx.Json"
632660
min-version: ""
633661
license: "MIT"
634662
license-url: ""
635663
location: "Shipped within package"
636-
is-required: "Optional, one JSON serialization library is required"
664+
is-required: "Optional, only applicable for Metro"
637665
supported-platforms:
638666
supported-operating-systems:
639667
Android:
@@ -663,11 +691,11 @@ sdks:
663691
- .NET Core 2
664692
- .NET 4.x
665693
minimum-os-version:
666-
- iOS 9
694+
- iOS 9.0
667695
maximum-os-version:
668-
- iOS 14
696+
- iOS 14.4.2
669697
target-architecture:
670-
- Universal
698+
- arm64
671699
target-devices:
672700
- iPad
673701
- iPhone
@@ -737,42 +765,70 @@ sdks:
737765
- Mobile
738766
- Game Engine
739767
source-repository: https://github.com/pubnub/unity
740-
documentation: https://www.pubnub.com/docs/unity3d-c-sharp/pubnub-c-sharp-sdk
768+
documentation: https://www.pubnub.com/docs/sdks/unity
741769
distributions:
742770
-
743771
distribution-type: package
744772
distribution-repository: git release
745773
package-name: PubNub.unitypackage
746-
location: https://github.com/pubnub/unity/releases/download/v4.9.0/PubNub.unitypackage
774+
location: https://github.com/pubnub/unity/releases/download/v5.0.0/PubNub.unitypackage
747775
requires:
748776
-
749-
name: "Pathfinding.Serialization.JsonFx"
750-
min-version: ""
751-
license: "MIT"
777+
name: "UnityEditor"
778+
min-version: "2018.4.26f1"
779+
license: "https://unity3d.com/legal"
780+
license-url: "https://unity3d.com/legal"
781+
location: "Should be installed on computer"
782+
is-required: "Required"
783+
-
784+
name: "JSON .NET For Unity"
785+
min-version: "2.0.1"
786+
license: "Unity's standard Unity Asset Store End User License Agreement"
752787
license-url: ""
753788
location: "Shipped within package"
754789
is-required: "Optional, one JSON serialization library is required"
755790
-
756791
name: "PeterO.Cbor"
757792
min-version: ""
758-
license: "MIT"
793+
license: "Creative Commons"
759794
license-url: ""
760795
location: "Shipped within package"
761796
is-required: "Required"
762797
-
763-
name: "Pathfinding.Serialization.JsonFx"
798+
name: "MiniJSON"
764799
min-version: ""
765800
license: "MIT"
766801
license-url: ""
767802
location: "Shipped within package"
768803
is-required: "Optional, one JSON serialization library is required"
769804
-
770-
name: "MiniJSON"
805+
name: "MarkerMetro.Unity.WinLegacy"
806+
min-version: "1.8.0.18"
807+
license: "MIT"
808+
license-url: "https://raw.githubusercontent.com/MarkerMetro/MarkerMetro.Unity.WinLegacy/master/LICENSE"
809+
location: "Shipped within package"
810+
is-required: "Optional, only applicable for Metro"
811+
-
812+
name: "BouncyCastle"
813+
min-version: "1.8.1.0"
814+
license: "MIT"
815+
license-url: ""
816+
location: "Shipped within package"
817+
is-required: "Optional, only applicable for Metro"
818+
-
819+
name: "BouncyCastle.Crypto"
820+
min-version: "1.8.1.0"
821+
license: "MIT"
822+
license-url: ""
823+
location: "Shipped within package"
824+
is-required: "Optional, only applicable for Metro"
825+
-
826+
name: "JsonFx.Json"
771827
min-version: ""
772828
license: "MIT"
773829
license-url: ""
774830
location: "Shipped within package"
775-
is-required: "Optional, one JSON serialization library is required"
831+
is-required: "Optional, only applicable for Metro"
776832
supported-platforms:
777833
supported-operating-systems:
778834
Android:
@@ -802,11 +858,11 @@ sdks:
802858
- .NET Core 2
803859
- .NET 4.x
804860
minimum-os-version:
805-
- iOS 9
861+
- iOS 9.0
806862
maximum-os-version:
807-
- iOS 14
863+
- iOS 14.4.2
808864
target-architecture:
809-
- Universal
865+
- arm64
810866
target-devices:
811867
- iPad
812868
- iPhone

0 commit comments

Comments
 (0)