Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/validate-pubnub-yml.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: validate-pubnub-yml

# Controls when the action will run. Workflow runs when manually triggered using the UI
# or API.
on: [push]

jobs:
build:
name: Validate PubNub yml
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: Install dependencies
run: |
npm install [email protected]
npm install [email protected]
npm install [email protected]
npm install [email protected]
- name: Validate
run: GITHUB_TOKEN=${{ secrets.GH_TOKEN }} node ./.github/workflows/validate-yml.js
94 changes: 94 additions & 0 deletions .github/workflows/validate-yml.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
const YAML = require('yaml')
const Ajv = require('ajv');
const fetch = require('node-fetch');
const fs = require('fs');
const chalk = require('chalk');

const ghToken = process.env.GITHUB_TOKEN;
const ghHeaders = {'User-Agent': 'sdk-bot', 'Authorization': 'token ' + ghToken,'Accept': 'application/vnd.github.v3.raw'};

const sdkReposJSONBranch = "develop";
let sdkReposJSONPath = "http://api.github.com/repos/pubnub/documentation-resources/contents/website-common/tools/build/sdk-repos.json?ref=" + sdkReposJSONBranch;
startExecution(sdkReposJSONPath);

async function startExecution(sdkReposJSONPath){
var sdkRepos = await requestGetFromGithub(sdkReposJSONPath);
var sdkReposAndFeatureMappingArray = parseReposAndFeatureMapping(sdkRepos);
var schemaText = await requestGetFromGithub(sdkReposAndFeatureMappingArray[2]);

schema = JSON.parse(schemaText);
var yaml = fs.readFileSync(".pubnub.yml", 'utf8');

if(yaml != null){
yml = YAML.parse(yaml);
var ajv = new Ajv({schemaId: 'id', "verbose":true, "allErrors": true});
const validate = ajv.compile(schema);
const valid = validate(yml);
if (validate.errors!= null) {
console.log(chalk.cyan("==================================="));
console.log(chalk.red(yml["version"] + " validation errors..."));
console.log(chalk.cyan("==================================="));
console.log(validate.errors);
console.log(chalk.cyan("==================================="));
var result = {code:1, repo: yml["version"], msg: "validation errors"};
printResult(result);
process.exit(1);
}
else {
var result = {code: 0, repo: yml["version"], msg: "validation pass"};
printResult(result);
}
} else {
var result = {code:1, repo: "yml null", msg: "validation errors"};
printResult(result);
process.exit(1);
}
}

function printResult(result){
var str = result.repo + ", " + result.msg;
if(result.code === 0){
console.log(chalk.green(str) + ", Code: " + result.code);
} else {
console.log(chalk.red(str) + ", Code: " + result.code);
}
}

async function requestGetFromGithub(url){
try {
const response = await fetch(url, {
headers: ghHeaders,
method: 'get',
});
if(response.status == 200){
const json = await response.text();
return json;
} else {
console.error(chalk.red("res.status: " + response.status + "\n URL: " + url));
return null;
}

} catch (error) {
console.error(chalk.red("requestGetFromGithub: " + error + "\n URL: " + url));
return null;
}
}

function parseReposAndFeatureMapping(body){
if(body != null){
var sdkRepos = JSON.parse(body);
var locations = sdkRepos["locations"];
if(locations!=null){
var sdkURLs = locations["sdks"];
var featureMappingURL = locations["featureMapping"];
var pubnubYAMLSchemaURL = locations["pubnubYAMLSchema"];
return [sdkURLs, featureMappingURL, pubnubYAMLSchemaURL];
} else {
console.log(chalk.red("response locations null"));
return null;
}
} else {
console.log(chalk.red("response body null"));
return null;
}
}
168 changes: 168 additions & 0 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
---
name: eon-map
scm: https://github.com/pubnub/eon-map
version: "1.2.2"
schema: 1
files:
- ./eon-map.js
changelog:
- version: 1.2.2
date: 2017-07-08
changes:
- type: improvement
text: "Remove bad error checks."
- version: 1.2.1
date: 2017-07-08
changes:
- type: bug
text: "Fix require path for `mapbox.js`."
- type: improvement
text: "Add channels / groups verifications."
- type: improvement
text: "Add default map zoom and center location."
- version: 1.2.0
date: 2017-07-07
changes:
- type: improvement
text: "Move from Bower builds to Webpack"
- type: improvement
text: "Update keys used by demos."
- version: 1.1.4
date: 2017-06-02
changes:
- type: bug
text: "Fix mapbox dependency."
- version: 1.1.3
date: 2017-06-02
changes:
- type: improvement
text: "Update mapbox to v3"
- version: 1.1.1
date: 2017-06-02
changes:
- type: feature
text: "Add Leaflet Mutant plugin to display baselayers using mutation observers."
- version: 1.1.0
date: 2017-06-02
changes:
- type: feature
text: "Add Google maps support."
features:
channel-groups:
- CHANNEL-GROUPS-LIST-CHANNELS-IN-GROUP
storage:
- STORAGE-INCLUDE-TIMETOKEN
- STORAGE-COUNT
- STORAGE-FETCH-MESSAGES
subscribe:
- SUBSCRIBE-CHANNELS
- SUBSCRIBE-CHANNEL-GROUPS
- SUBSCRIBE-PUBSUB-V2
sdks:
- full-name: EON Maps Framework
short-name: EON Maps
artifacts:
- artifact-type: framework
language: JavaScript
tier: 3
tags:
- Web
source-repository: https://github.com/pubnub/eon-map
documentation: https://www.pubnub.com/developers/eon
distributions:
- distribution-type: source

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be api-client

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Distribution type? Usually it is package, source

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Source is not there in the enum (and source is equivalent to api-client)

                    "api-client",                         "library",                         "package",                        "application",                        "framework"

