Commit 49054e1
committed
CI: Add automatic dependent repo resolution logic.
The openEMS Project is a multi-repo project. Changes frequently
affect multiple repos, with changes depending on each other.
Forking a repo also means all related repos must be forked together,
creating a poor contribution experience, since the CI pipeline
doesn't work properly for them.
This commit introduces automatic dependent-repo resolution logic
to the CI/CD pipeline, with the following rules.
1. Want to develop a multi-repo change in CSXCAD and openEMS? Use
the same branch name, they'll be tested together.
2. Want to send Pull Requests to both CSXCAD and openEMS? Use
the same branch name in your fork, and open two individual Pull
Requests against CSXCAD and openEMS. If both Pull Requests are
opened, and the source branch name is the same, they'll be tested
together.
3. Want to fork openEMS and develop it at the downstream? You can
fork the only the repos you need. The CI/CD script automatically
uses the project founder's repos as fall back for non-forked
dependencies. You can override these dependencies by forking more
repos.
== Owner-then-Founder Dependency Lookup ==
If a git commit is pushed into a repo, or if a repo has received
a Pull Request from a contributor, to build this repo, we need to
look for the repo's dependencies. We check all dependencies one
by one. If the repo's owner also has dependent repo under their
GitHub account. If it's the case, the owner's copy is used as the
dependency. If it's not the case, the founder account thliebig's
copy is used as the dependency.
This two-tier lookup solves several problems:
1. An experimenter can only fork openEMS without forking any
dependencies. Since the CI/CD script falls back to the founder's
repos for dependencies, their local repo's CI/CD works automatically.
If they want to make a change to CSXCAD and openEMS at the same
time, they only need to selectively fork CSXCAD, so that the
"repo owner override" takes effect. At the same time, they can
keep using the founder's fparser repo as a fallback without forking
it.
2. Someone may send a Pull Request against a downstream fork itself,
rather than the project founder. For example, I have a downstream
openEMS fork named fasterEMS. If someone sends a Pull Request against
my "fasterEMS/CSXCAD", my repo's CI/CD needs to use the same-owner
repo "fasterEMS/fparser" as the dependency, not project founder's
"thliebig/fparser".
== Pull-Request Ganging ==
If a Pull Request "pr_primary" is submitted against the upstream repo
"repo_primary", we check whether the same contributor has also opened
another Pull Request "pr_dependency" against our dependency "repo_dependency",
and whether both Pull Requests uses the same source branch name, such as
"feature". If both conditions are met, we can say that two Pull Requests
are "ganged", they are tested by CI/CD together. When testing "pr_primary"
at "repo_primary", instead of using default repos as dependencies, we
checkout the merge commit of "pr_secondary" at the "repo_secondary" as
its dependency.
For more than 2 repos, the same "ganged PR" logic also applies.
If Pull-Request Ganging is activated, a warning is generated in the
"Annotations" panel of the GitHub Actions Summary page, reminding
developers to merge the dependent PR first before the main PR.
== Branch Ganging ==
If a git commit is submitted to a non-default branch "feature" of repo
"repo_primary", we check whether our dependency "repo_dependency" also
has a branch named "feature".
If this condition is met, we can say that two repo branches are "ganged",
they are tested by CI/CD together. When testing the branch "feature" of
"repo_primary", instead of using default branch "master" of "repo_dependency"
as the dependency, we checkout the branch "feature" the "repo_dependency"
instead.
This allows testing multi-repo features together while it's in development.
For more than 2 repos, the same "ganged branches" logic also applies.
If Branch Ganging is activated, a warning is generated in the
"Annotations" panel of the GitHub Actions Summary page, reminding
developers that a different branch of the dependent repo is used for this
test.
== Implementation Details ==
This commit adds a new CI job called "Resolve Repo Dependencies",
which is executed before all other jobs. This job calls the Python
script "scripts/resolve_dependent_repos.py", which uses GitHub
Actions variables and GitHub APIs to find the needed dependencies
according to the conditions and contexts explained above.
After the script finishes, it generates several output variables
that contain the repoes and branches of all dependencies. These
output variables are passed using the shell variable "$GITHUB_OUTPUT"
(provided by GitHub Actions), later, all other jobs use these variable
as their inputs for the "actions/checkout" steps.
Signed-off-by: Yifeng Li <tomli@tomli.me>1 parent c62051e commit 49054e1
2 files changed
Lines changed: 395 additions & 45 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
0 commit comments