dvc: exp push: breaking in GHA
Bug Report
Description
dvc exp push --rev HEAD is breaking in GitHub Actions. The log is in https://github.com/iterative/lstm_seq2seq/actions/runs/4559164229/jobs/8042811435#step:7:4777.
Reproduce
Try to run the action in https://github.com/iterative/lstm_seq2seq/actions/workflows/cml.yaml from the debug branch (to get verbose output).
Note that I could not reproduce it locally, even from a shallow clone or detached head.
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 3
- Comments: 16 (14 by maintainers)
Yes, that’s specifically for actions triggered by a PR. On
pushit should be using the tip of the pushed branch.Just an FYI that
dvc exp remove -g ...will probably not work out of the box in codespaces, the default github access token generated for a codespace does not have delete permissions. (This can be verified by tryinggit push --delete refs/exps/...in the codespace)I’m assuming it’s possible to configure codespaces to use a specific token, in which case
exp remove -g originwould work as long as the token had the appropriate delete permissions.@dberenbaum I’m not sure that this workflow will actually do what you are intending though. If you run an experiment in a github actions PR with the default
actions/checkoutworkflow, HEAD in the pull request is the merge commit generated by github (refs/pull/###/merge), and not the actual tip of the PR branch (refs/pull/###/head).So the resulting experiment will be derived from the pull request merge commit (and not from some commit on your original
mainbranch).To illustrate this, the linked run from my example-get-started fork creates an experiment derived from
716deb4(the PR merge commit). The tip of my PRci-push-testbranch is actually66610dbEven if I pull the experiment and then do
exp show -AI will not be able to see the experiment since it does not actually belong to any of the branches in my repo (the PR merge commit generated by github is essentially a dangling merge commit that does not belong to any branch). To actually view the experiment inexp show, you would have togit checkout 716deb4(detached-checkout the merge commit) and then doexp showfrom the detached checkout.If you want the experiment to derive from the tip of the PR branch, users need to explicitly tell github to not use the merge ref in their GHA workflow
(see https://github.com/actions/checkout#checkout-pull-request-head-commit-instead-of-merge-commit)
This is actually supported in dulwich, there’s a bug in how we were calling dulwich
send-packand will be fixed in the next scmrepo release. (see https://github.com/pmrowla/example-get-started/actions/runs/4676585105/jobs/8283071376)It looks like git push does work (https://github.com/pmrowla/example-get-started/actions/runs/4673849990/jobs/8277481487), so this is probably due to dulwich’s shallow ref support being incomplete. I’ll start looking into it but it may be non-trivial to fix (shallow repo support is complicated, there’s a reason libgit2 still hasn’t implemented any shallow support at all)
In the meantime the suggested workflow for using
exp pushin CI should be to just usefetch-depth: 0It’s not needed for
exp runandexp apply.git push(andexp push) depends on git history that may or may not be available in shallow repos. I haven’t tested to see if it’s actually possible to manuallygit pushexp refs from anactions/checkoutGHA workflow (with the default shallowfetch-depth: 1), but in general any time you need togit pushanything in GHA I’m pretty sure the recommendation is to usefetch-depth: 0.Yes, the
example-repos-devis correctly configured soexp remove -gandexp pushboth work:https://github.com/iterative/example-repos-dev/blob/dcfd76301af427f9cc33f7e3e6248fa68669d16b/.devcontainer.json#L20-L22
I am currently debugging as I am not sure if it is something different, but
exp pushis also failing for me inside GitHub Codespaces