ci: Add CI check for Parse Server options definitions (#7955)
This commit is contained in:
21
.github/workflows/ci.yml
vendored
21
.github/workflows/ci.yml
vendored
@@ -70,6 +70,27 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm ci
|
run: npm ci
|
||||||
- run: npm run lint
|
- run: npm run lint
|
||||||
|
check-definitions:
|
||||||
|
name: Check Definitions
|
||||||
|
timeout-minutes: 5
|
||||||
|
runs-on: ubuntu-18.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Use Node.js ${{ matrix.NODE_VERSION }}
|
||||||
|
uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
- name: Cache Node.js modules
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ~/.npm
|
||||||
|
key: ${{ runner.os }}-node-${{ matrix.NODE_VERSION }}-${{ hashFiles('**/package-lock.json') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-node-${{ matrix.NODE_VERSION }}-
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm ci
|
||||||
|
- name: CI Definitions Check
|
||||||
|
run: npm run ci:definitionsCheck
|
||||||
check-circular:
|
check-circular:
|
||||||
name: Circular Dependencies
|
name: Circular Dependencies
|
||||||
timeout-minutes: 5
|
timeout-minutes: 5
|
||||||
|
|||||||
39
ci/definitionsCheck.js
Normal file
39
ci/definitionsCheck.js
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
const fs = require('fs').promises;
|
||||||
|
const { exec } = require('child_process');
|
||||||
|
const core = require('@actions/core');
|
||||||
|
const { nextTick } = require('process');
|
||||||
|
const { AbortController } = require("node-abort-controller");
|
||||||
|
(async () => {
|
||||||
|
const [currentDefinitions, currentDocs] = await Promise.all([
|
||||||
|
fs.readFile('./src/Options/Definitions.js', 'utf8'),
|
||||||
|
fs.readFile('./src/Options/docs.js', 'utf8'),
|
||||||
|
]);
|
||||||
|
exec('npm run definitions');
|
||||||
|
const ac = new AbortController();
|
||||||
|
const { signal } = ac;
|
||||||
|
const watcher = fs.watch('./src/Options/docs.js', {signal});
|
||||||
|
let i = 0;
|
||||||
|
// eslint-disable-next-line
|
||||||
|
for await (const _ of watcher) {
|
||||||
|
i++;
|
||||||
|
if (i === 3) {
|
||||||
|
ac.abort();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await new Promise(resolve => nextTick(resolve));
|
||||||
|
const [newDefinitions, newDocs] = await Promise.all([
|
||||||
|
fs.readFile('./src/Options/Definitions.js', 'utf8'),
|
||||||
|
fs.readFile('./src/Options/docs.js', 'utf8'),
|
||||||
|
]);
|
||||||
|
if (currentDefinitions !== newDefinitions || currentDocs !== newDocs) {
|
||||||
|
console.error(
|
||||||
|
'\x1b[31m%s\x1b[0m',
|
||||||
|
'Definitions files cannot be updated manually. Please update src/Options/index.js then run `npm run definitions` to generate definitions.'
|
||||||
|
);
|
||||||
|
core.error('Definitions files cannot be updated manually. Please update src/Options/index.js then run `npm run definitions` to generate definitions.');
|
||||||
|
process.exit(1);
|
||||||
|
} else {
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
})();
|
||||||
6
package-lock.json
generated
6
package-lock.json
generated
@@ -10272,6 +10272,12 @@
|
|||||||
"integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==",
|
"integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node-abort-controller": {
|
||||||
|
"version": "3.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/node-abort-controller/-/node-abort-controller-3.0.1.tgz",
|
||||||
|
"integrity": "sha512-/ujIVxthRs+7q6hsdjHMaj8hRG9NuWmwrz+JdRwZ14jdFoKSkm+vDsCbF9PLpnSqjaWQJuTmVtcWHNLr+vrOFw==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"node-domexception": {
|
"node-domexception": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
|
||||||
|
|||||||
@@ -99,6 +99,7 @@
|
|||||||
"mongodb-runner": "4.8.1",
|
"mongodb-runner": "4.8.1",
|
||||||
"mongodb-version-list": "1.0.0",
|
"mongodb-version-list": "1.0.0",
|
||||||
"node-fetch": "3.2.10",
|
"node-fetch": "3.2.10",
|
||||||
|
"node-abort-controller": "3.0.1",
|
||||||
"nyc": "15.1.0",
|
"nyc": "15.1.0",
|
||||||
"prettier": "2.0.5",
|
"prettier": "2.0.5",
|
||||||
"semantic-release": "17.4.6",
|
"semantic-release": "17.4.6",
|
||||||
@@ -107,6 +108,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"ci:check": "node ./ci/ciCheck.js",
|
"ci:check": "node ./ci/ciCheck.js",
|
||||||
"ci:checkNodeEngine": "node ./ci/nodeEngineCheck.js",
|
"ci:checkNodeEngine": "node ./ci/nodeEngineCheck.js",
|
||||||
|
"ci:definitionsCheck": "node ./ci/definitionsCheck.js",
|
||||||
"definitions": "node ./resources/buildConfigDefinitions.js && prettier --write 'src/Options/*.js'",
|
"definitions": "node ./resources/buildConfigDefinitions.js && prettier --write 'src/Options/*.js'",
|
||||||
"docs": "jsdoc -c ./jsdoc-conf.json",
|
"docs": "jsdoc -c ./jsdoc-conf.json",
|
||||||
"lint": "flow && eslint --cache ./",
|
"lint": "flow && eslint --cache ./",
|
||||||
|
|||||||
Reference in New Issue
Block a user