Copy link
Author

@parfeon parfeon May 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where?

"distribution-type": {
                        "type": "string",
                        "description" : "The type of the distribution. e.g. package"
                      },

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check artifact-type, I will double check if we need the same enum here as well

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But you left comment on distribution type (or GitHub app for phone is buggy)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ya I mentioned it on distribution type, and it should use the same enums from artifact-type. (I will double check though)

distribution-repository: GitHub release
package-name: EON Maps Framework
location: https://github.com/pubnub/eon-map/releases/tag/1.2.2
supported-platforms:
supported-browsers:
minimun-supported-version:
- Safari 10.0
- Mozilla Firefox 51.0
- Google Chrome 56.0
- Opera 41.0
- Microsoft Edge 38
requires:
- name: google-maps
min-version: 3.2.1
max-version: 3.3.0
location: Shipped within framework
license: MIT
license-url: https://github.com/davidkudera/google-maps-loader/blob/master/LICENSE
is-required: Required
- name: leaflet
min-version: 1.0.3
max-version: 1.7.1
location: Shipped within framework
license: BSD-2-Clause
license-url: https://github.com/Leaflet/Leaflet/blob/master/LICENSE
is-required: Required
- name: leaflet.gridlayer.googlemutant
min-version: 0.6.2
max-version: 0.6.4
location: Shipped within framework
license: Beerware
license-url: https://gitlab.com/IvanSanchez/Leaflet.GridLayer.GoogleMutant/-/blob/master/LICENSE
is-required: Required
- name: mapbox.js
min-version: 3.1.1
max-version: 3.3.1
location: Shipped within framework
license: BSD-3-Clause
license-url: https://github.com/mapbox/mapbox.js/blob/publisher-production/LICENSE.md
is-required: Required
- name: pubnub
min-version: 4.0.13
max-version: 4.32.0
location: Shipped within framework
license: MIT
license-url: https://github.com/pubnub/javascript/blob/master/LICENSE
is-required: Required
- distribution-type: package
distribution-repository: NPM
package-name: EON Maps Framework
location: https://www.npmjs.com/package/eon-map
supported-platforms:
supported-browsers:
minimun-supported-version:
- Safari 10.0
- Mozilla Firefox 51.0
- Google Chrome 56.0
- Opera 41.0
- Microsoft Edge 38
requires:
- name: google-maps
min-version: 3.2.1
max-version: 3.3.0
location: Shipped within framework
license: MIT
license-url: https://github.com/davidkudera/google-maps-loader/blob/master/LICENSE
is-required: Required
- name: leaflet
min-version: 1.0.3
max-version: 1.7.1
location: Shipped within framework
license: BSD-2-Clause
license-url: https://github.com/Leaflet/Leaflet/blob/master/LICENSE
is-required: Required
- name: leaflet.gridlayer.googlemutant
min-version: 0.6.2
max-version: 0.6.4
location: Shipped within framework
license: Beerware
license-url: https://gitlab.com/IvanSanchez/Leaflet.GridLayer.GoogleMutant/-/blob/master/LICENSE
is-required: Required
- name: mapbox.js
min-version: 3.1.1
max-version: 3.3.1
location: Shipped within framework
license: BSD-3-Clause
license-url: https://github.com/mapbox/mapbox.js/blob/publisher-production/LICENSE.md
is-required: Required
- name: pubnub
min-version: 4.0.13
max-version: 4.32.0
location: Shipped within framework
license: MIT
license-url: https://github.com/pubnub/javascript/blob/master/LICENSE
is-required: Required