|
| 1 | +# Arcade-powered source-build |
| 2 | + |
| 3 | +Source-build existing as a process outside the Microsoft build impedes efforts |
| 4 | +to maintain the source-buildability of .NET Core. Integration into the normal |
| 5 | +build process is driven by two major goals: |
| 6 | + |
| 7 | +1. When the .NET Core SDK **official build** completes, its artifacts include |
| 8 | + validated, ship-ready source-build outputs, in addition to the Microsoft |
| 9 | + build outputs. |
| 10 | + |
| 11 | + * **Official builds** produce the signed bits released by Microsoft, running |
| 12 | + on a daily or per-commit basis depending on repo and point in time. |
| 13 | + |
| 14 | + * This has two core benefits over the current situation: we know immediately |
| 15 | + whether an SDK can be source-built cleanly, and the status is as visible as |
| 16 | + an SDK build failure. |
| 17 | + |
| 18 | + * Breaks in source-build can be detected and fixed immediately by repo |
| 19 | + owners, just as any other build failure, rather than fixed by source-build |
| 20 | + maintainers weeks to months after the fact using patches. |
| 21 | + |
| 22 | + * Microsoft build process owners don't need to reject late build respins |
| 23 | + based on manual post-build source-build efforts being projected to not |
| 24 | + complete in time for release dates. |
| 25 | + |
| 26 | + * Rebuilding the SDK close to a release day doesn't cause setbacks to |
| 27 | + source-build maintainers by throwing away manual build uptake work. |
| 28 | + |
| 29 | + * This eliminates the delay between Microsoft build completion and |
| 30 | + source-build tarball availability, as long as we treat a source-build |
| 31 | + failure as seriously as a Microsoft build failure. |
| 32 | + |
| 33 | +2. Every repo involved in source-build validates source-buildability in its **PR |
| 34 | + validation** build. |
| 35 | + |
| 36 | + * **PR validation** builds run on each pull request submitted to a |
| 37 | + repository, and is typically required to succeed to merge. There are also |
| 38 | + **rolling builds** that run lower-priority and slower tests after each |
| 39 | + merge. |
| 40 | + |
| 41 | + * This allows developers and release owners to understand the source-build |
| 42 | + impact of changes, reducing the frequency the source-build servicing team |
| 43 | + has to root-cause and patch over problems. |
| 44 | + |
| 45 | +This doc is about where we can start, what incremental progress would look like, |
| 46 | +and the vision. |
| 47 | + |
| 48 | +## Starting point: official build |
| 49 | + |
| 50 | +The output of source-build is a set of tarballs that can be used to build the |
| 51 | +.NET Core SDK from source. We can move the current behavior of source-build to |
| 52 | +the Core-SDK official build. That is, Core-SDK clones all constituent repos, |
| 53 | +applies patches, builds each repo using customized build commands, and produces |
| 54 | +the source-build tarballs as artifacts. |
| 55 | + |
| 56 | +This immediately makes the dotnet/source-build repo unnecessary: it only held |
| 57 | +the source-build orchestration behavior. |
| 58 | + |
| 59 | +This needs more work to meet our goals due to build performance. It is simply |
| 60 | +too slow (> 2hrs) to build all constituent repos within one official build. It |
| 61 | +needs to be fast enough that it is reasonable for the entire official build to |
| 62 | +be rejected when the source-build fails. |
| 63 | + |
| 64 | +> Note: practically, the source-build official build should run in an |
| 65 | +> independent build pipeline at first: the long build time would interfere with |
| 66 | +> other .NET 5 work if integrated directly. |
| 67 | +
|
| 68 | +For more info, see [source-build-in-pipeline.md]. |
| 69 | + |
| 70 | +## Starting point: PR validation |
| 71 | + |
| 72 | +We can start here by adding extra jobs that run the standard source-build |
| 73 | +command and arguments. This is a simple step to confirm the build isn't |
| 74 | +fundamentally broken. |
| 75 | + |
| 76 | +This needs more work to meet our goals for many reasons: |
| 77 | + |
| 78 | +* Prebuilt dependency usage isn't tracked, because all dependencies are |
| 79 | + downloaded as non-source-built prebuilts. |
| 80 | +* Source-build behavior may not work with source-built upstreams. |
| 81 | +* The artifacts built by the repo may not work downstream. |
| 82 | +* Advanced build flows aren't checked, such as source-build bootstrap or using |
| 83 | + an N-1 SDK. |
| 84 | + |
| 85 | +For more info, see [source-build-in-pipeline.md]. |
| 86 | + |
| 87 | +Related work, but not necessary to meet our goals: |
| 88 | + |
| 89 | +* Unit tests are typically disabled in source-build, because test infrastructure |
| 90 | + isn't built from source. We should run tests on the source-build product to |
| 91 | + catch bugs. However, this isn't necessary to meet the maintainability goals of |
| 92 | + this plan. |
| 93 | + |
| 94 | +## Incremental progress |
| 95 | + |
| 96 | +### The performance gap |
| 97 | +We need to avoid building all constituent repos in the Core-SDK build. To do |
| 98 | +this, each repo needs to produce intermediate source-built artifacts during its |
| 99 | +official build, to be consumed by downstream repos. On the other end, |
| 100 | +source-build needs to support restoring from an intermediate artifact. |
| 101 | + |
| 102 | +To make incremental progress, we should pick one of Core-SDK's upstreams, and |
| 103 | +add source-build functionality that produces source-built intermediates. |
| 104 | +Core-SDK should consume them. We should choose a leaf in the source-build |
| 105 | +dependency graph, say, Linker. When Core-SDK is looking at the build graph to |
| 106 | +determine which repos to build, instead of building Linker, it should restore |
| 107 | +the Linker intermediate artifact. Once we have this flow working, the |
| 108 | +functionality should be integrated into Arcade SDK for easy onboarding. |
| 109 | + |
| 110 | +Then, working from the bottom (leaves) upward (towards Core-SDK), more repos |
| 111 | +should consume and produce source-built intermediates in their official builds. |
| 112 | +When this completes, each repo only needs to build itself. See |
| 113 | +[incremental-official.md] for more details about this process. |
| 114 | + |
| 115 | +It is possible to instead only implement official source-build in a handful of |
| 116 | +repos. This segments the build into chunks, which must be coherent. This idea is |
| 117 | +discussed in [incremental-official-chunked.md], and is not recommended. |
| 118 | + |
| 119 | +> Note: some constituent repos aren't maintained by Microsoft, so it isn't |
| 120 | +> feasible to add them directly to this flow. We could fork them and set up a |
| 121 | +> build just for source-build intermediates. If a repo builds quickly, however, |
| 122 | +> it might be better to simply rebuild it whenever the outputs are needed. |
| 123 | +
|
| 124 | +### Getting into Arcade |
| 125 | +The initial plan to run source-build in Core-SDK doesn't assume any changes to |
| 126 | +Arcade: this should be possible due to the extension points that already exist |
| 127 | +in the Arcade SDK. Once we have that, it will be clearer what logic is missing, |
| 128 | +and how to add it. This allows us to migrate source-build logic incrementally |
| 129 | +and in parallel with other work. |
| 130 | + |
| 131 | +For more info, see [in-arcade.md]. |
| 132 | + |
| 133 | +### The speculative SDK |
| 134 | +It's difficult to validate that a PR won't break downstream repos. This problem |
| 135 | +is shared by source-build and the Microsoft build. "Speculative builds" have |
| 136 | +been proposed to try to help with this, but would be very difficult to implement |
| 137 | +in the Microsoft build. It may be more reasonable in the context of |
| 138 | +source-build: all builds happen on a single machine, so the problem is focused |
| 139 | +on figuring out a build graph rather than organizing dozens of machines in a |
| 140 | +build lab and flowing bits across a network. |
| 141 | + |
| 142 | +This is also necessary in source-build to validate several distro maintenance |
| 143 | +scenarios: by making a PR, is it still possible to run a bootstrap build of the |
| 144 | +.NET Core SDK? Can .NET Core SDK version N be built using SDK N-1? |
| 145 | + |
| 146 | +This can be developed in parallel to other efforts. See [speculative-build.md] |
| 147 | +for more info about speculative builds. |
| 148 | + |
| 149 | +## End result |
| 150 | + |
| 151 | +When all of this is working, the official Microsoft build of the .NET Core SDK |
| 152 | +also produces tarballs that distro maintainers can use to build it from source. |
| 153 | +Contributors in each repo use checks in PR validation to verify each change is |
| 154 | +compatible with source-build requirements, and if validation runs into a |
| 155 | +problem, they are able to reproduce the build locally using an Arcade build |
| 156 | +command. |
| 157 | + |
| 158 | +--- |
| 159 | + |
| 160 | +## Q&A |
| 161 | + |
| 162 | +### Q: How do we patch without an orchestration-focused repo? |
| 163 | +A: We shouldn't! But if we have to, use a forked branch. See |
| 164 | +[patching.md](patching.md). |
| 165 | + |
| 166 | + |
| 167 | +[in-arcade.md]: in-arcade.md |
| 168 | +[incremental-official-chunked.md]: incremental-official-chunked.md |
| 169 | +[incremental-official.md]: incremental-official.md |
| 170 | +[source-build-in-pipeline.md]: source-build-in-pipeline.md |
| 171 | +[speculative-build.md]: speculative-build.md |
0 commit comments