#1 Add README.md and a bunch of fixes
Merged 7 years ago by pingou. Opened 7 years ago by jlebon.
jlebon/fedobuild pr/readme-and-fixes  into  master

file added
+27
@@ -0,0 +1,27 @@ 

+ # fedobuild

+ 

+ fedobuild is a service that aims to improve the quality of

+ life of Fedora packagers by automating packaging updates. It

+ listens on [the fedmsg bus](http://fedmsg.com/) for dist-git

+ pushes and automatically initiates koji builds and bodhi

+ updates.

+ 

+ In order to make use of fedobuild, one must include a

+ fedobuild.yml file in the root of the dist-git repo. The

+ YAML file must have two keys: the package NEVR, and the

+ Bodhi notes to testers:

+ 

+ ```

+ - nevr: foobar-2.1-3

+   bodhi-notes: |

+     Dear testers,

+ 

+     Please test these amazing features in this new release

+     of foobar:

+       - Added 5 more bars in which to foo.

+       - Fixed issue where users couldn't baz.

+ ```

+ 

+ Dist-git pushes which update the YAML will automatically

+ trigger the fedobuild process if the NEVR has not yet been

+ built in Koji.

file modified
+35 -34
@@ -20,7 +20,7 @@ 

  

  _log = logging.getLogger(__name__)

  

- MANDATORY = ['nevr', 'changelog']

+ MANDATORY = ['nevr', 'bodhi-notes']

  FASUSER = raw_input('FAS username: ')

  FASPASS = getpass.getpass('FAS password: ')

  
@@ -48,37 +48,38 @@ 

      return (retcode, out)

  

  

- def get_changelog(name, namespace, commit):

-     ''' Retrieve the CHANGELOG.yml file of this package at this commit. '''

-     url = 'http://pkgs.fedoraproject.org/cgit/%s/%s.git/plain/CHANGELOG.yml?id=%s' % (

+ def get_repo_config(name, namespace, commit):

+     ''' Retrieve the fedobuild.yml file of this package at this commit. '''

+     url = 'https://src.fedoraproject.org/cgit/%s/%s.git/plain/fedobuild.yml?id=%s' % (

          namespace, name, commit)

+ 

      req = requests.get(url)

      if not req:

          _log.info(

-             'Could not access the CHANGELOG.yml for %s/%s, '

+             'Could not access the fedobuild.yml file for %s/%s, '

              'returned code: %s' % (namespace, name, req.status_code))

          return

  

-     return yaml.load(req.text)

+     return yaml.safe_load(req.text)

  

  

- def validate_changelog(changelog):

-     """ Checks that the changelog has all the mandatory keys and returns a

+ def validate_config(config):

+     """ Checks that the YAML has all the mandatory keys and returns a

      boolean accordingly."""

      validate = False

-     _log.info('changelog: %s' % changelog)

-     if changelog:

+     _log.info('config: %s' % config)

+     if config:

          validate = True

          for key in MANDATORY:

              _log.info('Checking key "%s"' % key)

-             if key not in changelog[0]:

+             if key not in config[0]:

                  _log.info(

-                     'Missing key "%s" in changelog: %s' % (

-                         key, changelog[0]))

+                     'Missing key "%s" in YAML: %s' % (

+                         key, config[0]))

                  validate = False

                  break

      else:

-         _log.info('No content in changelog: %s' % changelog)

+         _log.info('No content in config: %s' % config)

  

      return validate

  
@@ -89,7 +90,7 @@ 

      _log.info('Contacting pkgdb at: %s' % url)

      req = requests.get(url)

      if not req:

-         _log.info('Could not contact pkgdb, error:  %s' % re.status_code)

+         _log.info('Could not contact pkgdb, error:  %s' % req.status_code)

          raise RuntimeError('Could not contact pkgdb')

      data = req.json()

      return data["collections"][0]['dist_tag']
@@ -129,10 +130,10 @@ 

      return out.split('\n')[0].rsplit(' ', 1)[1]

  

  

- def update_package(changelog, dist):

+ def update_package(config, dist):

      """ Checks bodhi if the specified package already has an update and if

      not create one. """

-     build = changelog['nevr'] + dist

+     build = config['nevr'] + dist

      bodhi = Bodhi2Client(username=FASUSER, password=FASPASS)

      data = bodhi.query(builds=build)

      if len(data['updates']) > 0:
@@ -141,12 +142,12 @@ 

  

      update = bodhi.save(

          builds=build,

-         type=changelog.get('update_type'),

-         bugs=changelog.get('bugzilla'),

-         notes=changelog.get('changelog'),

-         close_bugs=changelog.get('close_bug_on_stable'),

-         suggest=changelog.get('suggest'),

-         severity=changelog.get('severity'),

+         type=config.get('update_type'),

+         bugs=config.get('bugzilla'),

+         notes=config.get('bodhi-notes'),

+         close_bugs=config.get('close_bug_on_stable'),

+         suggest=config.get('suggest'),

+         severity=config.get('severity'),

      )

      _log.debug('Bodhi said: %s' % update)

      if 'url' in update:
@@ -156,12 +157,12 @@ 

  

  def process(message):

      """ For a given message:

-         - Check if the CHANGELOG.yml file was edited

+         - Check if the fedobuild.yml file was edited

          - Retrieve the commit

          - Retrieve the branches in which this commit is

          - Fire a build in koji if necessary

      """

-     to_process = 'CHANGELOG.yml' in message['msg']['commit']['stats']['files']

+     to_process = 'fedobuild.yml' in message['msg']['commit']['stats']['files']

  

      namespace = message['msg']['commit']['namespace']

      name = message['msg']['commit']['repo']
@@ -169,23 +170,23 @@ 

  

      if not to_process:

          _log.info(

-             'No CHANGELOG.yml change in %s/%s: %s' % (

+             'No fedobuild.yml change in %s/%s: %s' % (

                  namespace, name, commit))

          return

-     _log.info('Changes to CHANGELOG.yml detected')

+     _log.info('Changes to fedobuild.yml detected')

  

-     changelog = get_changelog(name, namespace, commit)

-     if not validate_changelog(changelog):

+     config = get_repo_config(name, namespace, commit)

+     if not validate_config(config):

          _log.info(

-             'Invalid CHANGELOG.yml in %s/%s: %s' % (

+             'Invalid fedobuild.yml in %s/%s: %s' % (

                  namespace, name, commit))

          return

-     _log.info('CHANGELOG.yml validated')

+     _log.info('fedobuild.yml validated')

  

      branch = message['msg']['commit']['branch']

      dist = get_dist(branch)

  

-     if not already_built(changelog[0]['nevr'], dist):

+     if not already_built(config[0]['nevr'], dist):

          _log.info('Building package in koji')

          task_id = build_pkg(namespace, name, commit, branch)

          _log.info('Package builing in task #%s' % task_id)
@@ -204,10 +205,10 @@ 

      commit = message['msg']['commit']['rev']

      branch = message['msg']['commit']['branch']

      dist = get_dist(branch)

-     changelog = get_changelog(name, namespace, commit)

+     config = get_repo_config(name, namespace, commit)

  

      if branch != 'master':

-         update_package(changelog[0], dist)

+         update_package(config[0], dist)

      else:

          _log.info('Package updated in `master`, no need for a bodhi update')

  

Nice presentation! :)

Overall changes:
- Add a basic README.md.
- Rename changelog to bodhi-notes.
- Some other minor fixes.

Pull-Request has been merged by pingou

7 years ago
Metadata