mirror of
https://gitlab.com/Thoscellen/Wallset.git
synced 2025-05-31 19:04:51 +02:00
ajouter test-manifest job
This commit is contained in:
parent
6cd74ba294
commit
f4a46241cd
@ -43,6 +43,24 @@ test-images-job/valid_set:
|
||||
PACKAGE_NAME: "valid_set"
|
||||
<<: *test-images
|
||||
|
||||
.test-manifest-job: &test-manifest
|
||||
stage: Test
|
||||
image: node:latest
|
||||
rules:
|
||||
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
||||
changes:
|
||||
- ${ENTRY_FOLDER}/${PACKAGE_NAME}/*
|
||||
script:
|
||||
- cd .gitlab/node_job/
|
||||
- npm install ajv ajv-errors mocha mocha-steps chai
|
||||
- cd ../..
|
||||
- node .gitlab/node_job/node_modules/mocha/bin/_mocha --require mocha-steps --colors .gitlab/node_job/wppChecker.js
|
||||
|
||||
test-manifest-job/valid_set:
|
||||
variables:
|
||||
PACKAGE_NAME: "valid_set"
|
||||
<<: *test-manifest
|
||||
|
||||
# Jobs from here run Merged_results or Push/Merge Commits to the main branch. Tag is created on release so no run with tag creation
|
||||
.bundle-job: &bundle
|
||||
stage: Bundle
|
||||
|
@ -3,20 +3,20 @@ const path = require("path");
|
||||
const { env, exit } = require("process");
|
||||
const expect = require("chai").expect;
|
||||
const Ajv = require("ajv").default;
|
||||
const ajv = new Ajv({allErrors: true});
|
||||
const ajv = new Ajv({ allErrors: true });
|
||||
require("ajv-errors")(ajv);
|
||||
|
||||
//let root, slug;
|
||||
//let workingDirectory = path.join(root, slug);
|
||||
//console.log(`👷♂️ Working with ‘${slug}’ slug.`);
|
||||
|
||||
const themeSchemaFile = ".gitlab/node_job/json_theme_schema.jsonc";
|
||||
const themeSchemaFile = "src/test_manifest_job/json_theme_schema.jsonc";
|
||||
let wppManifest;
|
||||
let validator;
|
||||
let files;
|
||||
|
||||
function leftOuterJoin(leftArray, rightArray) {
|
||||
return leftArray.filter(function(el) {
|
||||
return leftArray.filter(function (el) {
|
||||
return this.indexOf(el) < 0;
|
||||
}, rightArray);
|
||||
}
|
||||
@ -35,11 +35,11 @@ function flatReferences(wppManifest) {
|
||||
});
|
||||
}
|
||||
|
||||
describe('Mandatory Checks', function() {
|
||||
before(function() {
|
||||
slug = env.WPP_SLUG;
|
||||
describe('Mandatory Checks', function () {
|
||||
before(function () {
|
||||
slug = env.PACKAGE_NAME;
|
||||
expect(slug).to.be.a("string").that.is.not.empty;
|
||||
root = env.WPP_ROOT;
|
||||
root = env.ENTRY_FOLDER;
|
||||
expect(root).to.be.a("string").that.is.not.empty;
|
||||
workingDirectory = path.join(root, slug);
|
||||
files = fs.readdirSync(workingDirectory);
|
||||
@ -47,30 +47,30 @@ describe('Mandatory Checks', function() {
|
||||
validator = ajv.compile(JSON.parse(fs.readFileSync(themeSchemaFile, 'utf8')));
|
||||
});
|
||||
|
||||
step('Manifest is an existing json file', function() {
|
||||
step('Manifest is an existing json file', function () {
|
||||
wppManifest = JSON.parse(fs.readFileSync(path.join(workingDirectory, "theme.json"), "utf8"));
|
||||
});
|
||||
|
||||
step('Manifest passes the schema', function() {
|
||||
step('Manifest passes the schema', function () {
|
||||
const isValid = validator(wppManifest);
|
||||
if(!isValid) expect.fail(`\n\t• ${validator.errors.map(el => {return el.message;}).join('\n\t• ')}`);
|
||||
if (!isValid) expect.fail(`\n\t• ${validator.errors.map(el => { return el.message; }).join('\n\t• ')}`);
|
||||
});
|
||||
|
||||
step('There are no missing files', function() {
|
||||
step('There are no missing files', function () {
|
||||
let references = flatReferences(wppManifest);
|
||||
references.push("theme.json");
|
||||
missings = leftOuterJoin(references, files);
|
||||
expect(missings,
|
||||
`The following reference${(missings.length > 1)? "s": ""} from theme.json ${(missings.length > 1)? "are": "is"} missing in the pack. Consider adding ${(missings.length > 1)? "them": " it"} to the pack or removing the reference${(missings.length > 1)? "s": ""} from the theme.json:\n\t• ${missings.join('\n\t• ')}\n`
|
||||
).to.be.lengthOf(0, );
|
||||
`The following reference${(missings.length > 1) ? "s" : ""} from theme.json ${(missings.length > 1) ? "are" : "is"} missing in the pack. Consider adding ${(missings.length > 1) ? "them" : " it"} to the pack or removing the reference${(missings.length > 1) ? "s" : ""} from the theme.json:\n\t• ${missings.join('\n\t• ')}\n`
|
||||
).to.be.lengthOf(0,);
|
||||
});
|
||||
|
||||
step('There are no orphan files', function() {
|
||||
step('There are no orphan files', function () {
|
||||
let references = flatReferences(wppManifest);
|
||||
orphans = leftOuterJoin(files.filter(x => x !== "theme.json"), references);
|
||||
expect(orphans,
|
||||
`The following orphan file${(orphans.length > 1)? "s are": " is"} not referenced in this theme.json. Consider removing the file${(orphans.length > 1)? "s": ""} or referencing ${(orphans.length > 1)? "them": "it"} in the theme.json:\n\t• ${orphans.join('\n\t• ')}\n`
|
||||
).to.be.lengthOf(0);
|
||||
`The following orphan file${(orphans.length > 1) ? "s are" : " is"} not referenced in this theme.json. Consider removing the file${(orphans.length > 1) ? "s" : ""} or referencing ${(orphans.length > 1) ? "them" : "it"} in the theme.json:\n\t• ${orphans.join('\n\t• ')}\n`
|
||||
).to.be.lengthOf(0);
|
||||
});
|
||||
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user