casaroli opened a new pull request, #20806:
URL: https://github.com/apache/nuttx/pull/20806

   ## Summary
   
   When a `Depends-On:` PR is merged, its commits are already in master. Build 
and the memory report still cherry-pick the PR head again. The cherry-pick is 
empty or conflicts, and `Fetch-Source` fails with `cherry_pick_conflict`. Today 
the author must remove the line and start CI again each time a dependency 
merges.
   
   This PR reads the state of each dependency with the GitHub API (`GET 
/repos/{owner}/{repo}/pulls/{n}`):
   
   - merged, and its `merge_commit_sha` is an ancestor of the checkout: CI 
skips it and says so in the log;
   - closed without merge: CI does not apply it and fails with 
`::error::Dependency <dep> is closed without merge; remove it from depends-on 
or reopen it.`;
   - open: CI applies it as today;
   - merged into a different branch, or merged after the checkout was made (for 
example a re-run of an old run): the ancestor check fails, so CI applies it as 
today;
   - if the API call fails, CI writes a warning and applies the dependency as 
today.
   
   The report stays truthful. `applied.tsv` gets a fourth column `merged` for a 
skipped dependency, and `result.json` gets `"merged": true`. For a closed 
dependency, the failure report gets the error code `dependency_closed` and 
`"closed": true` on that dependency. The comment shows "(already merged, 
skipped)", or for the failure "❌ **closed without merge**" on the dependency 
and the reason "a dependency PR is closed without merge; remove it from 
depends-on or reopen it". The memory report writes the same notes and error in 
its log and step summary. The old comment workflow ignores the new fields, so 
the report format stays compatible. The last commit updates 
`Documentation/testing/nuttx-ci.rst`.
   
   nuttx-apps carries a copy of `build.yml` and `depends-on-comment.yml`; the 
same change goes there in its own PR.
   
   ## Impact
   
   CI only. Behaviour change: a `Depends-On:` PR that is closed without merge 
now fails `Fetch-Source` (and the memory report). On master, CI applied such a 
PR silently and the build continued. A PR body can now keep a `Depends-On:` 
line after the dependency merges. One extra API call for each declared 
dependency, with the workflow `GITHUB_TOKEN` (the Apply step now gets 
`GH_TOKEN`). Nothing changes for PRs without `Depends-On:`, or for open 
dependencies.
   
   ## Testing
   
   I ran the "Apply depends-on PRs" step scripts, extracted from the YAML 
files, on my machine against real PRs, with the old (master) and the new 
workflows. The sources were clones of nuttx and nuttx-apps master. #20802 is 
merged, #20783 is closed without merge, #20777 and nuttx-apps#3878 are open.
   
   | Case | master | this PR |
   |---|---|---|
   | build.yml, #20802 only | fails, `cherry_pick_conflict` | skips #20802, 
exit 0 |
   | build.yml, `[#20802 nuttx-apps#3878]` | fails, `cherry_pick_conflict` | 
skips #20802, applies 3878, exit 0 |
   | membrowse-report.yml, same | fails, "Could not cherry-pick" | skips 
#20802, applies 3878, exit 0 |
   | build.yml, checkout is the parent of the #20802 merge commit | applies 
both | applies both (same as master) |
   | build.yml, API call fails | (no API call) | warning, applies #20802, fails 
as on master |
   | build.yml, open #20777 only | applies it | applies it (same) |
   | build.yml and membrowse-report.yml, #20783 only | applies it, exit 0 | 
fails: "closed without merge; remove it from depends-on or reopen it", nothing 
applied |
   | build.yml and membrowse-report.yml, `[#20802 #20783 nuttx-apps#3878]` | 
fails, `cherry_pick_conflict` | skips #20802, fails on #20783 with the same 
error |
   
   I also ran the github-script of `depends-on-comment.yml` with node and a 
fake API, for the new `result.json` files. For a success it marks #20802 
"(already merged, skipped)". For the #20783 failure it marks #20783 "❌ **closed 
without merge**" and shows the reason above. The old comment workflow renders 
the same reports without the notes and without a reason line. `python3 -m 
unittest test_depends_on` passes (40 tests), `yamllint` and `shellcheck` give 
no new findings, and `tools/checkpatch.sh -c -u -m -g` passes.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to