Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong reported version, while running under actions/checkout@v2 #414

Closed
skirpichev opened this issue Mar 29, 2020 · 15 comments
Closed

Wrong reported version, while running under actions/checkout@v2 #414

skirpichev opened this issue Mar 29, 2020 · 15 comments

Comments

@skirpichev
Copy link

E.g. in this build I got "0.1.dev1+g731594d", while correct one is something like "0.11.0a15.dev184+g5cbde2799".

@RonnyPfannschmidt
Copy link
Contributor

RonnyPfannschmidt commented Mar 29, 2020

Off hand the reason is not clear, can you add a SETUPTOOLS_SCM_DEBUG=1 setup.py --version call to get extra information

@skirpichev
Copy link
Author

See this build, linting step:

root '/home/runner/work/diofant/diofant'
looking for ep setuptools_scm.parse_scm /home/runner/work/diofant/diofant
found ep .git = setuptools_scm.git:parse
cmd 'git rev-parse --show-toplevel'
out b'/home/runner/work/diofant/diofant\n'
real root /home/runner/work/diofant/diofant
cmd 'git describe --dirty --tags --long --match *.*'
err b'fatal: No names found, cannot describe anything.\n'
ret 128
cmd 'git rev-parse --verify --quiet HEAD'
out b'767e300ac7b6f31ad456073028782874b4d5c101\n'
cmd 'git status --porcelain --untracked-files=no'
cmd 'git rev-list HEAD'
out b'767e300ac7b6f31ad456073028782874b4d5c101\n'
cmd 'git rev-parse --abbrev-ref HEAD'
out b'HEAD\n'
tag 0.0
tag '0.0' parsed to {'version': '0.0', 'prefix': '', 'suffix': ''}
version pre parse 0.0
version <Version('0.0')>
version 0.0 -> 0.0
scm version <ScmVersion 0.0 d=1 n=g767e300 d=False b=HEAD>
config {'version_scheme': 'guess-next-dev', 'local_scheme': 'node-and-date'}
ep ('setuptools_scm.version_scheme', 'guess-next-dev')
ep found: guess-next-dev
ep ('setuptools_scm.local_scheme', 'node-and-date')
ep found: node-and-date
version 0.1.dev1
local_version +g767e300
/home/runner/work/diofant/diofant/.eggs/setuptools_scm-3.5.0-py3.7.egg/setuptools_scm/git.py:68: UserWarning: "/home/runner/work/diofant/diofant" is shallow and may cause errors
0.1.dev1+g767e300
  warnings.warn('"{}" is shallow and may cause errors'.format(wd.path))

@RonnyPfannschmidt
Copy link
Contributor

It seems the clone depth is zero and no tags get loaded, which in turn takes away all of the Metadata setuprools_scm needs, please use a full clone

@skirpichev
Copy link
Author

Oh, I see. Probably, this recipe will work. But I would prefer to wait for a better solution, perhaps that PR. v1 version is working again, anyway...

Thank you for help. Feel free to close this bugreport or document this somewhere somehow...

@RonnyPfannschmidt
Copy link
Contributor

RonnyPfannschmidt commented May 3, 2020

for setuptools_scm 4.0 i will cause an error here

@chrisjbillington
Copy link
Contributor

Fetching all tagged commits doesn't solve the issue - git can't count the number of intervening commits, or even know which of the tagged commits is the closest parent to master. You need every commit in between.

Be nice if there was a kind of shallow clone where all commit objects from deeper than --depth were pulled in, and just not the tree objects they reference.

@webknjaz
Copy link
Member

@chrisjbillington here's a working example of how to do it in GHA: https://github.com/ansible/pylibssh/blob/1e7b17f/.github/workflows/build-test-n-publish.yml#L146-L151

(credit: @matthewfeickert)

@RonnyPfannschmidt
Copy link
Contributor

im closing this one as current suggestion is to fetch everything

#431 is a followup to make better workflows

@steven-murray
Copy link

steven-murray commented May 20, 2020

I'm having a problem with this -- I think it is related, but I guess maybe I'm missing something else.

Here's my workflow: https://github.com/steven-murray/hmf/pull/62/checks?check_run_id=694283873

