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

deploy: automatic version bumps #2097

Open
wants to merge 16 commits into
base: develop
Choose a base branch
from
Open

Conversation

bbpbuildbot
Copy link
Collaborator

New script that will automatically create new versions of certain packages

@heerener
Copy link
Collaborator

Used curl to file the pull request to validate the parameters, with the API key that will be used by the job.

@bbpbuildbot
Copy link
Collaborator Author

Thank you for your pull request!

Should you want to clear the PR build directory after failures, please use this pipeline. Before running the cleanup pipeline, please ensure that any PR building pipelines have been cancelled or finished running.

@bbpbuildbot
Copy link
Collaborator Author

To test your PR, use the following on BlueBrain5:

unset MODULEPATH
. /gpfs/bbp.cscs.ch/ssd/apps/bsd/pulls/2097/config/modules.sh
module load unstable

@bbpbuildbot
Copy link
Collaborator Author

To test your PR, use the following on BlueBrain5:

unset MODULEPATH
. /gpfs/bbp.cscs.ch/ssd/apps/bsd/pulls/2097/config/modules.sh
module load unstable

6 similar comments
@bbpbuildbot
Copy link
Collaborator Author

To test your PR, use the following on BlueBrain5:

unset MODULEPATH
. /gpfs/bbp.cscs.ch/ssd/apps/bsd/pulls/2097/config/modules.sh
module load unstable

@bbpbuildbot
Copy link
Collaborator Author

To test your PR, use the following on BlueBrain5:

unset MODULEPATH
. /gpfs/bbp.cscs.ch/ssd/apps/bsd/pulls/2097/config/modules.sh
module load unstable

@bbpbuildbot
Copy link
Collaborator Author

To test your PR, use the following on BlueBrain5:

unset MODULEPATH
. /gpfs/bbp.cscs.ch/ssd/apps/bsd/pulls/2097/config/modules.sh
module load unstable

@bbpbuildbot
Copy link
Collaborator Author

To test your PR, use the following on BlueBrain5:

unset MODULEPATH
. /gpfs/bbp.cscs.ch/ssd/apps/bsd/pulls/2097/config/modules.sh
module load unstable

@bbpbuildbot
Copy link
Collaborator Author

To test your PR, use the following on BlueBrain5:

unset MODULEPATH
. /gpfs/bbp.cscs.ch/ssd/apps/bsd/pulls/2097/config/modules.sh
module load unstable

@bbpbuildbot
Copy link
Collaborator Author

To test your PR, use the following on BlueBrain5:

unset MODULEPATH
. /gpfs/bbp.cscs.ch/ssd/apps/bsd/pulls/2097/config/modules.sh
module load unstable

Copy link

@olupton olupton left a comment

Choose a reason for hiding this comment

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

Just had a quick skim through.

I'm not sure if you considered this, but note that we have some similar logic for manipulating recipes - implemented as a custom Spack command - in https://github.com/BlueBrain/spack/blob/develop/bluebrain/spack-scripting/scripting/cmd/configure_pipeline.py; we use that for configuring Spack in CI pipelines. One still has to fudge the recipe .py somewhat manually, but you would avoid having to parse the recipes to extract the versions and so on.

Up to you.

bluebrain/version-bumping/src/bumper.py Show resolved Hide resolved
@heerener
Copy link
Collaborator

Just had a quick skim through.

I'm not sure if you considered this, but note that we have some similar logic for manipulating recipes - implemented as a custom Spack command - in https://github.com/BlueBrain/spack/blob/develop/bluebrain/spack-scripting/scripting/cmd/configure_pipeline.py; we use that for configuring Spack in CI pipelines. One still has to fudge the recipe .py somewhat manually, but you would avoid having to parse the recipes to extract the versions and so on.

Up to you.

I hadn't seen that specific code, but it does answer my initial "how do I get the package object in a clean way". Replacing the current code with something similar is definitely possible and gets rid of a regex and makes get_latest_spack_version somewhat simpler, so I'm in favor of it.

I'm still reading the source to insert the new version though

@bbpbuildbot
Copy link
Collaborator Author

To test your PR, use the following on BlueBrain5:

unset MODULEPATH
. /gpfs/bbp.cscs.ch/ssd/apps/bsd/pulls/2097/config/modules.sh
module load unstable

