monorepo



The word monorepo is a combination between “mono”, as in the Greek word mónos (in translation, alone) and an abbreviation of the word repository. A simple concept if taken verbatim: one lonely repository. The domain is software engineering so we’re referring to a home for source code, multimedia assets, binary files, and so on. But this definition is just the tip of the iceberg, since a monorepo in practice is so much more.

monorepo这个单词是希腊语mónos (翻译, 单独使用 )中“ mono ”和“ repository”的缩写之间的组合。 一字不漏的简单概念:一个孤独的仓库。 该领域是软件工程,因此我们指的是源代码,多媒体资产,二进制文件等的目录。 但是,这个定义只是冰山一角,因为在实践中,monorepo的意义远不止于此。

In this article I plan to distill the pros and cons of having every piece of code your company owns in the same repository. At the end you should have a good idea about why you should consider working like this, what challenges you’ll face, what problems it’ll solve, and how much you’ll need to invest in it.

在本文中,我计划提炼出贵公司在同一存储库中拥有的每段代码的利弊。 最后,您应该对为什么要考虑像这样工作,将要面临的挑战,将要解决的问题以及需要在其中进行多少投资方面有一个好主意。

The term itself, as visible in the chart above, looks to be as new as 2017. However it would be a mistake to think that previously nobody was storing all of their code in one place. In fact during my first job back in 2009, the company I worked at stored every project in a single SVN repository, one directory per project. Indeed you may well be able to trace this practice back even further. But how can we explain the recent explosive popularity, then?

如上图所示,术语本身看起来像2017年一样新。但是,以为以前没有人将所有代码存储在一个地方是错误的。 实际上,在我2009年的第一份工作中,我所工作的公司将每个项目都存储在一个SVN存储库中,每个项目一个目录。 确实,您也许可以追溯这种做法。 但是,如何解释最近的爆炸式流行呢?

The reality is that storing code in a single spot is not the main selling point. In the past years the major tech companies — Google, Facebook, or Dropbox have been showing off their way of working together within the same repository at massive scale. Organizations of tens of thousands of engineers collaborating within one repository is an awesome sight. And a difficult engineering problem. So difficult in fact that these companies invest a lot of money into tools and systems that allow developers to work productively. These systems in turn have solved problems that you may not even realize you had. This is what fascinates people during tech talks. This is what’s been driving searches since 2017.

现实情况是,将代码存储在单个位置不是主要卖点。 在过去的几年中,主要的科技公司-Google,Facebook或Dropbox一直在炫耀他们在同一个存储库中进行大规模合作的方式。 数以万计的工程师组织在一个存储库中进行协作真是太棒了。 和一个困难的工程问题。 实际上,这些公司是如此困难,以至于这些公司在工具和系统上投入了大量资金,以使开发人员能够高效地工作。 这些系统又解决了您可能根本没有意识到的问题。 这就是在技术讲座中让人着迷的地方。 自2017年以来,这一直在推动搜索。

  • Front-end development at Google, Alex Eagle: https://medium.com/@Jakeherringbone/you-too-can-love-the-monorepo-d95d1d6fcebe

    Google,Alex Eagle的前端开发: https : //medium.com/@Jakeherringbone/you-too-can-love-the-monorepo-d95d1d6fcebe

  • Google monorepo presentation, Rachel Potvin: https://www.youtube.com/watch?v=W71BTkUbdqE

    Google monorepo演示文稿,蕾切尔·波文(Rachel Potvin): https : //www.youtube.com/watch?v= W71BTkUbdqE

  • Scaling Mercurial to the size of Facebook’s codebase, Durham Goode: https://code.fb.com/core-data/scaling-mercurial-at-facebook/

    将Mercurial缩放到Facebook代码库Durham Goode的大小: https : //code.fb.com/core-data/scaling-mercurial-at-facebook/

I’ve identified a few core features that a Google or a Facebook vetted monorepo offers. This is surely not an exhaustive list, but it’s a great starting point. When discussing each of one of these points, I took into consideration what life looks like without them, and what exactly do they solve. Certainly in our field of work everything is a trade-off, nothing’s free. For every pro that I list someone will find use-cases that directly contradict me, butI’m OK with that.