Short problem: I am using

        run: |
          git fetch --prune --unshallow
          git fetch --depth=1 origin +refs/tags/*:refs/tags/*
          git describe --tags
          git describe --tags $(git rev-list --tags --max-count=1)

as described in the link posted above. The last two lines are printing

v3.0.9-8-g97882b1
v3.0.9

which is what I would expect.

However, I have a step after this that does

python -m pip install setuptools>=42 wheel setuptools_scm --user
python setup.py --version

to print out the version that setuptools_scm should be giving (should be 3.0.9.something). Instead, it's printing out 0.0.0 every time.

My full workflow is here: https://github.com/steven-murray/hmf/blob/pypi/.github/workflows/publish-to-pypi.yaml

Any help would be much appreciated!

@webknjaz
Copy link
Member

@steven-murray it's unrelated. You use a legacy setup.py invocation but forgot to configure it: https://github.com/pypa/setuptools_scm#setuppy-usage.

@steven-murray
Copy link

@webknjaz thank you, that did it. I didn't realize that merely having a setup.py would cause it to break. I now have both the pyproject.toml and entry in setup() and it's working. Thanks again!

@webknjaz
Copy link
Member

@steven-murray I think it wasn't about having setup.py but about invoking it directly.

@webknjaz
Copy link
Member

webknjaz commented Jun 26, 2020

FTR I've faced another interesting incarnation of this.
I use:

          git fetch --prune --unshallow
          git fetch --depth=1 origin +refs/tags/*:refs/tags/*

followed by removing the tags from HEAD for pushes to devel (it's my solution to a certain race condition).
And this works under Ubuntu. But in macOS builders, Git doesn't seem to be able to detect the previous tag and falls back to v0.1 too. (Even though the previous tag is just one commit back, as in depth=1)

Just wanted to document this corner case.
Refs:

@RonnyPfannschmidt
Copy link
Contributor

@webknjaz please open a new issue and consider rerunning with debug

@webknjaz
Copy link
Member

I don't think this is necessary. It's probably not this project's fault. I only wanted to document this so that it'd be useful to folks coming to this page from Google.

nicklasl added a commit to spotify/confidence-sdk-python that referenced this issue Sep 15, 2023
majamassarini added a commit to packit/packit that referenced this issue Nov 20, 2023
With version
[0.86.0](https://github.com/packit/packit/actions/runs/6901837024) the
**pypi_bublish** action is failing.
The failing command is `python -m build` which is retrieving a *wrong
version*.
If you clone the repo and you run `python -m build` you get the correct
version.
But if you run `python -m build` in this container, which is doing more
or less what the github **checkout** action does, you get the wrong
version.

```FROM ubuntu:latest

RUN apt-get update && apt-get install -y --no-install-recommends \
git \
python3 \
python3.10-venv \
python3-pip
RUN git config --global --add safe.directory /packit
RUN git config --global init.defaultBranch main
RUN git init /packit
WORKDIR /packit
RUN git remote add origin https://github.com/packit/packit
RUN git config --local gc.auto 0
RUN git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :"
RUN git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'http\.https\:\/\/github\.com\/\.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :"
#RUN git config --local http.https://github.com/.extraheader AUTHORIZATION: basic ***
RUN git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin 44f90cd
RUN git checkout --progress --force 44f90cd
RUN git fetch --prune --unshallow
RUN git fetch --depth=1 origin +refs/tags/*:refs/tags/*
``` 

A [thread](pypa/setuptools-scm#414) about the
problem.
And thanks to @webknjaz
[solution](https://github.com/ansible/pylibssh/blob/1e7b17f/.github/workflows/build-test-n-publish.yml#L146-L151)
adding this two lines of code to the container makes **scm** work again.
eapolinario added a commit to flyteorg/flytekit that referenced this issue Dec 20, 2023
eapolinario added a commit to flyteorg/flytekit that referenced this issue Dec 21, 2023
* Enable python 3.12

Signed-off-by: Eduardo Apolinario <[email protected]>

* Relax the constraints on tensorflow

Signed-off-by: Eduardo Apolinario <[email protected]>

* wip - split tensorflow tests

Signed-off-by: Eduardo Apolinario <[email protected]>

* Run on python 3.12

Signed-off-by: Eduardo Apolinario <[email protected]>

* Split tensorflow unit tests in their own tests

Signed-off-by: Eduardo Apolinario <[email protected]>

* Fix typo in dev-requirements.in

Signed-off-by: Eduardo Apolinario <[email protected]>

* Run extra unit tests in separate step

Signed-off-by: Eduardo Apolinario <[email protected]>

* Remove windows restriction

Signed-off-by: Eduardo Apolinario <[email protected]>

* Fix unit_test_extras make target

Signed-off-by: Eduardo Apolinario <[email protected]>

* Fix typo in makefile and version restriction in dev-requirements.in

Signed-off-by: Eduardo Apolinario <[email protected]>

* Add support for 3.12 in default_images.py

Signed-off-by: Eduardo Apolinario <[email protected]>

* Modify regex in dataclass tests

Signed-off-by: Eduardo Apolinario <[email protected]>

* Rename step in pythonbuild gh workflow

Signed-off-by: Eduardo Apolinario <[email protected]>

* Enable 3.12 in serialization tests

Signed-off-by: Eduardo Apolinario <[email protected]>

* Read python versions from env var

Signed-off-by: Eduardo Apolinario <[email protected]>

* Revert "Read python versions from env var"

This reverts commit 6d0fb12.

Signed-off-by: Eduardo Apolinario <[email protected]>

* Run integration tests on 3.12

Signed-off-by: Eduardo Apolinario <[email protected]>

* Use bookworm as base image

Signed-off-by: Eduardo Apolinario <[email protected]>

* Restrict ydata-profiling

Signed-off-by: Eduardo Apolinario <[email protected]>

* Install latest flytekit

Signed-off-by: Eduardo Apolinario <[email protected]>

* Mount .git in dev image and output version

Signed-off-by: Eduardo Apolinario <[email protected]>

* Cat dynamic version in integration test gh workflow

Signed-off-by: Eduardo Apolinario <[email protected]>

* Use solution described in pypa/setuptools-scm#414

Signed-off-by: Eduardo Apolinario <[email protected]>

* Remove investigation aids

Signed-off-by: Eduardo Apolinario <[email protected]>

* Install pandas in deck plugin

Signed-off-by: Eduardo Apolinario <[email protected]>

* Revert bump of flytekit version in pod plugin

Signed-off-by: Eduardo Apolinario <[email protected]>

* Combine installation of flytekit and plugins in dev image

Signed-off-by: Eduardo Apolinario <[email protected]>

* Test setting fetch-depth: 0

Signed-off-by: Eduardo Apolinario <[email protected]>

* Use with stanza

Signed-off-by: Eduardo Apolinario <[email protected]>

* Comment need for fetch-depth: 0

Signed-off-by: Eduardo Apolinario <[email protected]>

---------

Signed-off-by: Eduardo Apolinario <[email protected]>
Co-authored-by: Eduardo Apolinario <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants