Fusionnne les jobs node en un

This commit is contained in:
Simon 2023-05-16 20:20:26 +00:00 committed by Simon
parent e0c1ad7e03
commit 9d6ddf6e25
16 changed files with 1323 additions and 2121 deletions

4
.gitignore vendored
View File

@ -1,3 +1,7 @@
# Ignore node_module # Ignore node_module
**/node_modules/ **/node_modules/
# Ignore python stuff
**/__pycache__
**/.pytest_cache

View File

@ -1,3 +1,7 @@
include:
- .gitlab/valid_set.yml
- .gitlab/missing_tag_set.yml
stages: stages:
- Manifest - Manifest
- Test - Test
@ -6,87 +10,53 @@ stages:
- Release - Release
variables: variables:
ENTRY_FOLDER: "test" # test directory for testing CI/CD, or assets directory for normal operations ENTRY_FOLDER: $CI_PROJECT_DIR/test # test directory for testing CI/CD, or assets directory for normal operations
RELEASE_VERSION: v0.$CI_PIPELINE_IID RELEASE_VERSION: v0.$CI_PIPELINE_IID
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${PACKAGE_NAME}/${RELEASE_VERSION}" PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${PACKAGE_NAME}/${RELEASE_VERSION}"
# Jobs from here run on Merge Requests as prerequisite for merging. # Jobs from here run on Merge Requests as prerequisite for merging.
.manifest-job: &manifest .manifest-job:
stage: Manifest stage: Manifest
image: node:latest image: node:latest
rules: rules:
- if: $CI_COMMIT_TAG - if: $CI_COMMIT_TAG
when: never # Do not run this job when a tag is created manually when: never
- if: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME == "cicd"
- changes: - changes:
- ${ENTRY_FOLDER}/${PACKAGE_NAME}/* - ${ENTRY_FOLDER}/${PACKAGE_NAME}/*
script: script:
- cd src/build_job - cd src/
- npm install - npm install
- npm run start - npm run start
- cat ../../${ENTRY_FOLDER}/${PACKAGE_NAME}/theme.json - cat ${ENTRY_FOLDER}/${PACKAGE_NAME}/theme.json
- npm run test
artifacts: artifacts:
paths: paths:
- ${ENTRY_FOLDER}/${PACKAGE_NAME}/theme.json - ${ENTRY_FOLDER}/${PACKAGE_NAME}/theme.json
when: on_success when: on_success
expire_in: "1 hour" expire_in: "1 hour"
manifest-job/valid_set: .test-job:
variables:
PACKAGE_NAME: "valid_set"
<<: *manifest
.test-images-job: &test-images
stage: Test stage: Test
image: python:latest image: python:latest
rules: rules:
- if: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME == "cicd"
- if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: $CI_PIPELINE_SOURCE == "merge_request_event"
changes: changes:
- ${ENTRY_FOLDER}/${PACKAGE_NAME}/* - ${ENTRY_FOLDER}/${PACKAGE_NAME}/*
script: script:
- pip install -U pytest pillow iteration_utilities - pip install -U pytest pillow iteration_utilities
- python -m pytest src/test_images_job/test_wpp.py --tb=line -rA --color=yes --code-highlight=yes -q - python -m pytest src/test_images.py --tb=line -rA --color=yes
allow_failure: true allow_failure: true
test-images-job/valid_set:
variables:
PACKAGE_NAME: "valid_set"
<<: *test-images
test-images-job/missing_tag_set:
variables:
PACKAGE_NAME: "missing_tag_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 src/test_manifest_job
- npm install ajv ajv-errors mocha mocha-steps chai
- cd ../..
- node src/test_manifest_job/node_modules/mocha/bin/_mocha --require mocha-steps --colors src/test_manifest_job/wpp_checker.js
test-manifest-job/valid_set:
variables:
PACKAGE_NAME: "valid_set"
<<: *test-manifest
test-manifest-job/missing_tag_set:
variables:
PACKAGE_NAME: "missing_tag_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 # 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 .bundle-job:
stage: Bundle stage: Bundle
image: javieraviles/zip:latest image: javieraviles/zip:latest
rules: rules:
- if: $CI_COMMIT_TAG - if: $CI_COMMIT_TAG
when: never # Do not run this job when a tag is created manually when: never
- if: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME == "cicd"
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
changes: changes:
- ${ENTRY_FOLDER}/${PACKAGE_NAME}/* - ${ENTRY_FOLDER}/${PACKAGE_NAME}/*
@ -98,22 +68,12 @@ test-manifest-job/missing_tag_set:
when: on_success when: on_success
expire_in: "1 hour" expire_in: "1 hour"
bundle-job/valid_set: .upload-job:
variables:
PACKAGE_NAME: "valid_set"
<<: *bundle
bundle-job/missing_tag_set:
variables:
PACKAGE_NAME: "missing_tag_set"
<<: *bundle
.upload-job: &upload
stage: Distribute stage: Distribute
image: curlimages/curl:latest image: curlimages/curl:latest
rules: rules:
- if: $CI_COMMIT_TAG - if: $CI_COMMIT_TAG
when: never # Do not run this job when a tag is created manually when: never
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
changes: changes:
- ${ENTRY_FOLDER}/${PACKAGE_NAME}/* - ${ENTRY_FOLDER}/${PACKAGE_NAME}/*
@ -123,26 +83,12 @@ bundle-job/missing_tag_set:
--header "JOB-TOKEN: ${CI_JOB_TOKEN}" \ --header "JOB-TOKEN: ${CI_JOB_TOKEN}" \
--upload-file ${PACKAGE_NAME}.zip "${PACKAGE_REGISTRY_URL}/${PACKAGE_NAME}.zip?select=package_file" --upload-file ${PACKAGE_NAME}.zip "${PACKAGE_REGISTRY_URL}/${PACKAGE_NAME}.zip?select=package_file"
upload-job/valid_set: .release-job:
needs:
- bundle-job/valid_set
variables:
PACKAGE_NAME: "valid_set"
<<: *upload
upload-job/missing_tag_set:
needs:
- bundle-job/missing_tag_set
variables:
PACKAGE_NAME: "missing_tag_set"
<<: *upload
.release-job: &release
stage: Release stage: Release
image: registry.gitlab.com/gitlab-org/release-cli:latest image: registry.gitlab.com/gitlab-org/release-cli:latest
rules: rules:
- if: $CI_COMMIT_TAG - if: $CI_COMMIT_TAG
when: never # Do not run this job when a tag is created manually when: never
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
changes: changes:
- ${ENTRY_FOLDER}/${PACKAGE_NAME}/* - ${ENTRY_FOLDER}/${PACKAGE_NAME}/*
@ -157,17 +103,3 @@ upload-job/missing_tag_set:
links: links:
- name: ${PACKAGE_NAME} - name: ${PACKAGE_NAME}
url: "${PACKAGE_REGISTRY_URL}/${PACKAGE_NAME}.zip" url: "${PACKAGE_REGISTRY_URL}/${PACKAGE_NAME}.zip"
release-job/valid_set:
needs:
- upload-job/valid_set
variables:
PACKAGE_NAME: "valid_set"
<<: *release
release-job/missing_tag_set:
needs:
- upload-job/missing_tag_set
variables:
PACKAGE_NAME: "missing_tag_set"
<<: *release

View File

@ -0,0 +1,32 @@
manifest-job/missing_tag_set:
variables:
PACKAGE_NAME: "missing_tag_set"
extends: .manifest-job
test-images-job/missing_tag_set:
needs:
- manifest-job/missing_tag_set
variables:
PACKAGE_NAME: "missing_tag_set"
extends: .test-job
bundle-job/missing_tag_set:
needs:
- manifest-job/missing_tag_set
variables:
PACKAGE_NAME: "missing_tag_set"
extends: .bundle-job
upload-job/missing_tag_set:
needs:
- bundle-job/missing_tag_set
variables:
PACKAGE_NAME: "missing_tag_set"
extends: .upload-job
release-job/missing_tag_set:
needs:
- upload-job/missing_tag_set
variables:
PACKAGE_NAME: "missing_tag_set"
extends: .release-job

32
.gitlab/valid_set.yml Normal file
View File

@ -0,0 +1,32 @@
manifest-job/valid_set:
variables:
PACKAGE_NAME: "valid_set"
extends: .manifest-job
test-images-job/valid_set:
needs:
- manifest-job/valid_set
variables:
PACKAGE_NAME: "valid_set"
extends: .test-job
bundle-job/valid_set:
needs:
- manifest-job/valid_set
variables:
PACKAGE_NAME: "valid_set"
extends: .bundle-job
upload-job/valid_set:
needs:
- bundle-job/valid_set
variables:
PACKAGE_NAME: "valid_set"
extends: .upload-job
release-job/valid_set:
needs:
- upload-job/valid_set
variables:
PACKAGE_NAME: "valid_set"
extends: .release-job

60
.vscode/launch.json vendored
View File

@ -1,30 +1,60 @@
{ {
// Utilisez IntelliSense pour en savoir plus sur les attributs possibles.
// Pointez pour afficher la description des attributs existants.
// Pour plus d'informations, visitez : https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{ {
"name": "Gen-Manifest Valid_set",
"cwd": "${workspaceFolder}/src",
"type": "node", "type": "node",
"request": "launch", "request": "launch",
"name": "Tester avec Valid_set", "runtimeExecutable": "npm",
"runtimeArgs": [
"run",
"start"
],
"env": {
"ENTRY_FOLDER": "${workspaceFolder}/test",
"PACKAGE_NAME": "valid_set"
},
"skipFiles": [ "skipFiles": [
"<node_internals>/**" "<node_internals>/**"
], ],
"program": "${workspaceFolder}/src/test_manifest_job/node_modules/mocha/bin/_mocha", },
"args": [ {
"${workspaceFolder}/src/test_manifest_job/wpp_checker.js", "name": "Test-Manifest Valid_set",
"--require mocha-steps", "cwd": "${workspaceFolder}/src",
"--colors", "type": "node",
"request": "launch",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run",
"test"
], ],
"env": { "env": {
"ENTRY_FOLDER": "test", "ENTRY_FOLDER": "${workspaceFolder}/test",
"PACKAGE_NAME": "valid_set" "PACKAGE_NAME": "valid_set"
}, },
"internalConsoleOptions": "openOnSessionStart", "skipFiles": [
"console": "integratedTerminal", "<node_internals>/**"
"cwd": "${workspaceFolder}", ],
"autoAttachChildProcesses": true, },
} {
"name": "Test-Images Valid_set",
"cwd": "${workspaceFolder}/src",
"console": "internalConsole",
"type": "python",
"request": "launch",
"module": "pytest",
"args": [
"test_images.py",
"-rA",
"--tb=line",
"--color=yes"
],
"env": {
"ENTRY_FOLDER": "${workspaceFolder}/test",
"PACKAGE_NAME": "valid_set"
},
"justMyCode": true
},
] ]
} }

View File

@ -6,7 +6,7 @@ const iptc = require("node-iptc");
// find all images // find all images
const slug = process.env["PACKAGE_NAME"]; const slug = process.env["PACKAGE_NAME"];
const root = process.env["ENTRY_FOLDER"]; const root = process.env["ENTRY_FOLDER"];
let workingDirectory = path.join("../..", root, slug); let workingDirectory = path.join(root, slug);
// extract metadata from them // extract metadata from them
fs.readdir(workingDirectory, (err, files) => { fs.readdir(workingDirectory, (err, files) => {
@ -22,10 +22,8 @@ fs.readdir(workingDirectory, (err, files) => {
// iterate each files // iterate each files
files.filter(file => path.extname(file) == '.jpg').forEach(image => { files.filter(file => path.extname(file) == '.jpg').forEach(image => {
buffer = fs.readFileSync(path.join(workingDirectory, image)); buffer = fs.readFileSync(path.join(workingDirectory, image));
//if (err) { throw err };
// extract metadata // extract metadata
let metadata = iptc(buffer); let metadata = iptc(buffer);
// fill object
theme.imageFilename ||= metadata.special_instructions + "_*" + path.extname(image); theme.imageFilename ||= metadata.special_instructions + "_*" + path.extname(image);
theme.imageCredits ||= metadata.copyright_notice; theme.imageCredits ||= metadata.copyright_notice;
theme.displayName ||= metadata.headline; theme.displayName ||= metadata.headline;

View File

@ -1,21 +0,0 @@
{
"name": "build_job",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "build_job",
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"node-iptc": "^1.0.5"
}
},
"node_modules/node-iptc": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/node-iptc/-/node-iptc-1.0.5.tgz",
"integrity": "sha512-+e9aVETp/X8iFX2qBw2GnABkq/jGs7dJdxGURZysOdn4ZdOdArPW2a3xQpSq6GX2CcgEzUklDfaC/cg4sLv35g=="
}
}
}

View File

@ -1,14 +0,0 @@
{
"name": "build_job",
"version": "1.0.0",
"description": "Generate a theme.json file from the images' metadata of the working folder.",
"main": "themeset_builder.js",
"scripts": {
"start": "node themeset_builder.js"
},
"author": "Simon",
"license": "ISC",
"dependencies": {
"node-iptc": "^1.0.5"
}
}

View File

@ -0,0 +1,86 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"required": [
"imageFilename",
"imageCredits",
"displayName",
"dayImageList",
"nightImageList"
],
"properties": {
"imageFilename": {
"type": "string"
},
"imageCredits": {
"type": "string"
},
"displayName": {
"type": "string"
},
"dayHighlight": {
"type": "integer",
"minimum": 0
},
"nightHighlight": {
"type": "integer",
"minimum": 0
},
"sunriseImageList": {
"type": "array",
"minItems": 0,
"uniqueItems": true,
"items": {
"type": "integer",
"minimum": 0
}
},
"dayImageList": {
"type": "array",
"minItems": 0,
"uniqueItems": true,
"items": {
"type": "integer",
"minimum": 0
}
},
"sunsetImageList": {
"type": "array",
"minItems": 0,
"uniqueItems": true,
"items": {
"type": "integer",
"minimum": 0
}
},
"nightImageList": {
"type": "array",
"minItems": 0,
"uniqueItems": true,
"items": {
"type": "integer",
"minimum": 0
}
}
},
"errorMessage": {
"required": {
"imageFilename": "The imageFilename property is missing.",
"imageCredits": "The imageCredits property is missing.",
"displayName": "The displayName property is missing.",
"dayImageList": "The dayImageList property is missing.",
"nightImageList": "The nightImageList property is missing."
},
"properties": {
"imageFilename": "The imageFilename property must be of type string.",
"imageCredits": "The imageCredits property must be of type string.",
"displayName": "The displayName property must be of type string.",
"dayHighlight": "The dayHighlight property must be a counting number.",
"nightHighlight": "The nightHighlight property must be a counting number.",
"sunriseImageList": "The sunriseImageList property must be a list of counting numbers.",
"dayImageList": "The dayImageList property must be a list of counting numbers.",
"sunsetImageList": "The sunsetImageList property must be a list of counting numbers.",
"nightImageList": "The nightImageList property must be a list of counting numbers."
}
}
}

View File

@ -5,12 +5,8 @@ const Ajv = require("ajv").default;
const ajv = new Ajv({ allErrors: true }); const ajv = new Ajv({ allErrors: true });
require("ajv-errors")(ajv); require("ajv-errors")(ajv);
//let root, slug; const themeSchemaFile = "json_theme_schema.jsonc";
//let workingDirectory = path.join(root, slug); let manifest;
//console.log(`👷‍♂️ Working with ${slug} slug.`);
const themeSchemaFile = "src/test_manifest_job/json_theme_schema.jsonc";
let wppManifest;
let validator; let validator;
let files; let files;
let workingDirectory; let workingDirectory;
@ -21,17 +17,17 @@ function leftOuterJoin(leftArray, rightArray) {
}, rightArray); }, rightArray);
} }
function flatReferences(wppManifest) { function flatReferences(manifest) {
allImageIds = [ allImageIds = [
wppManifest.dayHighlight, manifest.dayHighlight,
wppManifest.nightHighlight, manifest.nightHighlight,
...wppManifest.dayImageList, ...manifest.dayImageList,
...wppManifest.nightImageList, ...manifest.nightImageList,
...(wppManifest.sunsetImageList || []), ...(manifest.sunsetImageList || []),
...(wppManifest.sunriseImageList || []) ...(manifest.sunriseImageList || [])
]; ];
return allImageIds.filter(el => el !== undefined).map(el => { return allImageIds.filter(el => el !== undefined).map(el => {
return wppManifest.imageFilename.replace("*", el); return manifest.imageFilename.replace("*", el);
}); });
} }
@ -48,16 +44,16 @@ describe('Mandatory Checks', function () {
}); });
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")); manifest = 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); const isValid = validator(manifest);
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); let references = flatReferences(manifest);
references.push("theme.json"); references.push("theme.json");
let missings = leftOuterJoin(references, files); let missings = leftOuterJoin(references, files);
expect(missings, expect(missings,
@ -66,7 +62,7 @@ describe('Mandatory Checks', function () {
}); });
step('There are no orphan files', function () { step('There are no orphan files', function () {
let references = flatReferences(wppManifest); let references = flatReferences(manifest);
let orphans = leftOuterJoin(files.filter(x => x !== "theme.json"), references); let orphans = leftOuterJoin(files.filter(x => x !== "theme.json"), references);
expect(orphans, 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` `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`

1066
src/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

20
src/package.json Normal file
View File

@ -0,0 +1,20 @@
{
"name": "build-manifest",
"version": "1.0.0",
"description": "Generate the manifest file of the project, based on metadata contained in the pictures.",
"main": "build-manifest.js",
"scripts": {
"start": "node build-manifest.js",
"test": "mocha --require mocha-steps --timeout 0 --colors manifest.spec.js"
},
"author": "Simon",
"license": "ISC",
"dependencies": {
"ajv": "^8.5.0",
"ajv-errors": "^3.0.0",
"chai": "^4.3.4",
"mocha": "^10.2.0",
"mocha-steps": "^1.3.0",
"node-iptc": "^1.0.5"
}
}

View File

@ -1,6 +1,5 @@
import glob import glob
from PIL import Image, ImageStat from PIL import Image, ImageStat
# from _pytest.outcomes import skip
from iteration_utilities import duplicates from iteration_utilities import duplicates
from pathlib import Path from pathlib import Path
import json import json
@ -9,12 +8,8 @@ import pytest
def validate_brightness_image(working_path, theme_config, high_light, image_list, brightness_way): def validate_brightness_image(working_path, theme_config, high_light, image_list, brightness_way):
# get a dict<filename:string, mean:int> of all images to scan them
image_pattern = theme_config.get("imageFilename") image_pattern = theme_config.get("imageFilename")
# if image_filenames is None:
image_filenames = {}.fromkeys(glob.glob(str(Path(working_path, image_pattern)))) image_filenames = {}.fromkeys(glob.glob(str(Path(working_path, image_pattern))))
# generate an image statistics for each images # generate an image statistics for each images
for an_imagefile in image_filenames: for an_imagefile in image_filenames:
this_image = Image.open(an_imagefile).convert("L") this_image = Image.open(an_imagefile).convert("L")
@ -32,7 +27,6 @@ def validate_brightness_image(working_path, theme_config, high_light, image_list
an_image = image_pattern.replace("*", str(theme_config.get(high_light))) an_image = image_pattern.replace("*", str(theme_config.get(high_light)))
ref_est_file = str(Path(working_path, an_image)) ref_est_file = str(Path(working_path, an_image))
assert actual_est_image == ref_est_file, f"{brightness_way} image is {actual_est_image}, but the {high_light} image is {ref_est_file}." assert actual_est_image == ref_est_file, f"{brightness_way} image is {actual_est_image}, but the {high_light} image is {ref_est_file}."
else: else:
# if not highlight is given in theme.json, we suppose that brightest images are in the daylist # if not highlight is given in theme.json, we suppose that brightest images are in the daylist
ref_est_files = [] ref_est_files = []
@ -40,7 +34,6 @@ def validate_brightness_image(working_path, theme_config, high_light, image_list
an_image = image_pattern.replace('*', str(an_id)) an_image = image_pattern.replace('*', str(an_id))
ref_est_files.append(str(Path(working_path, an_image))) ref_est_files.append(str(Path(working_path, an_image)))
assert actual_est_image in ref_est_files, f"{brightness_way} image {actual_est_image} was not found in the '{image_list}' attribute." assert actual_est_image in ref_est_files, f"{brightness_way} image {actual_est_image} was not found in the '{image_list}' attribute."
# print(f"✔ {brightness_way} image is {actual_est_image}, as expected.")
@pytest.fixture @pytest.fixture
@ -70,11 +63,9 @@ def test_darkest_image(working_path, manifest):
def test_image_size(working_path, manifest): def test_image_size(working_path, manifest):
image_filename = manifest["imageFilename"].replace("*", str(manifest["dayImageList"][0])) image_filename = manifest["imageFilename"].replace("*", str(manifest["dayImageList"][0]))
img = Image.open(Path(working_path, image_filename)) w, h = Image.open(Path(working_path, image_filename)).size
w, h = img.size
assert w >= 1920 and h >= 1080, f"✖ Image size is too small (must be at least 1920×1080, is {w}×{h})" assert w >= 1920 and h >= 1080, f"✖ Image size is too small (must be at least 1920×1080, is {w}×{h})"
assert w >= h, "✖ Image orientation is portrait (must be landscape or square)" assert w >= h, "✖ Image orientation is portrait (must be landscape or square)"
# print(f"✔ Images are big enough ({w}×{h}) and landscape.")
def test_overlapping_images(manifest): def test_overlapping_images(manifest):
jointed_lists = manifest.get("dayImageList") jointed_lists = manifest.get("dayImageList")
@ -86,5 +77,4 @@ def test_overlapping_images(manifest):
str_dup_refs = [manifest["imageFilename"].replace("*", str(int)) for int in dup_refs] str_dup_refs = [manifest["imageFilename"].replace("*", str(int)) for int in dup_refs]
separator = ", " separator = ", "
assert not dup_refs, f"✖ Some images are referenced twice or more times: {separator.join(str_dup_refs)}." assert not dup_refs, f"✖ Some images are referenced twice or more: {separator.join(str_dup_refs)}."
# print("✔ There is no overlapping references of images in the theme.json.")

View File

@ -1,56 +0,0 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"required": ["imageFilename","imageCredits","displayName","dayImageList","nightImageList"],
"properties": {
"imageFilename": {"type": "string"},
"imageCredits": {"type": "string"},
"displayName": {"type": "string"},
"dayHighlight": {"type": "integer", "minimum": 0},
"nightHighlight": {"type": "integer", "minimum": 0},
"sunriseImageList": {
"type": "array",
"minItems" : 0,
"uniqueItems" : true,
"items": {"type": "integer", "minimum": 0}
},
"dayImageList": {
"type": "array",
"minItems" : 0,
"uniqueItems" : true,
"items": {"type": "integer", "minimum": 0}
},
"sunsetImageList": {
"type": "array",
"minItems" : 0,
"uniqueItems" : true,
"items": {"type": "integer", "minimum": 0}
},
"nightImageList": {
"type": "array",
"minItems" : 0,
"uniqueItems" : true,
"items": {"type": "integer", "minimum": 0}
}
},
"errorMessage": {
"required": {
"imageFilename":"The imageFilename property is missing. Consider adding it.",
"imageCredits":"The imageCredits property is missing. Consider adding it.",
"displayName":"The displayName property is missing. Consider adding it.",
"dayImageList":"The dayImageList property is missing. Consider adding it.",
"nightImageList":"The nightImageList property is missing. Consider adding it."
},
"properties": {
"imageFilename": "The imageFilename property must be of type string and reflect a glob of an image, i.e.: myWallpaper_*.jpg.",
"imageCredits": "The imageCredits property must be of type string.",
"displayName": "The displayName property must be of type string.",
"dayHighlight": "The dayHighlight property must be a counting number referencing an image, i.e.: 5 in myWallpaper_5.jpg.",
"nightHighlight": "The nightHighlight property must be a counting number referencing an image, i.e.: 13 in myWallpaper_13.jpg.",
"sunriseImageList": "The sunriseImageList property must be a list of counting numbers referencing images, i.e.: [1, 2, 3, 4].",
"dayImageList": "The dayImageList property must be a list of counting numbers referencing images, i.e.: [1, 2, 3, 4].",
"sunsetImageList": "The sunsetImageList property must be a list of counting numbers referencing images, i.e.: [1, 2, 3, 4].",
"nightImageList": "The nightImageList property must be a list of counting numbers referencing images, i.e.: [1, 2, 3, 4]."
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,18 +0,0 @@
{
"name": "wpp-checker",
"version": "1.0.0",
"description": "",
"main": "wpp_checker.js",
"scripts": {
"test": "src/test_manifest_job/node_modules/mocha/bin/_mocha --require mocha-steps --colors src/test_manifest_job/wpp_checker.js"
},
"author": "Simon",
"license": "ISC",
"dependencies": {
"ajv": "^8.5.0",
"ajv-errors": "^3.0.0",
"chai": "^4.3.4",
"mocha": "^8.4.0",
"mocha-steps": "^1.3.0"
}
}