mirror of
https://gitlab.com/Thoscellen/Wallset.git
synced 2025-05-31 19:04:51 +02:00
Merge branch 'cicd' into 'main'
Détecte si un thème est déjà présent See merge request Thoscellen/Wallset!6
This commit is contained in:
commit
4d394dc080
@ -1,6 +1,5 @@
|
||||
include:
|
||||
- .gitlab/valid_set.yml
|
||||
- .gitlab/missing_tag_set.yml
|
||||
- .gitlab/*.yml
|
||||
|
||||
stages:
|
||||
- Manifest
|
32
.gitlab/existing_valid_theme_set.yml
Normal file
32
.gitlab/existing_valid_theme_set.yml
Normal file
@ -0,0 +1,32 @@
|
||||
manifest-job/existing_valid_theme_set:
|
||||
variables:
|
||||
PACKAGE_NAME: "existing_valid_theme_set"
|
||||
extends: .manifest-job
|
||||
|
||||
test-images-job/existing_valid_theme_set:
|
||||
needs:
|
||||
- manifest-job/existing_valid_theme_set
|
||||
variables:
|
||||
PACKAGE_NAME: "existing_valid_theme_set"
|
||||
extends: .test-job
|
||||
|
||||
bundle-job/existing_valid_theme_set:
|
||||
needs:
|
||||
- manifest-job/existing_valid_theme_set
|
||||
variables:
|
||||
PACKAGE_NAME: "existing_valid_theme_set"
|
||||
extends: .bundle-job
|
||||
|
||||
upload-job/existing_valid_theme_set:
|
||||
needs:
|
||||
- bundle-job/existing_valid_theme_set
|
||||
variables:
|
||||
PACKAGE_NAME: "existing_valid_theme_set"
|
||||
extends: .upload-job
|
||||
|
||||
release-job/existing_valid_theme_set:
|
||||
needs:
|
||||
- upload-job/existing_valid_theme_set
|
||||
variables:
|
||||
PACKAGE_NAME: "existing_valid_theme_set"
|
||||
extends: .release-job
|
32
.gitlab/unbalanced_set.yml
Normal file
32
.gitlab/unbalanced_set.yml
Normal file
@ -0,0 +1,32 @@
|
||||
manifest-job/unbalanced_set:
|
||||
variables:
|
||||
PACKAGE_NAME: "unbalanced_set"
|
||||
extends: .manifest-job
|
||||
|
||||
test-images-job/unbalanced_set:
|
||||
needs:
|
||||
- manifest-job/unbalanced_set
|
||||
variables:
|
||||
PACKAGE_NAME: "unbalanced_set"
|
||||
extends: .test-job
|
||||
|
||||
bundle-job/unbalanced_set:
|
||||
needs:
|
||||
- manifest-job/unbalanced_set
|
||||
variables:
|
||||
PACKAGE_NAME: "unbalanced_set"
|
||||
extends: .bundle-job
|
||||
|
||||
upload-job/unbalanced_set:
|
||||
needs:
|
||||
- bundle-job/unbalanced_set
|
||||
variables:
|
||||
PACKAGE_NAME: "unbalanced_set"
|
||||
extends: .upload-job
|
||||
|
||||
release-job/unbalanced_set:
|
||||
needs:
|
||||
- upload-job/unbalanced_set
|
||||
variables:
|
||||
PACKAGE_NAME: "unbalanced_set"
|
||||
extends: .release-job
|
55
.vscode/launch.json
vendored
55
.vscode/launch.json
vendored
@ -56,5 +56,60 @@
|
||||
},
|
||||
"justMyCode": true
|
||||
},
|
||||
{
|
||||
"name": "Gen-Manifest existing_valid_theme_set",
|
||||
"cwd": "${workspaceFolder}/src",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"runtimeExecutable": "npm",
|
||||
"runtimeArgs": [
|
||||
"run",
|
||||
"start"
|
||||
],
|
||||
"env": {
|
||||
"ENTRY_FOLDER": "${workspaceFolder}/test",
|
||||
"PACKAGE_NAME": "existing_valid_theme_set"
|
||||
},
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "Test-Manifest existing_valid_theme_set",
|
||||
"cwd": "${workspaceFolder}/src",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"runtimeExecutable": "npm",
|
||||
"runtimeArgs": [
|
||||
"run",
|
||||
"test"
|
||||
],
|
||||
"env": {
|
||||
"ENTRY_FOLDER": "${workspaceFolder}/test",
|
||||
"PACKAGE_NAME": "existing_valid_theme_set"
|
||||
},
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "Test-Images existing_valid_theme_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": "existing_valid_theme_set"
|
||||
},
|
||||
"justMyCode": true
|
||||
},
|
||||
]
|
||||
}
|
@ -1,18 +1,23 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const iptc = require("node-iptc");
|
||||
const { exit } = require("process");
|
||||
|
||||
|
||||
// find all images
|
||||
// Fetch envs to target the right folder
|
||||
const slug = process.env["PACKAGE_NAME"];
|
||||
const root = process.env["ENTRY_FOLDER"];
|
||||
if (!slug || !root) exit(1);
|
||||
let workingDirectory = path.join(root, slug);
|
||||
|
||||
// extract metadata from them
|
||||
fs.readdir(workingDirectory, (err, files) => {
|
||||
if (err) { throw err };
|
||||
if (err) { throw err }; // If IO error, exit with an error message
|
||||
|
||||
// construct a JSON file
|
||||
// If there is already a theme.json silentely exit and let mocha running afterwards
|
||||
if (files.find(file => path.extname(file) == '.json')) exit(0);
|
||||
|
||||
// construct a JSON object
|
||||
let theme = new Object();
|
||||
theme.dayImageList = [];
|
||||
theme.nightImageList = [];
|
||||
@ -63,7 +68,7 @@ fs.readdir(workingDirectory, (err, files) => {
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
// make it the theme.json
|
||||
fs.writeFileSync(path.join(workingDirectory, 'theme.json'), JSON.stringify(theme));
|
||||
});
|
||||
|
||||
|
@ -7,7 +7,7 @@ import os
|
||||
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):
|
||||
image_pattern = theme_config.get("imageFilename")
|
||||
image_filenames = {}.fromkeys(glob.glob(str(Path(working_path, image_pattern))))
|
||||
# generate an image statistics for each images
|
||||
@ -15,6 +15,7 @@ def validate_brightness_image(working_path, theme_config, high_light, image_list
|
||||
this_image = Image.open(an_imagefile).convert("L")
|
||||
this_image_stats = ImageStat.Stat(this_image)
|
||||
image_filenames[an_imagefile] = this_image_stats.mean[0]
|
||||
#print(f'{an_imagefile} : {image_filenames[an_imagefile]}')
|
||||
|
||||
# get the brightest observed image from the list
|
||||
if high_light == "dayHighlight":
|
||||
@ -54,11 +55,11 @@ def manifest(working_path):
|
||||
|
||||
|
||||
def test_brightest_image(working_path, manifest):
|
||||
validate_brightness_image(working_path, manifest, "dayHighlight", "dayImageList", "Brightest")
|
||||
_validate_brightness_image(working_path, manifest, "dayHighlight", "dayImageList", "Brightest")
|
||||
|
||||
|
||||
def test_darkest_image(working_path, manifest):
|
||||
validate_brightness_image(working_path, manifest, "nightHighlight", "nightImageList", "Darkest")
|
||||
_validate_brightness_image(working_path, manifest, "nightHighlight", "nightImageList", "Darkest")
|
||||
|
||||
|
||||
def test_image_size(working_path, manifest):
|
||||
|
BIN
test/existing_valid_theme_set/stray__1.jpg
Normal file
BIN
test/existing_valid_theme_set/stray__1.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 346 KiB |
BIN
test/existing_valid_theme_set/stray__2.jpg
Normal file
BIN
test/existing_valid_theme_set/stray__2.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 422 KiB |
13
test/existing_valid_theme_set/theme.json
Normal file
13
test/existing_valid_theme_set/theme.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"dayImageList": [
|
||||
1
|
||||
],
|
||||
"nightImageList": [
|
||||
2
|
||||
],
|
||||
"sunsetImageList": [],
|
||||
"sunriseImageList": [],
|
||||
"imageFilename": "stray__*.jpg",
|
||||
"imageCredits": "©Thoscellen, ©BlueTwelve",
|
||||
"displayName": "Stray"
|
||||
}
|
BIN
test/unbalanced_set/unbalanced_set_1.jpg
Normal file
BIN
test/unbalanced_set/unbalanced_set_1.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 71 KiB |
BIN
test/unbalanced_set/unbalanced_set_2.jpg
Normal file
BIN
test/unbalanced_set/unbalanced_set_2.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 191 KiB |
BIN
test/unbalanced_set/unbalanced_set_3.jpg
Normal file
BIN
test/unbalanced_set/unbalanced_set_3.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 158 KiB |
Loading…
x
Reference in New Issue
Block a user