Compare commits

..

91 Commits

Author SHA1 Message Date
Simon
26c51d409f Merge branch 'zip-to-ddw' into 'cicd'
feat(#8): Deploy as .ddw files intead of zip

See merge request Thoscellen/Wallset!17
2023-07-15 20:56:35 +00:00
Simon
2c1137b590 feat(#8): Deploy as .ddw files intead of zip 2023-07-15 20:56:35 +00:00
797caf0678 Fixe l'execution de la commande cat 2023-05-18 23:21:58 +02:00
ea9a4a6618 Sépare le dossier d'entrée et le chemin absolu du répertoire de travail dans les script. 2023-05-18 23:21:58 +02:00
1d3c968ad9 Tente un fixe pour la pipeline. 2023-05-18 23:21:58 +02:00
fdaff717b0 Tente un fixe pour la pipeline 2023-05-18 23:21:58 +02:00
bbdf05f4ce Tente un fixe pour la pipeline 2023-05-18 23:21:58 +02:00
845f52ae33 Tente un fixe pour la pipeline. 2023-05-18 23:21:58 +02:00
4bab4c1b8a Inverse l'utilisation d'un glob dans la pipeline. 2023-05-18 23:21:58 +02:00
fba937b0d9 Tente un fixe pour la pipeline. 2023-05-18 23:21:58 +02:00
Simon
a28fea0cc7 Merge branch 'main' into 'cicd' 2023-05-18 23:21:58 +02:00
Simon
e31f02cd38 Merge branch 'cicd' into 'main'
Tente un fixe pour la pipeline.

See merge request Thoscellen/Wallset!9
2023-05-18 21:17:34 +00:00
Simon
123733def0 Tente un fixe pour la pipeline. 2023-05-18 21:17:34 +00:00
b24aa4bb54 Tente un fixe pour la pipeline. 2023-05-18 22:00:06 +02:00
Simon
226a3a3856 Merge branch 'cicd' into 'main'
Règle la CI pour se déclencher après une demande de fusion

See merge request Thoscellen/Wallset!7
2023-05-18 13:15:09 +00:00
Simon
6ec4d836cc Règle la CI pour se déclencher après une demande de fusion 2023-05-18 13:15:09 +00:00
8fe596ecaa Contrôle la CD de bout en bout 2023-05-18 15:04:10 +02:00
2c5b05f01a Règle la CI pour se déclencher après une demande de fusion 2023-05-18 15:04:10 +02:00
bdf91e0957 Déplace le script de déploiement à la racine 2023-05-18 15:04:10 +02:00
4b012e64c4 Fixe un problème de récursion dans la déclaration 2023-05-18 15:04:10 +02:00
528c25e11a Déclare les jobs plus dynamiquement. 2023-05-18 15:04:10 +02:00
82385d1164 Refactorise le script Python avec une convention 2023-05-18 15:04:10 +02:00
f8fa02924c Ajoutes un cas de test de thème validant 2023-05-18 15:04:10 +02:00
dee4a9c037 Fixes un bug empêchant la détection 2023-05-18 15:04:10 +02:00
Simon
530e2763d9 Merge branch 'main' into 'cicd' 2023-05-18 15:04:10 +02:00
Simon
4d394dc080 Merge branch 'cicd' into 'main'
Détecte si un thème est déjà présent

See merge request Thoscellen/Wallset!6
2023-05-18 12:30:10 +00:00
Simon
d541628920 Détecte si un thème est déjà présent 2023-05-18 12:30:10 +00:00
Simon
9d6ddf6e25 Fusionnne les jobs node en un 2023-05-17 22:58:37 +02:00
Simon
e0c1ad7e03 Ecrit le générateur de manifeste 2023-05-17 22:58:26 +02:00
Simon
6fe5481363 Initialise le fichier .gitlab-ci.yml 2023-05-17 22:57:54 +02:00
98878bd6b6 Détecte si un thème est déjà présent
Et ignore sa génération dans ce cas.
2023-05-17 22:21:30 +02:00
9ac05f338b Sépares le set de test missing_tag_set dans une configuration séparée. 2023-05-15 23:04:17 +02:00
54620edeb8 Fixes "unknown keys in extends (upload-job)" 2023-05-15 22:54:47 +02:00
3a2e419d27 Fix "unknown keys in extends (test-job)" 2023-05-15 22:53:52 +02:00
c47f7d4ae8 Introduit un include pour augmenter la lisibilité. 2023-05-15 22:50:45 +02:00
8b72846275 Ajoutes quelques dépendances 2023-05-15 18:12:04 +02:00
4c889c28ce Fixes le chemin utilisé par cat 2023-05-15 17:55:49 +02:00
5f5c28b033 Testes la valeur de $CI_PROJECT_DIR pour cwd. 2023-05-15 17:52:43 +02:00
78d8b60f59 Fixes une typo dans .gitlab-ci.yml 2023-05-14 23:41:24 +02:00
f0e5056de6 Actualises mocha vers la dernière version pour résister aux failles de sécurité 2023-05-14 23:39:47 +02:00
85803e95f1 Fixes les commandes d'execution pour python
Rends git ignorant du cache python
Fixes les commandes d'execution pour python en local
Ajoutes une commande d'execution de la CI selon la branche cicd
2023-05-14 23:39:14 +02:00
f83c6b7988 Supprime le job en doublon. 2023-05-14 21:46:07 +02:00
112b745a45 Ajuste les chemins d'accès relatifs pour le débug local.
WIP: Adapter la configuration pour la CI/CD.
2023-05-14 21:38:53 +02:00
d665e1f12e Actualise les configurations npm et vscode
Launch.json s'appuie sur package.json pour lancer les scripts, en utilisant src/ comme cwd.
Package.json utilise les bonnes conventions pour appeler les modules installés localements.
WIP: L'accès aux jeux de tests ne fonctionne pas encore
2023-05-14 13:36:33 +02:00
1e341a353a Merge branch 'main' of https://gitlab.com/Thoscellen/Wallset into cicd 2023-05-14 12:35:58 +02:00
4c5d5867c7 Fusionne les 2 apps node. 2023-05-14 12:35:40 +02:00
Simon
06f0f40964 Merge branch 'cicd' into 'main'
Ecriture du générateur de manifeste

See merge request Thoscellen/Wallset!4
2023-05-14 09:47:22 +00:00
Simon
5940937f6e Ecriture du générateur de manifeste 2023-05-14 09:47:21 +00:00
5916053780 Merge branch 'main' of https://gitlab.com/Thoscellen/Wallset into cicd 2023-05-14 11:42:57 +02:00
ef9b330685 Permettre au générateur de fournir le theme pour déploiement. 2023-05-13 23:28:23 +02:00
Simon
fc377e3a44 Merge branch 'cicd' into 'main'
Cicd

See merge request Thoscellen/Wallset!3
2023-05-13 20:57:05 +00:00
Simon
2b1714ed9b Cicd 2023-05-13 20:57:05 +00:00
ac38241629 Fixes plusieurs problèmes pour checker le theme.json généré.
Introduit aussi un launch.json pour mes réinstallations futures de VScode.
Supprime la description.md qui fait échouter ce test prévu pour réussir.
2023-05-13 22:54:22 +02:00
8c446eeb4b Fixe numéros mal castés en nombre 2023-05-13 12:35:35 +02:00
6d0a52a5df Fixe "workingDirectory is not defined" 2023-05-13 12:16:42 +02:00
798f6de969 Fixer un problème d'accès aux variables d'environnement
qui étaient fournies par Gitlab mais mal récupérés par node.
2023-05-13 12:00:55 +02:00
afb0e16596 Réduir la verbosité des logs. 2023-05-13 11:36:10 +02:00
ce3ffa7e6a Renforcer l'accès aux variables d'environnement 2023-05-13 10:38:35 +02:00
ff65f260d0 Réexporter les variables gitlab en tant que variables d'environnement bash 2023-05-13 10:34:16 +02:00
a7c5db924d Ajout de logs dans le premier job 2023-05-13 10:28:03 +02:00
16abe31b34 Fixe 'expose_as' contenant un caractère interdit 2023-05-13 10:24:06 +02:00
6cae40e2e8 Suppression des slugs par défaut
pour contrôler que les variables d'envs sont bien récupérées.
2023-05-13 10:22:42 +02:00
d32e075d3d Log du theme.json généré dans la CI. 2023-05-13 10:22:08 +02:00
bd71602b0a Ajouter job qui génère le theme.json 2023-05-12 08:32:46 +02:00
774b52e3e8 Ecriture du générateur de manifeste
Fonctionne en local avec le jeu de test valide, mais à besoin d'être ajuster avec:
 - Caster les nombres qui sont encore en string
 - Fluidifier l'execution dans le dossier de travail car le module n'est pas à la racine du projet
 - Améliorer le debugage local tant via npm que via VSCode (Pourquoi le dossier de travail doit être au niveau du package.json?, j'ai besoin de plus de connaissance)
 - Voir pour mieux paralléliser l'extraction des données (boucle forEach séquentiel, je pourrais tirer partie d'un Yield ou Async Await)
2023-05-11 23:08:58 +02:00
b349fe729a Modifications du module wpp_checker 2023-05-10 08:26:31 +02:00
67f2a9f474 Définition du module JS 2023-05-10 08:26:04 +02:00
69ec0da893 Retirer unisité exit module 2023-05-10 07:31:36 +02:00
116aae9465 Merge branch 'main' of https://gitlab.com/Thoscellen/Wallset into cicd 2023-05-10 07:24:45 +02:00
Simon
ed57c7ec28 Merge branch 'main' into 'cicd'
# Conflicts:
#   .gitlab/.gitlab-ci.yml
2023-05-08 14:09:23 +00:00
659237211d [no-ci] wrap-up for merging 2023-05-08 16:07:14 +02:00
933fb8d435 breaking more the theme 2023-05-08 16:03:23 +02:00
910c6bcf2d fix bad references 2023-05-08 15:57:33 +02:00
7a3ea5ad67 add test with invalid data 2023-05-08 15:48:01 +02:00
e815627197 removed orphan file 2023-05-08 15:11:01 +02:00
d234291a5c fix paths in script 2023-05-08 15:08:20 +02:00
f4a46241cd ajouter test-manifest job 2023-05-08 15:04:39 +02:00
6cd74ba294 fix wrong naming in theme.json 2023-05-08 14:18:17 +02:00
b5aeabc813 fix "No project found for the given test/v0.9." 2023-05-08 11:54:39 +02:00
c1a221bd8a Fix passation d'environement. 2023-05-08 11:52:26 +02:00
429acc65c2 update path to module 2023-05-08 11:48:33 +02:00
277a153a90 update path to module 2023-05-08 11:46:21 +02:00
444efdb279 Add a theme.json to help job pass. 2023-05-08 11:41:43 +02:00
70fbe935b6 test(cicd): Introducting images checkpoint 2023-05-08 11:36:51 +02:00
16ae62c21b fix issue with path containing "//" 2023-05-08 11:20:59 +02:00
a5f83748d6 Add dquote to variable 2023-05-08 11:19:47 +02:00
6bb20f6d2d Change description.md file. 2023-05-08 11:18:37 +02:00
2d0e5429df update echo message 2023-05-08 11:13:44 +02:00
3977fc4c13 Trigger the pipeline 2023-05-08 11:03:55 +02:00
4b5ae81dae Made some documentation 2023-05-08 10:56:45 +02:00
03cce7edee test(cicd): Implement new pipe with anchor 2023-05-08 10:48:21 +02:00
27 changed files with 1661 additions and 2157 deletions

10
.gitignore vendored Normal file
View File

@@ -0,0 +1,10 @@
# Ignore node_module
**/node_modules/
# Ignore python stuff
**/__pycache__
**/.pytest_cache
# Ignore les fichiers système de MacOS
**/.DS_Store

107
.gitlab-ci.yml Normal file
View File

@@ -0,0 +1,107 @@
include:
- .gitlab/*.yml
stages:
- Manifest
- Test
- Bundle
- Distribute
- Release
variables:
ENTRY_FOLDER: test # test directory for testing CI/CD, or assets directory for normal operations
RELEASE_VERSION: v0.$CI_PIPELINE_IID
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.
.manifest-job:
stage: Manifest
image: node:latest
rules:
#- if: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME == "cicd"
- if: $CI_COMMIT_TAG
when: never
- changes:
- ${ENTRY_FOLDER}/${PACKAGE_NAME}/*
script:
- cd src/
- npm install
- npm run start
- cat ../${ENTRY_FOLDER}/${PACKAGE_NAME}/theme.json
- npm run test
artifacts:
paths:
- ${ENTRY_FOLDER}/${PACKAGE_NAME}/theme.json
when: on_success
expire_in: "1 hour"
.test-job:
stage: Test
image: python:latest
rules:
#- if: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME == "cicd"
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
changes:
- ${ENTRY_FOLDER}/${PACKAGE_NAME}/*
script:
- pip install -U pytest pillow iteration_utilities
- python -m pytest src/test_images.py --tb=line -rA --color=yes
allow_failure: true
# 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:
stage: Bundle
image: javieraviles/zip:latest
rules:
#- if: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME == "cicd"
- if: $CI_COMMIT_TAG
when: never
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
changes:
- ${ENTRY_FOLDER}/${PACKAGE_NAME}/*
script:
- zip -j ${PACKAGE_NAME}.wdd ${ENTRY_FOLDER}/${PACKAGE_NAME}/*
artifacts:
paths:
- ${PACKAGE_NAME}.ddw
when: on_success
expire_in: "1 hour"
.upload-job:
stage: Distribute
image: curlimages/curl:latest
rules:
#- if: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME == "cicd"
- if: $CI_COMMIT_TAG
when: never
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
changes:
- ${ENTRY_FOLDER}/${PACKAGE_NAME}/*
script:
- |
curl --fail \
--header "JOB-TOKEN: ${CI_JOB_TOKEN}" \
--upload-file ${PACKAGE_NAME}.ddw "${PACKAGE_REGISTRY_URL}/${PACKAGE_NAME}.ddw?select=package_file"
.release-job:
stage: Release
image: registry.gitlab.com/gitlab-org/release-cli:latest
rules:
#- if: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME == "cicd"
- if: $CI_COMMIT_TAG
when: never
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
changes:
- ${ENTRY_FOLDER}/${PACKAGE_NAME}/*
script:
- echo "Releasing assets for $PACKAGE_NAME"
release:
name: "Livrable $PACKAGE_NAME $RELEASE_VERSION"
tag_name: "$PACKAGE_NAME.$RELEASE_VERSION"
description: "Version $RELEASE_VERSION"
ref: "$CI_COMMIT_SHA"
assets:
links:
- name: ${PACKAGE_NAME}.ddw
url: "${PACKAGE_REGISTRY_URL}/${PACKAGE_NAME}.ddw"
link_type: package

View File

@@ -1,165 +0,0 @@
stages:
- Manifest
- Test
- Bundle
- Distribute
- Release
variables:
ENTRY_FOLDER: "test" # test directory for testing CI/CD, or assets directory for normal operations
RELEASE_VERSION: v0.$CI_PIPELINE_IID
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${PACKAGE_NAME}/${RELEASE_VERSION}"
# TODO: to reenable later
# Jobs from here run on Merge Requests as prerequisite for merging.
.manifest-job: &manifest
stage: Manifest
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
changes:
# TODO: refacto this (as Reference or something else)
- ${ENTRY_FOLDER}/${PACKAGE_NAME}/*
script:
- echo generating manifest for ${ENTRY_FOLDER}/${PACKAGE_NAME}
# manifest-job/valid_set:
# variables:
# PACKAGE_NAME: "valid_set"
# <<: *gen-manifest
.test-images-job: &test-images
stage: Test
image: python:latest
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
changes:
- ${ENTRY_FOLDER}/${PACKAGE_NAME}/*
script:
- 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
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
.bundle-job: &bundle
stage: Bundle
image: javieraviles/zip:latest
rules:
- if: $CI_COMMIT_TAG
when: never # Do not run this job when a tag is created manually
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
changes:
- ${ENTRY_FOLDER}/${PACKAGE_NAME}/*
script:
- zip -j ${PACKAGE_NAME}.zip ${ENTRY_FOLDER}/${PACKAGE_NAME}/*
artifacts:
paths:
- ${PACKAGE_NAME}.zip
when: on_success
expire_in: "1 hour"
bundle-job/valid_set:
variables:
PACKAGE_NAME: "valid_set"
<<: *bundle
bundle-job/missing_tag_set:
variables:
PACKAGE_NAME: "missing_tag_set"
<<: *bundle
.upload-job: &upload
stage: Distribute
image: curlimages/curl:latest
rules:
- if: $CI_COMMIT_TAG
when: never # Do not run this job when a tag is created manually
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
changes:
- ${ENTRY_FOLDER}/${PACKAGE_NAME}/*
script:
- |
curl --fail \
--header "JOB-TOKEN: ${CI_JOB_TOKEN}" \
--upload-file ${PACKAGE_NAME}.zip "${PACKAGE_REGISTRY_URL}/${PACKAGE_NAME}.zip?select=package_file"
upload-job/valid_set:
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
image: registry.gitlab.com/gitlab-org/release-cli:latest
rules:
- if: $CI_COMMIT_TAG
when: never # Do not run this job when a tag is created manually
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
changes:
- ${ENTRY_FOLDER}/${PACKAGE_NAME}/*
script:
- echo "Releasing assets for $PACKAGE_NAME"
release:
name: "Release $PACKAGE_NAME $RELEASE_VERSION"
tag_name: "$PACKAGE_NAME.$RELEASE_VERSION"
description: "Version $RELEASE_VERSION"
ref: "$CI_COMMIT_SHA"
assets:
links:
- name: ${PACKAGE_NAME}
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/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

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

View 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

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

121
.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,121 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Gen-Manifest Valid_set",
"cwd": "${workspaceFolder}/src",
"type": "node",
"request": "launch",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run",
"start"
],
"env": {
"CI_PROJECT_DIR": "${workspaceFolder}",
"ENTRY_FOLDER": "test",
"PACKAGE_NAME": "valid_set"
},
"skipFiles": [
"<node_internals>/**"
],
},
{
"name": "Test-Manifest Valid_set",
"cwd": "${workspaceFolder}/src",
"type": "node",
"request": "launch",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run",
"test"
],
"env": {
"CI_PROJECT_DIR": "${workspaceFolder}",
"ENTRY_FOLDER": "test",
"PACKAGE_NAME": "valid_set"
},
"skipFiles": [
"<node_internals>/**"
],
},
{
"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": {
"CI_PROJECT_DIR": "${workspaceFolder}",
"ENTRY_FOLDER": "test",
"PACKAGE_NAME": "valid_set"
},
"justMyCode": true
},
{
"name": "Gen-Manifest existing_valid_theme_set",
"cwd": "${workspaceFolder}/src",
"type": "node",
"request": "launch",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run",
"start"
],
"env": {
"CI_PROJECT_DIR": "${workspaceFolder}",
"ENTRY_FOLDER": "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": {
"CI_PROJECT_DIR": "${workspaceFolder}",
"ENTRY_FOLDER": "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": {
"CI_PROJECT_DIR": "${workspaceFolder}",
"ENTRY_FOLDER": "test",
"PACKAGE_NAME": "existing_valid_theme_set"
},
"justMyCode": true
},
]
}

78
src/build-manifest.js Normal file
View File

@@ -0,0 +1,78 @@
const fs = require("fs");
const path = require("path");
const iptc = require("node-iptc");
const { exit } = require("process");
// Fetch envs to target the right folder
const workDir = process.env["CI_PROJECT_DIR"];
const root = process.env["ENTRY_FOLDER"];
const slug = process.env["PACKAGE_NAME"];
if (!workDir || !slug || !root) exit(1);
let workingDirectory = path.join(workDir, root, slug);
// extract metadata from them
fs.readdir(workingDirectory, (err, files) => {
if (err) { throw err }; // If IO error, exit with an error message
// 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 = [];
theme.sunsetImageList = [];
theme.sunriseImageList = [];
// iterate each files
files.filter(file => path.extname(file) == '.jpg').forEach(image => {
buffer = fs.readFileSync(path.join(workingDirectory, image));
// extract metadata
let metadata = iptc(buffer);
theme.imageFilename ||= metadata.special_instructions + "_*" + path.extname(image);
theme.imageCredits ||= metadata.copyright_notice;
theme.displayName ||= metadata.headline;
// explore categories to find if image is dayHighlight or nightHighlight
metadata.supplemental_categories?.forEach(cat => {
switch (cat) {
case "dayHighlight":
theme.dayHighlight ||= parseInt(metadata.original_transmission_reference);
break;
case "nightHighlight":
theme.nightHighlight ||= parseInt(metadata.original_transmission_reference);
break;
default:
break;
}
});
switch (metadata.category) {
case "day":
theme.dayImageList.push(parseInt(metadata.original_transmission_reference));
break;
case "night":
case "nig":
theme.nightImageList.push(parseInt(metadata.original_transmission_reference));
break;
case "sunset":
case "twilight":
case "twi":
theme.sunsetImageList.push(parseInt(metadata.original_transmission_reference));
break;
case "sunrise":
case "dawn":
case "daw":
theme.sunriseImageList.push(parseInt(metadata.original_transmission_reference));
break;
default:
break;
}
});
// make it the theme.json
fs.writeFileSync(path.join(workingDirectory, 'theme.json'), JSON.stringify(theme));
});

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

@@ -1,19 +1,15 @@
const fs = require("fs");
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 });
require("ajv-errors")(ajv);
//let root, slug;
//let workingDirectory = path.join(root, slug);
//console.log(`👷‍♂️ Working with ${slug} slug.`);
const themeSchemaFile = "src/test_manifest_job/json_theme_schema.jsonc";
let wppManifest;
const themeSchemaFile = "json_theme_schema.jsonc";
let manifest;
let validator;
let files;
let workingDirectory;
function leftOuterJoin(leftArray, rightArray) {
return leftArray.filter(function (el) {
@@ -21,53 +17,55 @@ function leftOuterJoin(leftArray, rightArray) {
}, rightArray);
}
function flatReferences(wppManifest) {
function flatReferences(manifest) {
allImageIds = [
wppManifest.dayHighlight,
wppManifest.nightHighlight,
...wppManifest.dayImageList,
...wppManifest.nightImageList,
...(wppManifest.sunsetImageList || []),
...(wppManifest.sunriseImageList || [])
manifest.dayHighlight,
manifest.nightHighlight,
...manifest.dayImageList,
...manifest.nightImageList,
...(manifest.sunsetImageList || []),
...(manifest.sunriseImageList || [])
];
return allImageIds.filter(el => el !== undefined).map(el => {
return wppManifest.imageFilename.replace("*", el);
return manifest.imageFilename.replace("*", el);
});
}
describe('Mandatory Checks', function () {
before(function () {
slug = env.PACKAGE_NAME;
const workDir = process.env["CI_PROJECT_DIR"];
expect(workDir).to.be.a("string").that.is.not.empty;
const slug = process.env["PACKAGE_NAME"];
expect(slug).to.be.a("string").that.is.not.empty;
root = env.ENTRY_FOLDER;
const root = process.env["ENTRY_FOLDER"];
expect(root).to.be.a("string").that.is.not.empty;
workingDirectory = path.join(root, slug);
workingDirectory = path.join(workDir, root, slug);
files = fs.readdirSync(workingDirectory);
expect(files).to.be.an('array').that.is.not.empty;
validator = ajv.compile(JSON.parse(fs.readFileSync(themeSchemaFile, 'utf8')));
});
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 () {
const isValid = validator(wppManifest);
const isValid = validator(manifest);
if (!isValid) expect.fail(`\n\t${validator.errors.map(el => { return el.message; }).join('\n\t• ')}`);
});
step('There are no missing files', function () {
let references = flatReferences(wppManifest);
let references = flatReferences(manifest);
references.push("theme.json");
missings = leftOuterJoin(references, files);
let 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,);
});
step('There are no orphan files', function () {
let references = flatReferences(wppManifest);
orphans = leftOuterJoin(files.filter(x => x !== "theme.json"), references);
let references = flatReferences(manifest);
let 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);

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
from PIL import Image, ImageStat
# from _pytest.outcomes import skip
from iteration_utilities import duplicates
from pathlib import Path
import json
@@ -8,18 +7,15 @@ import os
import pytest
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
def _validate_brightness_image(working_path, theme_config, high_light, image_list, brightness_way):
image_pattern = theme_config.get("imageFilename")
# if image_filenames is None:
image_filenames = {}.fromkeys(glob.glob(str(Path(working_path, image_pattern))))
# generate an image statistics for each images
for an_imagefile in image_filenames:
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":
@@ -32,7 +28,6 @@ def validate_brightness_image(working_path, theme_config, high_light, image_list
an_image = image_pattern.replace("*", str(theme_config.get(high_light)))
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}."
else:
# if not highlight is given in theme.json, we suppose that brightest images are in the daylist
ref_est_files = []
@@ -40,15 +35,15 @@ def validate_brightness_image(working_path, theme_config, high_light, image_list
an_image = image_pattern.replace('*', str(an_id))
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."
# print(f"✔ {brightness_way} image is {actual_est_image}, as expected.")
@pytest.fixture
def working_path():
# get the global variables containing gitlab-given project slug.
work_directory = os.environ["CI_PROJECT_DIR"]
entry_folder = os.environ["ENTRY_FOLDER"]
project_slug = os.environ["PACKAGE_NAME"]
root_folder = os.environ["ENTRY_FOLDER"]
working_path = Path(root_folder, project_slug)
working_path = Path(work_directory, entry_folder, project_slug)
if not working_path.is_dir():
raise FileNotFoundError(f"No project found for the given {working_path}.")
return working_path
@@ -61,20 +56,18 @@ 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):
image_filename = manifest["imageFilename"].replace("*", str(manifest["dayImageList"][0]))
img = Image.open(Path(working_path, image_filename))
w, h = img.size
w, h = Image.open(Path(working_path, image_filename)).size
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)"
# print(f"✔ Images are big enough ({w}×{h}) and landscape.")
def test_overlapping_images(manifest):
jointed_lists = manifest.get("dayImageList")
@@ -86,5 +79,4 @@ def test_overlapping_images(manifest):
str_dup_refs = [manifest["imageFilename"].replace("*", str(int)) for int in dup_refs]
separator = ", "
assert not dup_refs, f"✖ Some images are referenced twice or more times: {separator.join(str_dup_refs)}."
# print("✔ There is no overlapping references of images in the theme.json.")
assert not dup_refs, f"✖ Some images are referenced twice or more: {separator.join(str_dup_refs)}."

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": "wppchecker",
"version": "1.0.0",
"description": "",
"main": "wppChecker.js",
"scripts": {
"test": "mocha wppChecker.js --require mocha-step --colors"
},
"author": "PtiSimon",
"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"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 346 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 422 KiB

View File

@@ -0,0 +1,13 @@
{
"dayImageList": [
1
],
"imageFilename": "stray__*.jpg",
"nightImageList": [
2
],
"imageCredits": "©Thoscellen, ©BlueTwelve",
"sunriseImageList": [],
"displayName": "Stray",
"sunsetImageList": []
}

View File

@@ -1,7 +1,7 @@
{
"imageFilename": "bl3_landscape_*.jpg",
"displayName": "BL3",
"imageCredits": "© Gearbox",
"displayName": "",
"dayImageList": [
2
],

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

View File

@@ -1,4 +0,0 @@
# some descriptions
Introducting change for testing.
Pipeline still won't trigger.

View File

@@ -1,19 +0,0 @@
{
"imageFilename": "bl2_eridum_badlands_*.jpg",
"imageCredits": "Gearbox",
"displayName": "",
"dayHighlight": 1,
"nightHighlight": 3,
"sunriseImageList": [
4
],
"dayImageList": [
1
],
"sunsetImageList": [
2
],
"nightImageList": [
3
]
}