mirror of
https://gitlab.com/Thoscellen/Wallset.git
synced 2025-05-31 19:04:51 +02:00
Compare commits
6 Commits
main
...
valid_set.
Author | SHA1 | Date | |
---|---|---|---|
|
5c4b1e769c | ||
|
3487e5da0b | ||
|
0f093d4359 | ||
|
84b696b411 | ||
9941fa7bac | |||
|
5d4770dfe1 |
165
.gitlab/.gitlab-ci.yml
Normal file
165
.gitlab/.gitlab-ci.yml
Normal file
@ -0,0 +1,165 @@
|
||||
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
|
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"conventionalCommits.scopes": [
|
||||
"cicd"
|
||||
]
|
||||
}
|
@ -46,8 +46,8 @@ def validate_brightness_image(working_path, theme_config, high_light, image_list
|
||||
@pytest.fixture
|
||||
def working_path():
|
||||
# get the global variables containing gitlab-given project slug.
|
||||
project_slug = os.environ["WPP_SLUG"]
|
||||
root_folder = os.environ["WPP_ROOT"]
|
||||
project_slug = os.environ["PACKAGE_NAME"]
|
||||
root_folder = os.environ["ENTRY_FOLDER"]
|
||||
working_path = Path(root_folder, project_slug)
|
||||
if not working_path.is_dir():
|
||||
raise FileNotFoundError(f"No project found for the given {working_path}.")
|
||||
@ -76,7 +76,6 @@ def test_image_size(working_path, manifest):
|
||||
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")
|
||||
jointed_lists.extend(manifest.get("nightImageList"))
|
||||
|
@ -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,29 +47,29 @@ 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`
|
||||
`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);
|
||||
});
|
||||
|
BIN
test/missing_tag_set/bl3_landscape_1.jpg
Normal file
BIN
test/missing_tag_set/bl3_landscape_1.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 407 KiB |
BIN
test/missing_tag_set/bl3_landscape_2.jpg
Normal file
BIN
test/missing_tag_set/bl3_landscape_2.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 494 KiB |
BIN
test/missing_tag_set/bl3_landscape_3.jpg
Normal file
BIN
test/missing_tag_set/bl3_landscape_3.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 177 KiB |
BIN
test/missing_tag_set/bl3_landscape_4.jpg
Normal file
BIN
test/missing_tag_set/bl3_landscape_4.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 253 KiB |
14
test/missing_tag_set/theme.json
Normal file
14
test/missing_tag_set/theme.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"imageFilename": "bl3_landscape_*.jpg",
|
||||
"imageCredits": "© Gearbox",
|
||||
"displayName": "",
|
||||
"dayImageList": [
|
||||
2
|
||||
],
|
||||
"sunsetImageList": [
|
||||
2
|
||||
],
|
||||
"nightImageList": [
|
||||
3
|
||||
]
|
||||
}
|
4
test/valid_set/description.md
Normal file
4
test/valid_set/description.md
Normal file
@ -0,0 +1,4 @@
|
||||
# some descriptions
|
||||
|
||||
Introducting change for testing.
|
||||
Pipeline still won't trigger.
|
19
test/valid_set/theme.json
Normal file
19
test/valid_set/theme.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"imageFilename": "bl2_eridum_badlands_*.jpg",
|
||||
"imageCredits": "Gearbox",
|
||||
"displayName": "",
|
||||
"dayHighlight": 1,
|
||||
"nightHighlight": 3,
|
||||
"sunriseImageList": [
|
||||
4
|
||||
],
|
||||
"dayImageList": [
|
||||
1
|
||||
],
|
||||
"sunsetImageList": [
|
||||
2
|
||||
],
|
||||
"nightImageList": [
|
||||
3
|
||||
]
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user