def _copy(self): self._log.info('-' * 50) self._log.info("COPYING") if self._product_type: self._component.build_info.set_product_type(self._product_type) artifacts_dir = get_test_dir(self._manifest, self._component.name) artifacts_url = get_test_url(self._manifest, self._component.name) rotate_dir(artifacts_dir) if self._artifacts_layout: _orig_copystat = shutil.copystat shutil.copystat = lambda x, y, follow_symlinks=True: x for local_path, share_dir in self._artifacts_layout.items(): local_path = pathlib.Path(local_path).resolve() if local_path.is_dir(): shutil.copytree(local_path, artifacts_dir / share_dir, ignore=shutil.ignore_patterns('bin')) elif local_path.is_file(): shutil.copyfile(local_path, artifacts_dir / share_dir) shutil.copystat = _orig_copystat self._log.info(f'Artifacts copied to: {artifacts_dir}') self._log.info(f'Artifacts available by link: {artifacts_url}') else: self._log.info('Nothing to copy') if not self._run_build_config_actions(TestStage.COPY.value): return False return True
def copy_logs_to_share(self): rotate_dir(self.tests_artifacts_dir) print(f'Copy results to {self.tests_artifacts_dir}') # Workaround for copying to samba share on Linux to avoid exceptions while setting Linux permissions. _orig_copystat = shutil.copystat shutil.copystat = lambda x, y, follow_symlinks=True: x shutil.copytree(self.test_results_dir, self.tests_artifacts_dir, ignore=shutil.ignore_patterns('bin')) shutil.copystat = _orig_copystat
def _copy(self): """ Copy 'pack' stage results to share folder :return: None | Exception """ print('-' * 50) self.log.info("COPYING") set_log_file(self.options["LOGS_DIR"] / 'copy.log') branch = 'unknown' commit_id = 'unknown' if self.changed_repo: _, branch, commit_id = self.changed_repo.split(':') elif self.repo_states: for repo in self.repo_states: if repo['trigger']: branch = repo['branch'] commit_id = repo['commit_id'] build_dir = MediaSdkDirectories.get_build_dir( branch, self.build_event, commit_id, self.product_type, self.options["BUILD_TYPE"]) build_root_dir = MediaSdkDirectories.get_root_builds_dir() rotate_dir(build_dir) self.log.info('Copy to %s', build_dir) # Workaround for copying to samba share on Linux # to avoid exceptions while setting Linux permissions. _orig_copystat = shutil.copystat shutil.copystat = lambda x, y, follow_symlinks=True: x shutil.copytree(self.options['PACK_DIR'], build_dir) shutil.copystat = _orig_copystat if not self._run_build_config_actions(Stage.COPY): return False if self.build_state_file.exists(): with self.build_state_file.open() as state: build_state = json.load(state) if build_state['status'] == "PASS": last_build_path = build_dir.relative_to(build_root_dir) last_build_file = build_dir.parent.parent / f'last_build_{self.product_type}' last_build_file.write_text(str(last_build_path)) return True
def _copy(self): """ Copy 'pack' stage results to share folder :return: None | Exception """ self._log.info('-' * 50) self._log.info("COPYING") build_state = {'status': "PASS"} if self._build_state_file.exists(): with self._build_state_file.open() as state: build_state = json.load(state) if build_state['status'] == "FAIL": build_dir = get_build_dir(self._manifest, self._component.name, is_failed=True) build_url = get_build_url(self._manifest, self._component.name, is_failed=True) else: build_dir = get_build_dir(self._manifest, self._component.name) build_url = get_build_url(self._manifest, self._component.name) build_root_dir = get_build_dir(self._manifest, self._component.name, link_type='root') rotate_dir(build_dir) self._log.info('Copy to %s', build_dir) self._log.info('Artifacts are available by: %s', build_url) # Workaround for copying to samba share on Linux # to avoid exceptions while setting Linux permissions. _orig_copystat = shutil.copystat shutil.copystat = lambda x, y, follow_symlinks=True: x shutil.copytree(self._options['PACK_DIR'], build_dir) shutil.copystat = _orig_copystat if not self._run_build_config_actions(Stage.COPY.value): return False if build_state['status'] == "PASS": last_build_path = build_dir.relative_to(build_root_dir) last_build_file = build_dir.parent.parent / f'last_build_{self._component.build_info.product_type}' last_build_file.write_text(str(last_build_path)) return True
def copy_logs_to_share(self): rotate_dir(self.tests_artifacts_dir) print(f'Copy results to {self.tests_artifacts_dir}') print(f'Artifacts are available by: {self.tests_artifacts_url}') # Workaround for copying to samba share on Linux to avoid exceptions while setting Linux permissions. _orig_copystat = shutil.copystat shutil.copystat = lambda x, y, follow_symlinks=True: x shutil.copytree(self.test_results_dir, self.tests_artifacts_dir, ignore=shutil.ignore_patterns('bin')) shutil.copyfile(LOG_PATH, str(self.tests_artifacts_dir / LOG_NAME)) shutil.copyfile( str(self.test_adapter_log_dir / self.test_adapter_log_name), str(self.root_dir / self.test_adapter_log_name)) shutil.copystat = _orig_copystat
def copy(self): """ Copy 'pack' stage results to share folder :return: None | Exception """ _, branch, commit_id = self.changed_repo.split(':') build_dir = MediaSdkDirectories.get_build_dir( branch, self.build_event, commit_id, self.product_type, self.default_options["BUILD_TYPE"]) build_root_dir = MediaSdkDirectories.get_root_builds_dir() rotate_dir(build_dir) self.log.info('Copy to %s', build_dir) # Workaround for copying to samba share on Linux to avoid exceptions while setting Linux permissions. _orig_copystat = shutil.copystat shutil.copystat = lambda x, y, follow_symlinks=True: x shutil.copytree(self.default_options['PACK_DIR'], build_dir) shutil.copystat = _orig_copystat for action in self.actions[Stage.COPY]: action.run() if self.build_state_file.exists(): with self.build_state_file.open() as state: build_state = json.load(state) with (build_dir.parent / f'{self.product_type}_status.json' ).open('w') as build_status: json.dump(build_state, build_status) if build_state['status'] == "PASS": last_build_path = build_dir.relative_to(build_root_dir) with (build_dir.parent.parent / f'last_build_{self.product_type}' ).open('w') as last_build: last_build.write(str(last_build_path))
def _copy(self): """ Copy 'pack' stage results to share folder :return: None | Exception """ print('-' * 50) self._log.info("COPYING") branch = 'unknown' commit_id = 'unknown' if self._changed_repo: repo_name, branch, commit_id = self._changed_repo.split(':') if self._target_branch: branch = self._target_branch if commit_id == 'HEAD': commit_id = ProductState.get_head_revision( self._options['REPOS_DIR'] / repo_name) elif self._repo_states: for repo in self._repo_states.values(): if repo['trigger']: branch = repo['target_branch'] if repo.get( 'target_branch') else repo['branch'] commit_id = repo['commit_id'] elif self._manifest_file: component = self._manifest.get_component(self._product) repo = component.trigger_repository branch = repo.target_branch if repo.target_branch else repo.branch commit_id = repo.revision else: # "--changed-repo" or "--repo-states" arguments are not set, "HEAD" revision and "master" branch are used branch = 'master' commit_id = 'HEAD' build_dir = MediaSdkDirectories.get_build_dir( branch, self._build_event, commit_id, self._product_type, self._options["BUILD_TYPE"], product=self._product) build_url = MediaSdkDirectories.get_build_url( branch, self._build_event, commit_id, self._product_type, self._options["BUILD_TYPE"], product=self._product) build_root_dir = MediaSdkDirectories.get_root_builds_dir() rotate_dir(build_dir) self._log.info('Copy to %s', build_dir) self._log.info('Artifacts are available by: %s', build_url) # Workaround for copying to samba share on Linux # to avoid exceptions while setting Linux permissions. _orig_copystat = shutil.copystat shutil.copystat = lambda x, y, follow_symlinks=True: x shutil.copytree(self._options['PACK_DIR'], build_dir) shutil.copystat = _orig_copystat if not self._run_build_config_actions(Stage.COPY.value): return False if self._build_state_file.exists(): with self._build_state_file.open() as state: build_state = json.load(state) if build_state['status'] == "PASS": last_build_path = build_dir.relative_to(build_root_dir) last_build_file = build_dir.parent.parent / f'last_build_{self._product_type}' last_build_file.write_text(str(last_build_path)) return True