diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2519e8ba2b7c3bac12dd163af95a13368fd0d90c..c0f40b6f48c44f1aabbe50b9c3778daf13f9c3d0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,17 +1,7 @@ -# Copyright © 2022 Idiap Research Institute <contact@idiap.ch> +# SPDX-FileCopyrightText: Copyright © 2022 Idiap Research Institute <contact@idiap.ch> # # SPDX-License-Identifier: BSD-3-Clause include: - project: software/dev-profile - file: /gitlab/python.yml - - -documentation: - image: quay.io/condaforge/linux-anvil-cos7-x86_64 - before_script: - - rm -f /home/conda/.condarc - - mamba update --override-channels -c conda-forge -n base --all - - eval "$(/opt/conda/bin/conda shell.bash hook)" - - conda activate base - - pip install --pre --index-url https://gitlab.idiap.ch/api/v4/groups/software/-/packages/pypi/simple --extra-index-url https://pypi.org/simple '.[doc]' sphinx + file: /gitlab/python+rtd.yml diff --git a/conda/meta.yaml b/conda/meta.yaml index fe1009a621e61cce85320bec7bbd146ceccdb4eb..3cdc200681aee6ceaf18ef84b73e570c6f957d33 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -41,6 +41,7 @@ requirements: - gitpython - python-gitlab - python-dateutil + - pytz - setuptools - xdg diff --git a/pyproject.toml b/pyproject.toml index 021d766c655ac42996eaca21e0fb44d7c5c28415..418c322b7d2c7e3abf35a12c9f391f3e8082bfac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,6 +31,7 @@ dependencies = [ "packaging", "python-dateutil", "python-gitlab", + "pytz", "pyyaml", "setuptools", "tomli", diff --git a/src/idiap_devtools/scripts/gitlab/release.py b/src/idiap_devtools/scripts/gitlab/release.py index 886107fb6595acda777d8bbba6bc1dd4a89b7464..51278b27e6afd59e58be3d4e4608cfe0a5421595 100644 --- a/src/idiap_devtools/scripts/gitlab/release.py +++ b/src/idiap_devtools/scripts/gitlab/release.py @@ -9,7 +9,7 @@ import typing import click from idiap_devtools.click import validate_profile -from idiap_devtools.profile import Profile +from idiap_devtools.profile import Profile, get_profile_path from ...click import PreserveIndentCommand, verbosity_option from ...logging import setup @@ -26,7 +26,7 @@ Examples: .. code:: sh - devtool gitlab release --profile=default -vv changelog.md + devtool gitlab release -vv changelog.md .. tip:: @@ -38,7 +38,21 @@ Examples: .. code:: sh - devtool gitlab release --profile=default -vv --dry-run changelog.md + devtool gitlab release -vv --dry-run changelog.md + + 3. You may also pin package dependencies upon the release, so that the + shipped package respects a particular development profile set of pins: + + .. code:: sh + + devtool gitlab release -vv --pin-dependencies changelog.md + + The `default` profile is used, if set on your configuration file. + Otherwise, you may specify it explicitly like: + + .. code:: sh + + devtool gitlab release -vv --profile=specific --pin-dependencies changelog.md """, ) @@ -46,12 +60,21 @@ Examples: @click.option( "-P", "--profile", - default=None, + default="default", show_default=True, + callback=validate_profile, help="Directory containing the development profile (and a file named " "profile.toml), or the name of a configuration key pointing to the " "development profile to use", ) +@click.option( + "-p", + "--pin-dependencies/--no-pin-dependencies", + default=False, + help="If set, then pin dependencies from the dev-profile on the package " + "to be released. By default your default dev-profile is used. You may " + "override this using the --profile option", +) @click.option( "-d", "--dry-run/--no-dry-run", @@ -63,8 +86,9 @@ Examples: @verbosity_option(logger=logger) def release( changelog: typing.TextIO, - dry_run: bool, profile: str, + pin_dependencies: bool, + dry_run: bool, **_, ) -> None: """Tags packages on GitLab from an input CHANGELOG in markdown format. @@ -74,7 +98,8 @@ def release( in order): * Modifies ``pyproject.toml`` with the new release number and pins the - dependencies according to the specified profile's constraints + dependencies according to the specified profile's constraints (if one + was specified) * Sets-up the README links to point to the correct pipeline and documentation for the package * Commits, tags and pushes the git project adding the changelog @@ -85,8 +110,10 @@ def release( pipeline versions * Re-commits and pushes the whole with the option ``[ci skip]``. - When a dev-profile is given (with ``--profile``), the versions of the dependencies - in ``pyproject.toml`` will be pinned to those of the ``constraints.txt`` file. + N.B.: When the option ``pin-dependencies`` is set, the versions of the + dependencies in ``pyproject.toml`` will be pinned to those of the Python + ``constraints.txt`` file available in the select development profile + (choose using option ``--profile``). The changelog is expected to have the following structure: @@ -128,18 +155,6 @@ def release( gl = get_gitlab_instance() - if profile is None: - logger.warning( - "No dev-profile given. There will be no dependencies version pinning. " - "To enable pinning, set the --profile option." - ) - else: - profile = validate_profile(None, None, profile) - logger.info( - "Loading profile '%s' for dependencies version pinning.", profile - ) - loaded_profile = Profile(profile) - # traverse all packages in the changelog, edit older tags with updated # comments, tag them with a suggested version, then try to release, and # wait until done to proceed to the next package @@ -155,9 +170,22 @@ def release( ] if dry_run: - click.secho("!!!! DRY RUN MODE !!!!", fg="yellow", bold=True) click.secho( - "No changes will be committed to GitLab.", fg="yellow", bold=True + "DRY RUN MODE: No changes will be committed to GitLab.", + fg="yellow", + bold=True, + ) + + # loads profile data + if pin_dependencies: + the_profile = Profile(profile) + logger.info( + f"Pinning dependencies from profile `{get_profile_path(profile)}'...", + ) + else: + the_profile = None + logger.warning( + "Not pinning dependencies (use --pin-dependencies to change this).", ) for pkg_number, (header, line) in enumerate(pkgs): @@ -223,7 +251,7 @@ def release( tag_name=vtag, tag_comments=description_text, dry_run=dry_run, - profile=loaded_profile, + profile=the_profile, ) if not dry_run: # now, wait for the pipeline to finish, before we can release the