Skip to content

gitlab ci: Fix broken SPACK_CHECKOUT_VERSION#31963

Closed
scottwittenburg wants to merge 1 commit intospack:developfrom
scottwittenburg:ci-fix-spack-checkout-version
Closed

gitlab ci: Fix broken SPACK_CHECKOUT_VERSION#31963
scottwittenburg wants to merge 1 commit intospack:developfrom
scottwittenburg:ci-fix-spack-checkout-version

Conversation

@scottwittenburg
Copy link
Copy Markdown
Contributor

@scottwittenburg scottwittenburg commented Aug 5, 2022

fixes #31952

The generated .gitlab-ci.yml contains a variable SPACK_CHECKOUT_VERSION that generated child jobs should be able to use to checkout the version of spack that generated the pipeline. Since the value returned by spack.main.get_version() looks like 0.18.1.dev0 (<git-commit-sha>) these days, this PR updates the way the commit sha is extracted accordingly.

@spackbot-app spackbot-app bot added commands core PR affects Spack core functionality tests General test capability(ies) labels Aug 5, 2022
@scottwittenburg
Copy link
Copy Markdown
Contributor Author

@blue42u I think this fixes #31952.

@blue42u
Copy link
Copy Markdown
Contributor

blue42u commented Aug 6, 2022

This fixes #31952 unless the Spack instance is not a Git repository, in which case it's the bare Spack version (e.g. 0.19.0.dev0).

Would it be possible to move this git rev-parse call out into it's own function? It seems fragile having to reverse-engineer from the human readable version number.

git_path = os.path.join(spack.paths.prefix, ".git")
if os.path.exists(git_path):
git = exe.which("git")
if not git:
return version
rev = git(
"-C",
spack.paths.prefix,
"rev-parse",
"HEAD",
output=str,
error=os.devnull,
fail_on_error=False,
)
if git.returncode != 0:
return version


with ev.read("test"):
monkeypatch.setattr(spack.main, "get_version", lambda: "0.15.3-416-12ad69eb1")
monkeypatch.setattr(spack.main, "get_version", lambda: "0.19.0.dev0 (blah)")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love the sha256 example. 😉

@alecbcs
Copy link
Copy Markdown
Member

alecbcs commented Jul 9, 2023

@scottwittenburg should we close this PR now that #38778 is merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands core PR affects Spack core functionality tests General test capability(ies)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

spack ci generate: SPACK_CHECKOUT_VERSION cannot be checked out

4 participants