我已经确定了Google或Facebook审核的monorepo提供的一些核心功能。 这当然不是详尽无遗的清单,但这是一个很好的起点。 在讨论这些观点中的每一个时,我都考虑到没有它们,生活会是什么样子,以及它们究竟能解决什么。 当然,在我们的工作领域中,一切都是权衡的,没有免费的。 对于我列出的每个专业人士,都会找到与我直接矛盾的用例,但我对此表示同意。

您所有的代码,无论使用哪种语言,都位于一个存储库中 (All your code, regardless of language, is located in one repository)

The first advantage of storing everything in once place may not be immediately obvious, but as a developer, simply being able to freely browse through everything is of great impact. It helps foster a sort of team spirit and is also a very valuable and cheap way to distribute information. Have you ever asked yourself what projects are in development at your company? Past and present? Curious what a certain team is up to? How have they solved a particular engineering problem? How are they writing unit-tests?

将所有内容存储在一个地方的第一个优点可能不会立即显现出来,但是作为开发人员,简单地能够自由浏览所有内容将产生巨大的影响。 它有助于培养一种团队合作精神,也是一种非常有价值且廉价的信息发布方式。 您是否曾经问过自己公司正在开发哪些项目? 过去和现在? 好奇某个团队在做什么? 他们如何解决特定的工程问题? 他们如何编写单元测试?

In direct opposition to the monorepo we have the multirepo structure. Each project or module gets its own separate space. In such a system developers can spend quite a bit of time getting answers to the questions I listed above. The distributed nature of the work means there’s no single source of information that you can subscribe to.

在直接反对monorepo我们有multirepo结构。 每个项目或模块都有自己的单独空间。 在这样的系统中,开发人员可以花费大量时间来获得我上面列出的问题的答案。 作品的分布式性质意味着您无法订阅任何单一的信息源。

There are companies that have transitioned from a multi to a monorepo layout by following only this feature from my list. Such a structure should not be confused with the topic of this article though. I’d define it instead as a collocated multirepo. Yes, everything is in one place, but the rest of the features on this list are far more interesting.

有些公司仅遵循我列表中的此功能,已从多布局过渡到单仓库布局。 但是,这种结构不应与本文的主题混淆。 我将其定义为并置的multirepo。 是的,所有内容都集中在一个地方,但是此列表中的其余功能则更加有趣。

您能够以受控和显式的方式组织模块之间的依赖关系 (You‘re able to organize dependencies between modules in a controlled and explicit way)

The traditional, battle tested way of handling dependencies is by publishing versions to a separate storage system from continuous integration systems, or even manually, from development machines. These are versioned (or tagged) to make it easier to search later on. Now in a multirepo setup, each project has a set of dependencies of external origins (third parties) or internal, as in, published from inside the same company.

处理依赖关系的传统方法经过了严格的测试,方法是将版本从连续集成系统发布到单独的存储系统,甚至从开发机器发布到单独的存储系统。 这些版本(或标记),以使以后的搜索更加容易。 现在,在多仓库配置中,每个项目都具有一组外部来源(第三方)或内部依赖性,例如从同一家公司内部发布的依赖性。

In order for one team to depend on another one’s code, everything needs to pass through a dependency management storage system. Examples of this are npm, MavenCentral, or PyPi. I said earlier that you can easily build a collocated multirepo just by storing everything in one place. Such a system is indirectly observable. Let’s examine why that’s important.

为了使一个团队能够依赖另一个团队的代码,所有内容都需要通过依赖管理存储系统。 例如npm,MavenCentral或PyPi。 之前我说过,只需将所有内容存储在一个位置即可轻松构建并置的多仓库。 这样的系统是间接可观察到的。 让我们检查一下为什么这很重要。

As developers, our time is split very unequally between reading and writing code. Now imagine having to debug an issue that has its root cause inside of a dependency. We can rule out third parties here, since that’s a difficult problem as it is. No, this problem occurs in a package published by another team in your company. If your project depends on the latest version, you’re in luck! Just navigate to the respective directory and grab a cup of coffee.

作为开发人员,我们在阅读和编写代码之间的时间分配非常不均。 现在想象一下,必须调试其根本原因在依赖项中的问题。 我们可以在这里排除第三方,因为这确实是一个难题。 否,您公司中另一个团队发布的软件包中会出现此问题。 如果您的项目依赖于最新版本,那么您很幸运! 只需导航到相应的目录并获取一杯咖啡即可。

“Indeed, the ratio of time spent reading versus writing is well over 10 to 1. We are constantly reading old code as part of the effort to write new code. …[Therefore,] making it easy to read makes it easier to write.”

“实际上,读与写所花费的时间比例远远超过10:1。作为编写新代码的一部分,我们不断读取旧代码。 …[因此,]使其易于阅读,使其易于书写。”

― Robert C. Martin, Clean Code: A Handbook of Agile Software Craftsmanship

― Robert C. Martin,“ 清洁代码:敏捷软件Craft.io手册”

More often though you might depend on an older version. So now what do you do? Do you try and use your VCS to read through the older code? Do you try and read the actual artifact instead of the original code? What if it’s minified, as is usually the case with JavaScript?

尽管您可能依赖于较旧的版本,但使用频率更高。 那么,现在您该怎么办? 您是否尝试使用VCS来阅读较早的代码? 您是否尝试阅读实际的工件而不是原始代码? 如果将其缩小(通常与JavaScript一样),该怎么办?

Contrast this with Google’s system, for example — since code dependencies are direct, as in, there are essentially no versions anywhere, one can say the system is directly observable. The code you’re looking at is pretty much your entire world. I say mostly because of course there are always going to be minor exceptions to this rule, such as external dependencies that would be prohibitive to host yourself. But that shouldn’t take anything away from this discussion.

例如,将其与Google的系统进行对比-由于代码相关性是直接的,例如在任何地方基本上都没有版本,因此可以说该系统是直接可观察到的 。 您正在查看的代码几乎就是您的整个世界。 我说这主要是因为当然总是会有该规则的次要例外,例如外部依赖关系将禁止您自己托管。 但这不应该脱离讨论。



While we’re on the topic of dependency management we should touch upon the subject of restrictions. Imagine a project where you’re able to depend on any source file you need. Nothing is off limits, you can import anything. For those of you that started their careers at least 10 years ago, this sounds like business as usual for the time. This is an almost complete definition of a monolith.

当我们讨论依赖管理时,我们应该涉及限制的主题。 想象一个项目,您可以在其中依赖所需的任何源文件。 没有任何限制,您可以导入任何内容。 对于至少10年前开始职业生涯的人来说,这听起来像往常一样。 这是一个整体的几乎完整的定义。

The name implies grandeur, scale, but more importantly, singularity. Practically every source file inside of a monolith cannot live outside of it. There’s a fundamental reason for this is relevant to our discussion: you don’t have an explicit and audit-able way of managing dependencies inside of a monolith. Everything is up for grabs, and it feels free and cheap. So naturally, developers end up creating a complex graph of imports and includes.

该名称暗示着宏伟,规模,但更重要的是,单数。 实际上,整体中的每个源文件都不能驻留在整体之外。 有一个根本原因与我们的讨论有关:您没有一种明确且可审计的方式来管理整体内部的依赖关系。 一切都可以争夺,而且感觉免费又便宜。 因此,开发人员自然会创建一个复杂的导入和包含图。

Nowadays practically everyone is doing microservices, there can be little doubt about that. Given sufficient scale, a codebase becomes a beast, as everything is inexorably linked to each other. I’m sure many developers will provide counter-arguments that monoliths can be managed in a clean, reasonable way without falling into this trap. But exceptions simply reinforce the initial statement. Microservices solve this by defining clear boundaries and responsibilities, and a monorepo is a natural extension of this philosophy. Typically modules offer a set of public exports, or APIs, and other modules are only able to use those as part of their contracts.

如今,几乎每个人都在做微服务,对此毫无疑问。 如果有足够的规模,那么代码库就变成了野兽,因为一切都不可避免地相互关联。 我敢肯定,许多开发人员会提供反驳的论点,那就是可以以整洁,合理的方式管理整体,而不会陷入陷阱。 但是,异常只是加强了最初的陈述。 微服务通过定义明确的界限和职责来解决此问题,而monorepo是该理念的自然延伸。 通常,模块提供一组公共出口或API,而其他模块只能将其用作合同的一部分。

软件模块可重复使用通用基础架构 (Software modules reuse common infrastructure)

This is a topic that’s very near and dear to my heart. I’ll define infrastructure in this context, that of a software codebase, as the essential tools necessary to ensure productivity and code quality.

这是一个非常贴切且贴切的主题。 在这种情况下,我将定义基础结构 (软件代码库)作为确保生产力和代码质量所必需的基本工具。

One of the reasons why I think betting your company on multirepos is a mistake has to do with a set of basic requirements any software engineering project should meet:

我认为将您的公司押在multirepos上的原因之一是与任何软件工程项目都应满足的一系列基本要求有关的错误:

  • A build system to be able to reliably produce a deliverable artifact.一个能够可靠地产生可交付工件的构建系统。
  • A way to run automated tests.一种运行自动化测试的方法。
  • A way to statically analyze code for common mistakes, potential bugs, and enforce best practices.一种静态分析代码的常见错误,潜在错误并实施最佳实践的方法。
  • A way to install and manage third party dependencies, i.e. software modules which are external to your company.一种安装和管理第三方依赖性的方法,即公司外部的软件模块。

If you have your code split in multiple repositories, you need to replicate this work everywhere. Don’t underestimate how much work this involves! All of the features listed above require at the very minimum a set of configuration files which need to be maintained in perpetuity. Having them copied across more than two places basically guarantees you will always generate technical debt.

如果将代码拆分到多个存储库中,则需要在各处复制此工作 。 不要小看这涉及多少工作! 上面列出的所有功能至少都需要一组配置文件,这些文件需要永久维护。 将它们复制到两个以上的位置基本上可以确保您始终会产生技术债务。

I know that some companies go to extreme lengths to minimize the impact of this. They’ll have their configurations bundled as scaffolding (a la create-react-app or yeoman), and use them to setup new repositories. But as we’ve seen in the section before this one, there’s no way to enforce that everyone’s on the latest version of these boilerplate dependencies! The amount of time spent upgrading each repository individually increases linearly in large codebases. Given sufficient scale, practically all published versions of an internal package will be depended on at the same time!

我知道有些公司竭尽全力将其影响降到最低。 他们将其配置捆绑为脚手架( 例如la create-react-app或yeoman),并使用它们来设置新的存储库。 但是,正如我们在上一节中所看到的那样,无法强制所有人都使用这些样板依赖项的最新版本! 在大型代码库中,分别升级每个存储库所花费的时间线性增加。 如果有足够的规模,实际上将同时依赖内部软件包的所有已发布版本!

There’s a quote I absolutely love that relates to this conundrum:

有一个我绝对喜欢的报价与此难题有关:

At scale, statistics are not your friend. The more instances of anything you have, the higher the likelihood one or more of them will break. Probably at the same time.

从规模上讲,统计数据不是您的朋友。 您拥有的任何事物的实例越多,其中一个或多个分解的可能性就越高。 可能在同一时间。

— Anne Curie

— 安妮·居里

If you think distributed systems just refers to web services, I would disagree. Your codebase is an interconnected, living system. Tens, hundreds, or thousands of engineers are racing to get their code into production each day, all the while struggling to keep the build green and the code quality up. If anything, to me this sounds even scarier than a set of microservices :)

如果您认为分布式系统仅指Web服务,那我会不同意。 您的代码库是一个相互连接的实时系统。 数以千计,成百上千的工程师每天都在争先恐后地将其代码投入生产,同时努力保持构建的绿色和代码质量。 如果有的话,对我来说,这听起来比一套微服务还要可怕:)

更改始终反映在整个存储库中 (Changes are always reflected throughout the entire repository)

This is highly dependent on the rest of the features. It’s one of the benefits that’s easier to understand through example.

这在很大程度上取决于其余功能。 通过示例更容易理解它的好处之一。

Let’s say I work at a company that builds web applications for customers all around the world. Everything is organized into modules, as is exemplified below via the popular open-source project Babel. At this company we all use ReactJS for front-end work, and out of pure coincidence, all of our projects are on the same version of it.

假设我在一家为世界各地的客户构建Web应用程序的公司工作。 一切都被组织成模块,下面通过流行的开源项目Babel举例说明。 在这家公司,我们所有人都使用ReactJS进行前端工作,并且出于巧合,我们所有的项目都在同一版本上。

But the folks at Facebook publish the latest version of React and we realize that upgrading to it is not trivial. To be more productive, we’ve built a library of reusable components that resides as a separate module. All projects depend on it. This new React version brings lots of breaking changes that affect it. What options do we have for doing the upgrade?

但是Facebook上的人们发布了最新版本的React,我们意识到升级到它并不容易。 为了提高生产力,我们建立了一个可重用组件库,该库作为一个单独的模块存在。 所有项目都依赖它。 这个新的React版本带来了许多影响它的重大更改。 我们有什么选择来进行升级?

This is typically where monorepo adversaries would shoot down the entire concept. It’s easy to say that we’ve worked ourselves into a corner and that the multirepo structure would’ve been a superior choice given the circumstances. Indeed in the latter case what we would do is just gradually adopt the new React version in our projects one by one, preceded by a major version upgrade of our core components module.

这通常是monorepo对手击落整个概念的地方。 可以很容易地说,我们已经陷入困境,考虑到具体情况,多仓库结构将是一个更好的选择。 实际上,在后一种情况下,我们要做的就是逐步在我们的项目中逐步采用新的React版本,然后对核心组件模块进行重大版本升级。

But I would say this creates more problems than it solves. A core dependency breaking change release creates a schism in your engineering team. You now have two cores to maintain: the new one, which is used by a couple, brave teams in a few projects, and the older one, still depended on by almost the entire company.

但是我要说的是,这带来的问题多于解决的问题。 核心依赖性突破变更版本会在您的工程团队中造成分裂 。 现在,您需要维护两个核心:新的核心供几个项目中的几个勇敢的团队使用,而旧的核心仍被几乎整个公司所依赖。

Let’s take this problem to a bigger scale for further analysis. Our company may have some projects which are still in production, but are just in maintenance mode, and don’t have any active development teams assigned to them. These projects will probably be the last ones to migrate, extending the time window in which you keep working on two cores at the same time. The old version will still receive bugs or security fixes even though it’s deprecated, as you can’t risk your customers’ businesses.

让我们将这个问题更大规模地进行进一步分析。 我们公司可能有一些项目仍在生产中,但仅处于维护模式,并且没有指派任何活跃的开发团队。 这些项目可能是最后一个要迁移的项目,从而延长了您同时在两个内核上工作的时间范围。 即使您不赞成使用旧版本,但仍旧会收到错误或安全修复程序,因为您不能冒险客户的业务。

All of this is to say that a multirepo solution promotes and enables a constant state of technical debt. There are lots of migrations going on, modules that depend on older versions of other modules, and many, many deprecation policies which may or may not be enforceable.

所有这一切都意味着, 多重回购解决方案可以促进并保持技术债务的稳定状态 。 有许多迁移正在进行,模块依赖于其他模块的较旧版本,并且有很多折旧策略,这些策略可能强制执行,也可能无法强制执行。

Let’s now consider an alternative solution to the React upgrade problem. By having all of the code in one place, and dependent on each other directly, without versioning, we’re left with one option: we have to do all of the work upfront, in all modules simultaneously.

现在让我们考虑一下React升级问题的替代解决方案。 通过将所有代码放在一个位置,并且直接相互依赖而不进行版本控制,我们剩下一个选择:我们必须同时在所有模块中预先进行所有工作。

If that sounds like a scary proposition, I don’t blame you. It’s terrifying to think about, at first. However the advantage is clear: no migrations, no technical debt, less confusion around the state of our codebase. In practical terms, there is one obstacle to overcome with this solution — there may be hundreds, thousands, or millions of lines of code that need to be changed all at once. By having separate projects we avoid the sheer volume of work by doing it piece by piece. It’s still the same total amount of changes, but we’re naturally inclined to think it would be easier to do that over time, rather than in one push.

如果这听起来像一个可怕的主张,我就不会怪你。 一开始想起来很恐怖。 但是优点很明显:无需迁移,没有技术债务,对我们代码库状态的混乱也较少。 实际上,使用此解决方案需要克服一个障碍-可能需要成百上千,成千上万或几百万行的代码需要一次全部更改。 通过拥有单独的项目,我们可以通过逐个工作来避免繁琐的工作量。 总的变化量仍然是相同的,但我们自然倾向于认为,随着时间的推移,而不是一劳永逸地做到这一点会更容易。

To solve this last problem large companies have turned to codemods — programmatic transformations of source code that can run at very large scale. There are numerous tutorials out there if you’re interested, but the gist of it is — you write code that first detects certain patterns in your source code, and then applies specific changes to it. To take our React example further, you could write a codemod that replaces a deprecated API with a newer one, and even apply logic changes if necessary. Indeed this is how Facebook recommends you migrate from one version of their library to the next. It’s how they’re doing it internally. Check out their open-source examples.

