From 3d5dda60b2f4070bcda24009286c5db0feae757c Mon Sep 17 00:00:00 2001 From: Andre Anjos <andre.dos.anjos@gmail.com> Date: Fri, 22 Feb 2019 13:37:44 +0100 Subject: [PATCH] [scripts] Move scripts dealing with gitlab within its own group --- bob/devtools/scripts/changelog.py | 14 +++++++------- bob/devtools/scripts/commitfile.py | 6 +++--- bob/devtools/scripts/getpath.py | 6 +++--- bob/devtools/scripts/gitlab.py | 21 +++++++++++++++++++++ bob/devtools/scripts/lasttag.py | 4 ++-- bob/devtools/scripts/release.py | 10 +++++----- bob/devtools/scripts/visibility.py | 6 +++--- conda/meta.yaml | 23 ++++++++++++----------- doc/release.rst | 16 ++++++++-------- setup.py | 17 +++++++++++------ 10 files changed, 75 insertions(+), 48 deletions(-) create mode 100644 bob/devtools/scripts/gitlab.py diff --git a/bob/devtools/scripts/changelog.py b/bob/devtools/scripts/changelog.py index 0f3c1c2a..1edb25ed 100644 --- a/bob/devtools/scripts/changelog.py +++ b/bob/devtools/scripts/changelog.py @@ -20,33 +20,33 @@ Examples: 1. Generates the changelog for a single package using merge requests: - $ bdt changelog group/package.xyz changelog.md + $ bdt gitlab changelog group/package.xyz changelog.md 2. The same as above, but dumps the changelog to stdout instead of a file: - $ bdt changelog group/package.xyz + $ bdt gitlab changelog group/package.xyz 3. Generates the changelog for a single package looking at commits (not merge requests): - $ bdt changelog --mode=commits group/package.xyz changelog.md + $ bdt gitlab changelog --mode=commits group/package.xyz changelog.md 4. Generates the changelog for a single package looking at merge requests starting from a given date of January 1, 2016: \b - $ bdt changelog --mode=mrs --since=2016-01-01 group/package.xyz changelog.md + $ bdt gitlab changelog --mode=mrs --since=2016-01-01 group/package.xyz changelog.md 5. Generates a complete list of changelogs for a list of packages (one per line: \b - $ bdt getpath bob/bob.nightlies order.txt - $ bdt lasttag bob/bob + $ bdt gitlab getpath bob/bob.nightlies order.txt + $ bdt gitlab lasttag bob/bob # copy and paste date to next command - $ bdt changelog --since="2018-07-17 10:23:40" order.txt changelog.md + $ bdt gitlab changelog --since="2018-07-17 10:23:40" order.txt changelog.md ''') @click.argument('target') @click.argument('changelog', type=click.Path(exists=False, dir_okay=False, diff --git a/bob/devtools/scripts/commitfile.py b/bob/devtools/scripts/commitfile.py index 9edcab34..154e8fc5 100644 --- a/bob/devtools/scripts/commitfile.py +++ b/bob/devtools/scripts/commitfile.py @@ -17,19 +17,19 @@ Examples: 1. Replaces the README.rst file on the package bob/bob.extension, through a direct commit to the master branch, using the contents of the local file with the same name: - $ bdt commitfile -vv bob/bob.extension README.rst + $ bdt gitlab commitfile -vv bob/bob.extension README.rst 2. Replaces the README.rst file on the package beat/beat.core, specifying a commit message: \b - $ bdt commitfile -vv --message="[readme] Update [ci skip]" beat/beat.core README.rst + $ bdt gitlab commitfile -vv --message="[readme] Update [ci skip]" beat/beat.core README.rst 3. Replaces the file conda/meta.yaml on the package bob/bob.blitz through a merge request through a new branch called "conda-changes", specifying a commit/merge-request message, using the contents of the local file new.yaml, and setting the merge-request property "merge-when-pipeline-succeeds": \b - $ bdt commitfile -vv bob/bob.blitz --path=conda/meta.yaml --branch=conda-changes --auto-merge new.yaml + $ bdt gitlab commitfile -vv bob/bob.blitz --path=conda/meta.yaml --branch=conda-changes --auto-merge new.yaml ''') @click.argument('package') diff --git a/bob/devtools/scripts/getpath.py b/bob/devtools/scripts/getpath.py index b8105a8e..22f80164 100644 --- a/bob/devtools/scripts/getpath.py +++ b/bob/devtools/scripts/getpath.py @@ -16,17 +16,17 @@ Examples: 1. Get the file ``order.txt`` from bob.nightlies master branch: - $ bdt getpath bob/bob.nightlies order.txt + $ bdt gitlab getpath bob/bob.nightlies order.txt 2. Get the file ``order.txt`` from a different branch ``2.x``: - $ bdt getpath --ref=2.x bob/bob.nightlies order.txt + $ bdt gitlab getpath --ref=2.x bob/bob.nightlies order.txt 3. Get the directory ``gitlab`` (and eventual sub-directories) from bob.admin, save outputs in directory ``_ci``: - $ bdt getpath bob/bob.admin master gitlab _ci + $ bdt gitlab getpath bob/bob.admin master gitlab _ci ''') @click.argument('package') @click.argument('path') diff --git a/bob/devtools/scripts/gitlab.py b/bob/devtools/scripts/gitlab.py new file mode 100644 index 00000000..537a5e64 --- /dev/null +++ b/bob/devtools/scripts/gitlab.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python + +import os + +import pkg_resources + +import click +from click_plugins import with_plugins + +from . import bdt + + +@with_plugins(pkg_resources.iter_entry_points('bdt.gitlab.cli')) +@click.group(cls=bdt.AliasedGroup) +def gitlab(): + """Commands for that interact with gitlab + + Commands defined here are supposed to interact with gitlab, and + add/modify/remove resources on it directly. + """ + pass diff --git a/bob/devtools/scripts/lasttag.py b/bob/devtools/scripts/lasttag.py index a6fdc114..e7d0d63c 100644 --- a/bob/devtools/scripts/lasttag.py +++ b/bob/devtools/scripts/lasttag.py @@ -18,12 +18,12 @@ Examples: 1. Get the last tag information of the bob/bob package - $ bdt lasttag bob/bob + $ bdt gitlab lasttag bob/bob 2. Get the last tag information of the beat/beat.core package - $ bdt lasttag beat/beat.core + $ bdt gitlab lasttag beat/beat.core ''') @click.argument('package') diff --git a/bob/devtools/scripts/release.py b/bob/devtools/scripts/release.py index 0a350f65..502f5001 100644 --- a/bob/devtools/scripts/release.py +++ b/bob/devtools/scripts/release.py @@ -20,28 +20,28 @@ Examples: 1. Releases a single package: - $ bdt release --package=bob.package.xyz changelog.md + $ bdt gitlab release --package=bob.package.xyz changelog.md 2. If there is a single package in the ``changelog.md`` file, the flag ``--package`` is not required: - $ bdt release changelog.md + $ bdt gitlab release changelog.md 2. Releases the whole of bob using `changelog_since_last_release.md`: - $ bdt release bob/devtools/data/changelog_since_last_release.md + $ bdt gitlab release bob/devtools/data/changelog_since_last_release.md 3. In case of errors, resume the release of the whole of Bob: - $ bdt release --resume bob/devtools/data/changelog_since_last_release.md + $ bdt gitlab release --resume bob/devtools/data/changelog_since_last_release.md 4. The option `-dry-run` can be used to let the script print what it would do instead of actually doing it: - $ bdt release --dry-run changelog_since_last_release.md + $ bdt gitlab release --dry-run changelog_since_last_release.md ''' ) @click.argument('changelog', type=click.File('rt', lazy=False)) diff --git a/bob/devtools/scripts/visibility.py b/bob/devtools/scripts/visibility.py index 263fc144..ee24cebb 100644 --- a/bob/devtools/scripts/visibility.py +++ b/bob/devtools/scripts/visibility.py @@ -18,14 +18,14 @@ Examples: 1. Check the visibility of a package you can access - $ bdt visibility bob/bob.extension + $ bdt gitlab visibility bob/bob.extension 2. Checks the visibility of all packages in a file list: \b - $ bdt getpath bob/bob.nightlies order.txt - $ bdt visibility order.txt + $ bdt gitlab getpath bob/bob.nightlies order.txt + $ bdt gitlab visibility order.txt ''') @click.argument('target') @click.option('-g', '--group', default='bob', show_default=True, diff --git a/conda/meta.yaml b/conda/meta.yaml index c52062c6..32af26cf 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -55,27 +55,28 @@ test: - bdt -h - bdt -? - bdt --help - - bdt lasttag --help - #- bdt lasttag -vv bob/bob.devtools - - bdt commitfile --help - - bdt changelog --help - #- bdt changelog -vv bob/bob.devtools changelog.md - - bdt release --help - #- bdt release -vvd changelog.md - - bdt visibility --help - #- bdt visibility -vv bob/bob.devtools - bdt dumpsphinx --help - bdt dumpsphinx https://docs.python.org/3/objects.inv > /dev/null - bdt create --help - bdt build --help - bdt test --help - - bdt getpath --help - #- bdt getpath -vv bob/bob.devtools .gitignore - bdt caupdate --help - bdt new --help - bdt new -t "New package" -o bob.foobar bob/bob.foobar "John Doe" "joe.doe@example.com" - bdt new -t "New package" -l bsd -o bob.foobar2 bob/bob.foobar "John Doe" "joe.doe@example.com" - bdt new -t "New package" -l bsd -o beat.foobar beat/beat.foobar "John Doe" "joe.doe@example.com" + - bdt gitlab --help + - bdt gitlab lasttag --help + #- bdt gitlab lasttag -vv bob/bob.devtools + - bdt gitlab commitfile --help + - bdt gitlab changelog --help + #- bdt gitlab changelog -vv bob/bob.devtools changelog.md + - bdt gitlab release --help + #- bdt gitlab release -vvd changelog.md + - bdt gitlab visibility --help + #- bdt gitlab visibility -vv bob/bob.devtools + - bdt gitlab getpath --help + #- bdt gitlab getpath -vv bob/bob.devtools .gitignore - bdt ci --help - bdt ci base-build --help - bdt ci build --help diff --git a/doc/release.rst b/doc/release.rst index 60d3e9cc..bcb5a77a 100644 --- a/doc/release.rst +++ b/doc/release.rst @@ -19,8 +19,8 @@ Usage Using these scripts is a 2-step process: -1. Generate a changelog using ``bdt changelog`` -2. Tag a release using ``bdt release`` +1. Generate a changelog using ``bdt gitlab changelog`` +2. Tag a release using ``bdt gitlab release`` Use the ``--help`` flag in each command to learn more about each command. @@ -46,7 +46,7 @@ Manually update changelog The changelog since the last release can be found in the file ``bob/devtools/data/changelog_since_last_release.md``. The structure is -documented as part of the help message of ``bdt release``. Read it. +documented as part of the help message of ``bdt gitlab release``. Read it. To manually update the changelog, follow these guidelines: @@ -77,15 +77,15 @@ Here are the instructions to release Bob meta package: .. code-block:: sh - $ bdt getpath bob/bob.nightlies order.txt - $ bdt visibility order.txt + $ bdt gitlab getpath bob/bob.nightlies order.txt + $ bdt gitlab visibility order.txt * Put the list of public packages in ../../bob/requirements.txt -* Run ``bdt changelog`` first: +* Run ``bdt gitlab changelog`` first: .. code-block:: sh - $ bdt changelog ../../bob/requirements.txt bob_changelog.md + $ bdt gitlab changelog ../../bob/requirements.txt bob_changelog.md * Put the beta of version of the intended release version in ``../../bob/version.txt`` @@ -97,7 +97,7 @@ Here are the instructions to release Bob meta package: .. code-block:: sh - $ bdt release -p bob -c bob_changelog.md --bob-version 5.0.0 -- TOKEN + $ bdt gitlab release -p bob -c bob_changelog.md --bob-version 5.0.0 -- TOKEN * Put the pinnings below in requirements.txt and meta.yaml (like ``bob.buildout == 2.1.6``) and meta.yaml (like ``bob.buildout 2.1.6``) diff --git a/setup.py b/setup.py index f9ab5ce5..ae8e42e9 100644 --- a/setup.py +++ b/setup.py @@ -46,19 +46,23 @@ setup( 'bdt = bob.devtools.scripts.bdt:main', ], 'bdt.cli': [ - 'release = bob.devtools.scripts.release:release', 'new = bob.devtools.scripts.new:new', - 'commitfile = bob.devtools.scripts.commitfile:commitfile', - 'changelog = bob.devtools.scripts.changelog:changelog', - 'lasttag = bob.devtools.scripts.lasttag:lasttag', - 'visibility = bob.devtools.scripts.visibility:visibility', 'dumpsphinx = bob.devtools.scripts.dumpsphinx:dumpsphinx', 'create = bob.devtools.scripts.create:create', 'build = bob.devtools.scripts.build:build', 'test = bob.devtools.scripts.test:test', - 'getpath = bob.devtools.scripts.getpath:getpath', 'caupdate = bob.devtools.scripts.caupdate:caupdate', 'ci = bob.devtools.scripts.ci:ci', + 'gitlab = bob.devtools.scripts.gitlab:gitlab', + ], + + 'bdt.gitlab.cli': [ + 'commitfile = bob.devtools.scripts.commitfile:commitfile', + 'release = bob.devtools.scripts.release:release', + 'changelog = bob.devtools.scripts.changelog:changelog', + 'lasttag = bob.devtools.scripts.lasttag:lasttag', + 'visibility = bob.devtools.scripts.visibility:visibility', + 'getpath = bob.devtools.scripts.getpath:getpath', ], 'bdt.ci.cli': [ @@ -71,6 +75,7 @@ setup( 'readme = bob.devtools.scripts.ci:readme', 'pypi = bob.devtools.scripts.ci:pypi', ], + }, classifiers=[ 'Framework :: Bob', -- GitLab