diff --git a/.ci/ansible_tests.py b/.ci/ansible_tests.py index 01a012f5..0d67c3b2 100755 --- a/.ci/ansible_tests.py +++ b/.ci/ansible_tests.py @@ -14,7 +14,8 @@ import ci_lib TEMPLATES_DIR = os.path.join(ci_lib.GIT_ROOT, 'tests/ansible/templates') TESTS_DIR = os.path.join(ci_lib.GIT_ROOT, 'tests/ansible') -HOSTS_DIR = os.path.join(ci_lib.TMP, 'hosts') +TMP = ci_lib.TempDir(prefix='mitogen_ci_ansible') +TMP_HOSTS_DIR = os.path.join(TMP.path, 'hosts') def pause_if_interactive(): @@ -43,10 +44,10 @@ with ci_lib.Fold('job_setup'): os.chmod(ci_lib.TESTS_SSH_PRIVATE_KEY_FILE, int('0600', 8)) os.chdir(TESTS_DIR) - ci_lib.run("mkdir %s", HOSTS_DIR) + os.mkdir(TMP_HOSTS_DIR) for path in glob.glob(TESTS_DIR + '/hosts/*'): if not path.endswith('default.hosts'): - ci_lib.run("ln -s %s %s", path, HOSTS_DIR) + os.symlink(path, os.path.join(TMP_HOSTS_DIR, os.path.basename(path))) distros = collections.defaultdict(list) families = collections.defaultdict(list) @@ -60,7 +61,7 @@ with ci_lib.Fold('job_setup'): trim_blocks=True, # Remove first newline after a block ) inventory_template = jinja_env.get_template('test-targets.j2') - inventory_path = os.path.join(HOSTS_DIR, 'target') + inventory_path = os.path.join(TMP_HOSTS_DIR, 'test-targets.ini') with open(inventory_path, 'w') as fp: fp.write(inventory_template.render( @@ -75,7 +76,8 @@ with ci_lib.Fold('ansible'): playbook = os.environ.get('PLAYBOOK', 'all.yml') try: ci_lib.run('./run_ansible_playbook.py %s -i "%s" %s', - playbook, HOSTS_DIR, ' '.join(sys.argv[1:])) + playbook, TMP_HOSTS_DIR, ' '.join(sys.argv[1:]), + ) except: pause_if_interactive() raise diff --git a/.ci/ci_lib.py b/.ci/ci_lib.py index b0c9c04a..b37472a2 100644 --- a/.ci/ci_lib.py +++ b/.ci/ci_lib.py @@ -179,8 +179,8 @@ def exists_in_path(progname): class TempDir(object): - def __init__(self): - self.path = tempfile.mkdtemp(prefix='mitogen_ci_lib') + def __init__(self, prefix='mitogen_ci_lib'): + self.path = tempfile.mkdtemp(prefix=prefix) atexit.register(self.destroy) def destroy(self, rmtree=shutil.rmtree): @@ -193,9 +193,6 @@ class Fold(object): def __exit__(self, _1, _2, _3): pass -TMP = TempDir().path - - os.environ['PYTHONDONTWRITEBYTECODE'] = 'x' os.environ['PYTHONPATH'] = '%s:%s' % ( os.environ.get('PYTHONPATH', ''), diff --git a/.ci/debops_common_tests.py b/.ci/debops_common_tests.py index b9b0030c..6fd50124 100755 --- a/.ci/debops_common_tests.py +++ b/.ci/debops_common_tests.py @@ -6,7 +6,8 @@ import sys import ci_lib -project_dir = os.path.join(ci_lib.TMP, 'project') +TMP = ci_lib.TempDir(prefix='mitogen_ci_debops') +project_dir = os.path.join(TMP.path, 'project') vars_path = 'ansible/inventory/group_vars/debops_all_hosts.yml' inventory_path = 'ansible/inventory/hosts' docker_hostname = ci_lib.get_docker_hostname() diff --git a/docs/changelog.rst b/docs/changelog.rst index 1fbee883..ba4a608b 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -25,6 +25,7 @@ In progress (unreleased) * :gh:issue:`1238` packaging: Avoid :py:mod:`ast`, requires Python = 2.6 * :gh:issue:`1118` CI: Statically specify test usernames and group names * :gh:issue:`1118` CI: Don't copy SSH private key to temporary dir +* :gh:issue:`1118` CI: Don't share temporary directory between test groupings v0.3.22 (2025-02-04)