def make_actions_deploy_conda(repo_path: pathlib.Path, templates: Environment) -> List[str]: """ Add script to build Conda package and deploy to Anaconda. :param repo_path: Path to the repository root. :param templates: """ old_deploy_file = PathPlus(repo_path / ".ci" / "actions_deploy_conda.sh") old_build_file = PathPlus(repo_path / ".ci" / "actions_build_conda.sh") old_deploy_file.unlink(missing_ok=True) old_build_file.unlink(missing_ok=True) deploy_file = PathPlus(repo_path / ".github" / "actions_deploy_conda.sh") build_file = PathPlus(repo_path / ".github" / "actions_build_conda.sh") deploy_file.parent.maybe_make() build_file.write_clean(templates.get_template(build_file.name).render()) build_file.make_executable() deploy_file.write_clean(templates.get_template(deploy_file.name).render()) deploy_file.make_executable() return [ build_file.relative_to(repo_path).as_posix(), old_build_file.relative_to(repo_path).as_posix(), deploy_file.relative_to(repo_path).as_posix(), old_deploy_file.relative_to(repo_path).as_posix(), ]
def make_lint_roller(repo_path: pathlib.Path, templates: Environment) -> List[str]: """ Add the lint_roller.sh script to the desired repo. :param repo_path: Path to the repository root. :param templates: """ lint_roller = templates.get_template("lint_roller._sh") lint_file = PathPlus(repo_path / "lint_roller.sh") lint_file.write_clean(lint_roller.render()) lint_file.make_executable() return [lint_file.name]
def test_make_executable(): with TemporaryDirectory() as tmpdir: tempfile = pathlib.Path(tmpdir) / "tmpfile.sh" tempfile.touch() paths.make_executable(tempfile) assert os.access(tempfile, os.X_OK) with TemporaryDirectory() as tmpdir: tempfile = pathlib.Path(tmpdir) / "tmpfile.sh" tempfile.touch() paths.make_executable(str(tempfile)) assert os.access(str(tempfile), os.X_OK) with TemporaryDirectory() as tmpdir: tempfile = PathPlus(tmpdir) / "tmpfile.sh" tempfile.touch() tempfile.make_executable() assert os.access(tempfile, os.X_OK)