operator icon indicating copy to clipboard operation
operator copied to clipboard

Our charm tests that inject ops from github branch sometime trip on git reference

Open dimaqq opened this issue 10 months ago • 3 comments

Run if [ -e "requirements.txt" ]; then
  if [ -e "requirements.txt" ]; then
    sed -i -e "/^ops[ ><=]/d" -e "/canonical\/operator/d" -e "/#egg=ops/d" requirements.txt
    echo -e "\ngit+$GITHUB_SERVER_URL/$GITHUB_REPOSITORY@$GITHUB_SHA#egg=ops" >> requirements.txt
    sed -i -e "/^ops-scenario[ ><=]/d" -e "/^ops\[testing\][ ><=]/d" requirements.txt
    echo -e "\ngit+$GITHUB_SERVER_URL/$GITHUB_REPOSITORY@$GITHUB_SHA#egg=ops-scenario&subdirectory=testing" >> requirements.txt
  elif [ -e "uv.lock" ]; then
    uv remove ops --optional dev --frozen || echo "maybe ops[testing] is not a dev dependency"
    uv remove ops-scenario --optional dev --frozen || echo "maybe ops-scenario is not a dev dependency"
    uv remove ops --frozen
    uv add git+$GITHUB_SERVER_URL/$GITHUB_REPOSITORY@$GITHUB_SHA --raw-sources --prerelease=if-necessary-or-explicit
    uv add git+$GITHUB_SERVER_URL/$GITHUB_REPOSITORY@$GITHUB_SHA#subdirectory=testing --optional dev --raw-sources --prerelease=if-necessary-or-explicit
  else
    echo "Error: no requirements.txt or uv.lock file found"
    exit 1
  fi
  shell: /usr/bin/bash -e {0}
error: The dependency `ops-scenario` could not be found in `project.optional-dependencies.dev`
maybe ops-scenario is not a dev dependency
Using CPython 3.1[2](https://github.com/canonical/operator/actions/runs/15774568933/job/44465987369?pr=1842#step:4:2).3 interpreter at: /usr/bin/python[3](https://github.com/canonical/operator/actions/runs/15774568933/job/44465987369?pr=1842#step:4:3)
Creating virtual environment at: .venv
   Updating https://github.com/canonical/operator (92969e31e6169ccd1ca2[4](https://github.com/canonical/operator/actions/runs/15774568933/job/44465987369?pr=1842#step:4:4)5187522c9d9722e5535)
error: Git operation failed
  Caused by: failed to find branch, tag, or commit `92969e31e6169ccd1ca24[5](https://github.com/canonical/operator/actions/runs/15774568933/job/44465987369?pr=1842#step:4:5)187522c9d9722e5535`
  Caused by: process didn't exit successfully: `/usr/bin/git rev-parse '929[6](https://github.com/canonical/operator/actions/runs/15774568933/job/44465987369?pr=1842#step:4:6)9e31e6169ccd1ca245187522c9d9722e5535^0'` (exit status: 128)
--- stdout
92969e31e6169ccd1ca245187522c9d9722e5535^0

--- stderr
fatal: ambiguous argument '92969e31e6169ccd1ca24518[7](https://github.com/canonical/operator/actions/runs/15774568933/job/44465987369?pr=1842#step:4:7)522c9d9722e5535^0': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

dimaqq avatar Jun 20 '25 08:06 dimaqq

Weirdly only one test out of three we run in parallel trips on this. I wonder if this could have something to do with distributed nature of GitHub:

  • I push a commit to my branch with an open PR
  • GitHub Actions job is kicked off
  • The checkout step works fine evidently
  • But the python dep reference pointing to the same commit cannot be resolved?

Image

dimaqq avatar Jun 20 '25 08:06 dimaqq

I've started a discussion upstream: https://github.com/orgs/community/discussions/164558

dimaqq avatar Jun 30 '25 05:06 dimaqq

Build ops from local checkout and inject that into the 3rd party charm.

Alternatively: Retry! or sleep. But the first option seems much cleaner.

benhoyt avatar Sep 09 '25 03:09 benhoyt