dco-check run as GH action fails after extensive rebase
Opened this issue · 3 comments
Kia ora,
I added dco-check to GH, thank you for that, it's awesome :), and it flagged that a bunch of my commits weren't DCO compliant, so I rebased from scratch - e.g., git rebase -i --root
. In the process, I not only reworded, but also squashed and dropped some commits.
This has now broken dco-check, as it seems to be trying to retrieve a commit that no longer exists.
The output:
Detected: GitHub CI
Checking commits: a33bba34234dcc2e98aaa9b5ad7b58211bba17b2..f0a6afac8d98e1c29a472fd929bf8721b5c81da2
File "/opt/hostedtoolcache/Python/3.9.6/x64/bin/dco-check", line 8, in <module>
sys.exit(main())
File "/opt/hostedtoolcache/Python/3.9.6/x64/lib/python3.9/site-packages/dco_check/dco_check.py", line 1128, in main
commits = commit_retriever.get_commits(
File "/opt/hostedtoolcache/Python/3.9.6/x64/lib/python3.9/site-packages/dco_check/dco_check.py", line 939, in get_commits
response = request.urlopen(req)
File "/opt/hostedtoolcache/Python/3.9.6/x64/lib/python3.9/urllib/request.py", line 214, in urlopen
return opener.open(url, data, timeout)
File "/opt/hostedtoolcache/Python/3.9.6/x64/lib/python3.9/urllib/request.py", line 523, in open
response = meth(req, response)
File "/opt/hostedtoolcache/Python/3.9.6/x64/lib/python3.9/urllib/request.py", line 632, in http_response
response = self.parent.error(
File "/opt/hostedtoolcache/Python/3.9.6/x64/lib/python3.9/urllib/request.py", line 561, in error
return self._call_chain(*args)
File "/opt/hostedtoolcache/Python/3.9.6/x64/lib/python3.9/urllib/request.py", line 494, in _call_chain
result = func(*args)
File "/opt/hostedtoolcache/Python/3.9.6/x64/lib/python3.9/urllib/request.py", line 641, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found
The actual commits, post rebase:
git log --oneline
f0a6afa (HEAD -> main, origin/main, origin/HEAD) Update README.md
4eb1370 Add DCO check
d928469 Automate assignment to GH project
1107a80 Added skeleton of first client app, and tried to codify project structure
02bd9d8 Initial commit
I'm assuming that state was stored by GH when dco-check cloned the repo, and this confused it. I took the following actions, one of which fixed it, unfortunately I didn't do it in a very scientific manner, my apologies.
- Renamed workflow file from dco.yml to DCO-check.yml
- Renamed action from "dco" to "DCO check" in the YAML
- Renamed the check step from "check DCO" to "DCO check"
Hey! Happy to hear it's helpful!
I'm assuming it was running after a push to main
? Like you said, rebasing all your commits from the root probably confused GitHub and invalidated the before
field in the event payload of the push
event (https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#push), and your actions probably "reset" it.
I'm not sure if this edge case can be covered using the data from the push
event, but there might be a way to fall back on something else if the base commit isn't found when fetching data from the API. dco-check doesn't really expect a full/root rebase, and by default it tries not to check all commits from the root commit (at least for GitHub), but perhaps it would be the right behaviour here?
HI @christophebedard - It is indeed an edge case, might not need to be handled in code. I'd be happy to add some brief docs on it. If that works for you, I'd run some more isolated experiments to see which of the changes I made above resolved the issue, so can explain what to do if rebasing from --root and hitting this issue.
Of course, that would be great!