@heerener heerener requested a review from matz-e August 30, 2023 08:09
@bbpbuildbot
Copy link
Collaborator Author

To test your PR, use the following on BlueBrain5:

unset MODULEPATH
. /gpfs/bbp.cscs.ch/ssd/apps/bsd/pulls/2097/config/modules.sh
module load unstable

Copy link
Member

Choose a reason for hiding this comment

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

I think it would be good to have this be a proper Spack extension in the scripting part. That would also allow to quickly check versions on BB5 manually.

Comment on lines +110 to +117
if "CI_JOB_TOKEN" in os.environ:
logger.debug("CI_JOB_TOKEN found - running on gitlab")
package_git_url = (
f"https://gitlab-ci-token:{os.environ['CI_JOB_TOKEN']}@{package_git_url}"
)
else:
logger.debug("CI_JOB_TOKEN not found - SSH should be configured on your machine")
package_git_url = f"ssh://{package_git_url}"
Copy link
Member

Choose a reason for hiding this comment

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

This could be done with the same logic we already have in gitlab-pipelines, outside of Python. Then we don't need to know about tokens and all that in the Python part (and don't have to modify git URLs)

logger.info(f"===> Adding version {latest_source_version} for {package}")
source_lines = self.get_source_lines(package_file)
for idx, line in enumerate(source_lines):
if line.strip().startswith("version("):
Copy link
Member

Choose a reason for hiding this comment

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

could be a regexp... r"^( )+version\(". But actually: we don't want to add version directives into nested statements. Those are normally indicative of a programmatic approach to version bumping. Thus a fixed indent of 4 should be checked and used?

Comment on lines +14 to +15
sys.path.append("./lib/spack/")
sys.path.append("./lib/spack/external/")
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't be needed if this were a proper extension.

Comment on lines +42 to +52
PACKAGES = {
"brayns": {"tag_regex": re.compile(r"\d+\.\d+\.\d+")},
"brainbuilder": {
"tag_regex": re.compile(r"brainbuilder-v\d+\.\d+\.\d+"),
"tag_strip": "brainbuilder-",
},
"synapsetool": {"tag_regex": re.compile(r"v\d+\.\d+\.\d+")},
"regiodesics": {"tag_regex": re.compile(r"\d+\.\d+\.\d+")},
"touchdetector": {"tag_regex": re.compile(r"\d+\.\d+\.\d+")},
"spykfunc": {"tag_regex": re.compile(r"v\d+\.\d+\.\d+")},
}
Copy link
Member

Choose a reason for hiding this comment

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

So... Why not do it all in Spack?

Could query our repositories for packages and updates like this:

#!/usr/bin/env spack-python

import re

from spack.version import Version
from spack.util.executable import which

VERSION_RE = re.compile(r'(?:([^0-9].+)-)?v?(\d+\.\d+(?:\.\d+)*)$')


def homogenize(s: str):
    if s.startswith("py-"):
        s = s[3:]
    return s.lower().replace("-", "").replace("_", "")

repo = spack.repo.path.get_repo("bluebrain")
pkgs = repo.all_package_classes()
git = which("git")

for pkg in pkgs:
    print(pkg.name)
    if url := getattr(pkg, "git", None):
        most_recent = max([v for v in pkg.versions if not v.isdevelop()])
        candidates = []
        tags = {}
        for l in git("ls-remote", "--tags", url, output=str).splitlines():
            if l.endswith("{}"):
                continue
            _, tag = l.rsplit("/", 1)
            if m := VERSION_RE.search(tag):
                prefix, version = m.groups()
                if prefix and homogenize(prefix) != homogenize(pkg.name):
                    continue
                candidates.append(Version(version))
                tags[Version(version)] = tag
        if not candidates:
            continue
        most_recent_found =  max(candidates)
        if most_recent_found > most_recent:
            print(f"Current version:   {most_recent}")
            print(f"New version:       {most_recent_found} - {tags[most_recent_foun
d]}")
            print(url)

@matz-e
Copy link
Member

matz-e commented Aug 30, 2023

Oh, and the source of spack checksum could be very helpful for the packages that don't use tags but have something like pypi.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants