2023-02-22 14:15:23 +00:00
|
|
|
import sys
|
|
|
|
import os
|
2023-03-02 15:08:18 +00:00
|
|
|
import pytest as pt
|
2023-02-22 14:15:23 +00:00
|
|
|
from pathlib import Path
|
|
|
|
from ddadevops import *
|
|
|
|
|
|
|
|
# getting the name of the directory
|
|
|
|
# where the this file is present.
|
|
|
|
current = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
|
|
|
|
# Getting the parent directory name
|
|
|
|
# where the current directory is present.
|
|
|
|
parent = os.path.dirname(current)
|
|
|
|
|
|
|
|
# adding the parent directory to
|
|
|
|
# the sys.path.
|
|
|
|
sys.path.append(parent)
|
|
|
|
|
|
|
|
# now we can import the module in the parent
|
|
|
|
# directory.
|
|
|
|
|
|
|
|
from pybuilder.core import task, init, Project
|
|
|
|
from release_mixin import ReleaseMixin, create_release_mixin_config
|
|
|
|
|
|
|
|
MAIN_BRANCH = 'main'
|
2023-02-22 15:19:36 +00:00
|
|
|
STAGE = 'test'
|
|
|
|
PROJECT_ROOT_PATH = '.'
|
|
|
|
MODULE = 'test'
|
|
|
|
BUILD_DIR_NAME = "build_dir"
|
2023-02-22 14:15:23 +00:00
|
|
|
|
|
|
|
class MyBuild(ReleaseMixin):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def initialize(project, CONFIG_FILE):
|
|
|
|
project.build_depends_on('ddadevops>=3.1.2')
|
|
|
|
config = create_release_mixin_config(CONFIG_FILE, MAIN_BRANCH)
|
2023-02-23 13:40:10 +00:00
|
|
|
config.update({'stage': STAGE,
|
|
|
|
'module': MODULE,
|
|
|
|
'project_root_path': PROJECT_ROOT_PATH,
|
|
|
|
'build_dir_name': BUILD_DIR_NAME})
|
2023-02-22 14:15:23 +00:00
|
|
|
build = MyBuild(project, config)
|
|
|
|
return build
|
|
|
|
|
2023-03-02 15:08:18 +00:00
|
|
|
#def test_release_mixin(tmp_path):
|
|
|
|
#
|
|
|
|
# #init
|
|
|
|
# with open(f'test/resources/config.json', 'r') as json_file:
|
|
|
|
# contents = json_file.read()
|
|
|
|
#
|
|
|
|
# CONFIG_FILE = tmp_path / "config.json"
|
|
|
|
# CONFIG_FILE.write_text(contents)
|
|
|
|
#
|
|
|
|
# base_dir = "."
|
|
|
|
# project = Project(base_dir)
|
|
|
|
#
|
|
|
|
# # init
|
|
|
|
# build = initialize(project, CONFIG_FILE)
|
|
|
|
# build.commit_string = "MAJOR bla"
|
|
|
|
# build.init_release()
|
|
|
|
# release_version = build.release_version
|
|
|
|
#
|
|
|
|
# # test
|
|
|
|
# assert "124.0.0" in release_version.get_version_string()
|
|
|
|
#
|
|
|
|
# # init
|
|
|
|
# bump_version = build.bump_version
|
|
|
|
#
|
|
|
|
# # test
|
|
|
|
# assert "124.0.1-SNAPSHOT" in bump_version.get_version_string()
|