为了解决最后一个问题,大公司已转向codemods-可以大规模运行的源代码的编程转换。 如果您感兴趣的话,这里有许多教程,但要旨是-您编写的代码首先会检测源代码中的某些模式,然后对其进行特定的更改。 进一步讲一下我们的React示例,您可以编写一个codemod,用一个较新的API替换已弃用的API,并在必要时甚至应用逻辑更改。 实际上,这就是Facebook建议您从其库的一个版本迁移到下一个版本的方式。 这就是他们在内部进行的方式。 查看他们的开源示例 。

Viewed from this angle, a migration doesn’t seem as scary as before. You do all of your research upfront, you define how you want to essentially rewrite the affected code, and apply the changes more or less all at once. This to me is a robust solution. I’ve seen it in action, it can be done. It’s indeed amazing when it works and lately more and more companies are adopting it.

从这个角度来看,迁移似乎没有以前那么可怕。 您需要先进行所有研究,然后定义要如何实质上重写受影响的代码,然后一次或多或少全部应用更改。 对我来说,这是一个可靠的解决方案。 我已经看到了它的作用,可以做到。 当它起作用并且越来越多的公司正在采用它时,确实的确令人惊奇。

缺点 (Drawbacks)

The old adage of “there’s no such thing as a free lunch” certainly applies here, as well. I’ve talked about a lot of pros, but there are some cons which you need to think about.

“没有免费的午餐之类的东西”这句老话当然也适用于此。 我讨论了很多优点,但是您需要考虑一些缺点。

Given that everyone is working in the same place, and everything is interconnected, tests become the blood of the whole system. Trying to make a change that impacts potentially thousands of lines of code (or more) without the safety net of automated tests is simply not possible.

鉴于每个人都在同一个地方工作,并且所有事物都是相互联系的,所以测试成为整个系统的血液。 在没有自动测试的安全网的情况下,试图做出可能影响数千行代码(或更多行)的更改是根本不可能的。

Why is this any different from traditional ways of storing code? I’d say that versioned modules hide this particular problem, at the expense of creating technical debt. If you own a module that depends on another team’s code, by way of a strict version number, then you’re in charge of upgrading it. If you don’t have sufficient test coverage, you’ll err on the side of caution and simply delay upgrading until you’re confident the module doesn’t affect your own project. As we’ve discussed earlier, this has a serious long term consequences, but it’s a viable strategy nonetheless. Especially if your business doesn’t actually promote long term projects.

为什么这与传统的代码存储方式有所不同? 我会说版本控制模块隐藏了这个特殊问题,但以增加技术债务为代价。 如果您拥有一个依赖于另一个团队代码的模块(通过严格的版本号),那么您将负责升级它。 如果您没有足够的测试覆盖范围,则您会犯谨慎的一面,而只是延迟升级,直到您确信该模块不会影响您自己的项目为止。 正如我们前面讨论的那样,这会带来严重的长期后果,但这仍然是可行的策略。 特别是如果您的业务实际上没有促进长期项目。

We mentioned the benefit of every contributor being able to access all of the source code in your organization. If we flip that around, this can also be a problem for some types of work. There’s no easy way you can restrict access to projects. This is important if you consider government or military contracts as they typically have strict security requirements.

我们提到了每个贡献者都能访问组织中所有源代码的好处。 如果我们将其翻转,这对于某些类型的工作也可能是一个问题。 没有简单的方法可以限制对项目的访问。 如果您考虑政府或军事合同,因为它们通常具有严格的安全要求,这很重要。

Finally let’s consider continuous integration. You may be using a system such as Jenkins, Travis, or CircleCI, to manage the way your code is tested and delivered to customers. When you have more than one repository you typically set up one pipeline for each. Some teams even go further and have one dedicated CI instance per project. This is a flexible system that can adapt to the needs of each team. Your billing team may deploy to production once a week, while your web team would move faster and deploy multiple times a day.

最后,让我们考虑持续集成。 您可能正在使用Jenkins,Travis或CircleCI之类的系统来管理代码测试并交付给客户的方式。 当您有多个存储库时,通常会为每个存储库建立一个管道。 有些团队甚至走得更远,每个项目都有一个专用的CI实例。 这是一个灵活的系统,可以适应每个团队的需求。 您的计费团队可以每周一次部署到生产环境,而您的网络团队可以更快地迁移并每天部署多次。

If you’re considering moving to a monorepo, be wary of your CI system’s capabilities. It will have to do a lot of work. Simple tasks such as checking out the code, or building an artifact may become long running tasks which impact productivity. Google developed and runs its own custom CI solution, and for good reason. Nothing available on the market was good enough.

如果您正在考虑使用monorepo,请警惕CI系统的功能。 它必须做很多工作 。 诸如检出代码或构建工件之类的简单任务可能会变成长期运行的任务,从而影响生产率。 Google有充分的理由开发并运行自己的自定义CI解决方案。 市场上没有什么是足够好的。

Now before you conclude that this is a blocker, I’d recommend you carefully analyse your project and the tools you use. If you’re using git, for example, there’s a myth going around that it can’t handle big repositories. This is demonstrably inaccurate, as best exemplified by the project that inspired git in the first place, the Linux Kernel.

现在,在您断定这是一个阻碍因素之前,我建议您仔细分析您的项目和使用的工具。 例如,如果您使用的是git,则有一个神话,那就是它无法处理大型存储库。 这显然是不准确的,首先从启发git的项目Linux Kernel可以很好地说明这一点。

Make your own research and see how many files and lines of code you have, and try to predict how much your project will grow. If you’re nowhere near the scale of the Kernel, then you’re OK. You could also make the point that git isn’t very good at storing binaries. LFS aims to solve that. You can also rewrite your history to delete old binaries in order to optimize performance.

做您自己的研究,查看有多少文件和代码行,并尝试预测项目将增长多少。 如果您距离内核的范围还很远,那您就可以了。 您还可以指出git在存储二进制文件方面不是很好。 LFS致力于解决这一问题。 您还可以重写历史记录以删除旧的二进制文件,以优化性能。

In a similar vein, open-source CI systems are much more powerful than you think. Jenkins for example can scale to hundreds of jobs, dozens of workers, and can serve the needs of a large team with ease. Can it do Google scale? Absolutely not! But do you have tens of thousands of engineers pushing to production every day? The plateau at which these tools stop performing is so high, it’s not worth thinking about until you’re close to it. And chances are, you’ll know when you’re getting close.

同样,开源CI系统比您想象的要强大得多。 例如,詹金斯(Jenkins)可以扩展到数百个工作,数十个工人,并且可以轻松满足大型团队的需求。 Google可以扩展吗? 绝对不! 但是,您每天有成千上万的工程师投入生产吗? 这些工具停止运行的平稳期是如此之高,直到您接近它才值得考虑。 机会是,您将近在咫尺。

And finally, there’s cost. You’ll need at least one dedicated team to pull this off. Because the amount of work is certainly not trivial, and it demands passion and focus. This team will need to, and I’m just summarizing here, build and maintain in perpetuity what is essentially a platform that stores code, assets, build artifacts, reusable development infrastructure for running tests or static analysis, and a CI system able to withstand large workloads and traffic. If this sounds scary, it’s because it is. But you’ll have no problems convincing developers to join such a team, it’s the type of experience that’s hard to accumulate by doing side-projects at home.

最后,有成本。 您需要至少一个专门的团队来实现这一目标。 因为工作量肯定不小,需要热情和专注。 这个团队将需要(并且我在这里仅作总结)永久地构建和维护一个实质上是一个平台,该平台存储代码,资产,构建工件,可重复使用的开发基础结构以运行测试或静态分析,以及能够承受的CI系统大量的工作量和流量。 如果这听起来很吓人,那是因为。 但是,说服开发人员加入这样的团队不会有任何问题,这种经验很难通过在家中进行附带项目来积累。

在结束时 (In closing)

I’ve talked about the many advantages of working in a monorepo, the drawbacks, and touched upon the costs. This setup is not for everyone. I wouldn’t encourage you to try it out without first evaluating exactly what your problems and your business requirements look like. And of course, do go through all of the possible alternatives before deciding.

我已经谈到了在monorepo中工作的许多优点,缺点以及涉及的成本。 此设置并不适合所有人。 在不首先评估您的问题和业务需求的情况下,我不鼓励您尝试一下。 当然,在决定之前,请仔细研究所有可能的选择。

翻译自: https://www.freecodecamp.org/news/monorepo-essentials/

monorepo

monorepo_Monorepo开发的要点相关推荐

  1. iOS开发证件要点详解

    iOS开发证书要点详解 引言 关于开发证书配置(Certificates&Identifiers&Provisioning Profiles),相信做iOS开发的同学没少被折腾.对于一 ...

  2. Java、大数据开发学习要点(持续更新中...)

    Java.大数据开发学习要点 这里有作者本人学习Java.大数据开发时的详细知识记录,随时根据学习状态更新. 以下是关于

  3. Excel阅读模式/单元格行列指示/聚光灯开发 技术要点再分享

    1. 引言 文题中所谓技术要点再分享,本意是想在大神Charltsing Liu的博文"简单介绍Excel单元格行列指示的实现原理(俗称聚光灯功能)"的基础上写一点个人开发体会.写 ...

  4. 物流APP开发功能要点

    物流APP开发,物流APP开发功能,物流APP开发要点,物流APP开发需求,物流APP开发靠谱公司,物流APP开发制作流程,物流APP开发全网定制,物流APP开发源码交付. 物流APP开发能够满足用户 ...

  5. WAP网站开发的要点

    开发维护移动的WAP网站也有一段时间了,总结一下我认为WAP网站的要点: 1)速度永远是第一位的.手机上网本来速度就慢,没办法只有在服务器端提高速度,采取了一些措施,如数据都是放在缓存中,对数据库中数 ...

  6. [第四章]开发小要点:提高条形码识别率

    关于如何提高条形码识别率,下面有几个要点: 条形码的图片质量很重要.通常,条形码识别器处理区域中像素的计数以确定条形码类型中特定条的宽度和位置.因此,如果分辨率不高,此过程会受到影响. 通常,分辨率至 ...

  7. webkit webApp 开发技术要点总结

    如果你是一名前端er,又想在移动设备上开发出自己的应用,那怎么实现呢?幸好,webkit内核的浏览器能帮助我们完成这一切.接触 webkit webApp的开发已经有一段时间了,现把一些技巧分享给大家 ...

  8. [转]webkit webApp 开发技术要点总结

    1. viewport: 也就是可视区域.对于桌面浏览器,我们都很清楚viewport是什么,就是出去了所有工具栏.状态栏.滚动条等等之后用于看网页的区域, 这是真正有效的区域.由于移动设备屏幕宽度不 ...

  9. webApp 开发技术要点总结

    如果你是一名前端er,又想在移动设备上开发出自己的应用,那怎么实现呢?幸好,webkit内核的浏览器能帮助我们完成这一切.接触 webkit webapp的开发已经有一段时间了,现把一些技巧分享给大家 ...

最新文章

  1. 双圆弧插值算法(三,代码实现)
  2. 皮一皮:这解释...没毛病!
  3. eclipse rcp应用程序重启
  4. 九十一、前端可视化ECharts的使用
  5. Qt学习笔记之QString
  6. iOS开发之解决系统数字键盘无文字时delete键无法监听的技巧
  7. 信道模型多径传播阴影衰落——无线接入与定位(2)
  8. 你误解了Windows的文件后缀名吗?
  9. 面向对象之需求分析要略
  10. 格雷码与二进制转换电路设计
  11. MAC 下 excel 如何使用加载项(宏)
  12. 树的计数 + prufer序列与Cayley公式 学习笔记
  13. amazon实例 更改密钥_如何更改Amazon Echo的警报声音
  14. Dao层和Service层的区别
  15. 名帖07 赵宧光 篆书《篆书四箴册》
  16. 最新vx红包封面小程序源码 附教程
  17. 2020-12 补丁日: 微软多个高危漏洞通告
  18. crypto-js 加密 php后端解密
  19. 算法刷题 -- 1823. 找出游戏的获胜者<难度 ★★☆>
  20. php 横线,文字下面加横线怎么弄

热门文章

  1. 【java】兴唐第十五节课
  2. git ignore linux,为什么说.gitignore不能忽视
  3. root 123 mysql_MySQL常用命令
  4. 小程序聊天室开发,发送文字,表情,图片,音频,视频,即时通讯,快速部署,可定制开发
  5. 微信小程序 点击卡片切换 动画效果
  6. iOS开发 关于启动页和停留时间的设置
  7. 一款腾讯UED设计的提示插件(使用教程)
  8. GCD之信号量机制二
  9. 【工业串口和网络软件通讯平台(SuperIO)教程】七.二次开发服务驱动
  10. 【SQL Server】系统学习之一:表表达式