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

Refactor and move to setup.py based installation #1

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
*.py[co]
*.swp
*~

*.egg
*.egg-info
.eggs
dist
build
eggs
parts
sdist
develop-eggs
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Description
===========

Release-helper is a python tool that helps you manage large number of
github repositories by controlling milestones and labels,
and creating a overiew of the release process.

Configfile
==========

Username / token are best stored in minimal config file,
and used together with project config file.
This allows you to share the project configfile,
without compromising authentication details.

Example:
release-helper.py --configs=.secret/credentials.cfg,project.cfg --collect

Commands
========
* collect: gather the data from github, creates JSON file (most other steps will use this JSON file)
* render: generate the release notes overview and to discuss
* notes: generate the release notes (there's a *notestemplate* option to select a different template)
Example:
release-helper.py --configs=.secret/credentials.cfg,quattor.cfg --notes --milestone 16.6
* milestones: configure milestones due date on release data (or generated if milestone is not in release data)
* TODO: Missing the ability to open/close milestones
* labels: configure (add or update; no remove) the labels
* bump: advanced: bump/shift the milestones by `--months` number of months (default 2).
Generates and prints the release section data with updated dates.

Local usage
===========
You cannot use `file:///path/to/project/index.html` because some of the css and javascript url use
protocol relative urls, and would require that you install those also in the pooject dir.

* generate the required html and json using and start webserver using `--render --web` option
* got to url `http://localhost:8000` (and `http://localhost:8000/to_discuss`)

Example release page
====================

Example:
[quattor release overview]:(http://quattor.org/release)
124 changes: 124 additions & 0 deletions bin/release-helper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
#!/usr/bin/python
# encoding: utf8

import argparse
import BaseHTTPServer
import logging
import os
import SimpleHTTPServer

from release_helper.config import make_config, get_project, get_repos, get_releases, get_output_filenames, get_labels
from release_helper.collect import collect
from release_helper.labels import configure_labels
from release_helper.milestone import milestones_from_releases, configure_milestones, bump
from release_helper.render import make_html, make_notes


def get_args():
"""
Build up and parse commandline
"""
parser = argparse.ArgumentParser()
parser.add_argument("-d", "--debug", help="set debug loglevel", action="store_true")
parser.add_argument("-C", "--configs", help="comma-separated list of config files")

parser.add_argument("-c", "--collect", help="collect github repository information", action="store_true")
parser.add_argument("-r", "--render", help="render html release overview and discuss pages", action="store_true")

parser.add_argument("-n", "--notes", help="Generate the releasenotes", action="store_true")
parser.add_argument("--milestone", help="Milestone to use (for releasenotes)")
parser.add_argument("--notestemplate", help="TT template to use for the releasenotes", default='quattor_releasenotes')

parser.add_argument("-m", '--milestones', help='Configure milestones (from configured releases)', action='store_true')

parser.add_argument('-l', '--labels', help='Configure labels', action='store_true')

parser.add_argument("-w", "--web", help="start simple webserver", action="store_true")
parser.add_argument("-p", "--port", help="webserver port", default=8000)

parser.add_argument('--bump', help='Bump/shift milestones number of months, print new release section', action='store_true')
parser.add_argument('--months', help='Number of months to bump/shift milestones', action='store_true', default=2)

args = parser.parse_args()
return args


def main():
logger = logging.getLogger()
lvl = logging.INFO

args = get_args()
if args.debug:
lvl = logging.DEBUG

logger.setLevel(lvl)

cfgs = None
if args.configs:
cfgs = args.configs.split(',')

use_github = any([getattr(args, x) for x in ('collect', 'milestones', 'bump', 'labels')])

# Do not unneccesiraly gather GH data
make_config(cfgs=cfgs, use_github=use_github)

repos = get_repos()
project = get_project()
releases = get_releases()

basedir, filenames = get_output_filenames()

if not os.path.isdir(basedir):
os.mkdir(basedir)

logging.debug('Release helper start')

if args.milestones:
logging.info('Configure milestones')
milestones = milestones_from_releases(releases)
for repo in repos:
configure_milestones(repo, milestones)
elif args.bump:
logging.info('Bump milestones with %s months', args.months)
u_release_data = {}
for repo in repos:
u_release_data.update(bump(repo, months=args.months, releases=releases))

# Create new release section config
txt = []
for title, dates in sorted(u_release_data.items()):
txt.append("%s=%s" % (title, ','.join(dates)))

print "\n".join(txt)
elif args.labels:
labels = get_labels()
logging.info('Configuring labels')
for repo in repos:
configure_labels(repo, labels)
else:
if args.collect:
logging.info('Collect')
collect(repos, filenames)

if args.render:
logging.info('Render')
make_html(project, releases, filenames)

if args.notes:
logging.info("Release notes using milestone %s and template %s", args.milestone, args.notestemplate)
make_notes(project, args.milestone, args.notestemplate, filenames)

logging.debug('Release helper end')

if args.web:
os.chdir(basedir)
logging.debug('Starting webserver on port %s from basedir %s, running forever', args.port, basedir)
server_address = ('', int(args.port))

HandlerClass = SimpleHTTPServer.SimpleHTTPRequestHandler
HandlerClass.protocol_version = "HTTP/1.0"
httpd = BaseHTTPServer.HTTPServer(server_address, HandlerClass)
httpd.serve_forever()

if __name__ == '__main__':
main()
124 changes: 0 additions & 124 deletions burndown.html

This file was deleted.

File renamed without changes.
26 changes: 26 additions & 0 deletions data/quattor.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[main]
project=quattor

[releases]
14.8=2014-07-01,2014-08-25,2014-09-01
14.10=2014-09-01,2014-10-27,2014-11-01
15.2=2014-11-14,2015-03-07,2015-03-20
15.4=2015-03-23,2015-05-01,2015-05-08
15.8=2015-06-03,2015-09-14,2015-09-18
15.12=2015-10-29,2016-12-07,2015-12-17
16.2=2016-01-11,2016-02-15,2016-02-19
16.6=2016-02-29,2016-06-20,2016-07-01

[labels]
bug=ef2929
duplicate=d3d7cf
enhancement=83afdf
invalid=555753
question=75507b
wontfix=888a85
backwards incompatible=e46800
discuss at workshop=fce94f

[github]
organisation=quattor
white=CAF,CCM
18 changes: 18 additions & 0 deletions data/release_helper.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[main]
github=github,enterprise

[labels]
bug=ef2929

[github]
username=example1
token=1234567890
organisation=pubteam
white=abc

[enterprise]
api=https://enterprise.example.com/some/subtree/v3/
username=localuser
token=abcdef123456
organisation=myteam
black=secret
35 changes: 0 additions & 35 deletions github_labels_configure.py

This file was deleted.

Loading