Update all CI config

This commit is contained in:
Aurelien Vaillant
2022-02-23 17:35:11 +01:00
parent 3bcee6f017
commit 81f789cc30
9 changed files with 215 additions and 78 deletions
+12 -44
View File
@@ -1,49 +1,17 @@
import json
import os
import docker
import sys
from pathlib import PurePosixPath, Path
from pathlib import Path
from .forge import get_release_file
class ErrorTest(Exception):
""" Failed to generate the test """
def get_b3d_addon_dependency(archive: list):
"""From json resources, get all blender dependency and download-it"""
dependency = Path(os.getcwd(), "tests", "dependency.json")
with open(dependency) as f:
data = json.load(f)
def b3d_launch_blender_test(client: docker = docker.from_env(), test: list = None,
tag: str = 'stilobique/blender:latest'):
"""Launch blender and a list of Test, you can set a specific test file with his arg."""
unit_test_folder = Path(os.getcwd(), "tests", "unit_test")
if os.environ.get('GITHUB_WORKSPACE'):
local_path = os.environ.get('GITHUB_WORKSPACE')
else:
local_path = os.getcwd()
container_folder = '/addon_moderlab'
volume = [f'{local_path}:{container_folder}']
image_name = tag
if test is None:
unit_test = os.listdir(unit_test_folder)
else:
if type(test) is not list:
test = [test]
unit_test = test
try:
for test in unit_test:
print(f'Start this test : {test}')
command = [f"/bin/sh",
f"{PurePosixPath(container_folder, 'tests', 'launch_test.sh')}",
f"{PurePosixPath(container_folder, 'tests', 'unit_test', test)}"]
docker_test = client.containers.run(image_name, command=command, volumes=volume, privileged=True,
environment=[f'FOLDER_TEST={container_folder}'], detach=True, name=test)
exit_docker = docker_test.wait()
if exit_docker['StatusCode'] != 0:
print(f'Container error "{exit_docker["StatusCode"]}".\n\t'
f'Show log : \n\t'
f'{docker_test.logs()}')
raise ErrorTest
except ErrorTest as exception:
print(f'{exception.__doc__}')
sys.exit(1)
b3d_dependency = data['blender']
for key, value in b3d_dependency.items():
get_release_file(value[0], value[1])
archive.append(value[0])