mozilla-services / updatebot

Automation for updating third party libraries for Firefox
Mozilla Public License 2.0
8 stars 5 forks source link

Updatebot

<mozilla-services> codecov

Automated detection, patching, testing, and bug filing for updates in third-party libraries for Firefox.

For Mozilla Developers

Updatebot is a bot that looks for upstream updates to a third party dependency (typically a library) and if it detects an update it will:

Updatebot can be thought of as two halves: the bot that does the above and the in-tree ./mach vendor component that makes it easy for a library to be updated locally. We would be happy to help you set up your library for vendoring in Updatebot.

Updatebot doesn't have to vendor the update - it can instead just alert you that there were new commits. This is good for infrequently updated upstreams that are difficult to automatically vendor. In the future we intend to add some intelligence to this to let us filter by suspected security issues.

Updatebot has several configurable options:

  1. It can look for updates:
    • every run (6 hours) - good for infrequently updated upstreams
    • every N weeks
    • every N commits
    • only upon a new Firefox release (good for frequently updated libraries we bump once-per-FF release)
  2. It can track a specific upstream branch, or only look for newly tagged releases
  3. It can use ./mach try auto or ./mach try fuzzy with a custom query string to send in the try run
  4. Through the moz.yaml format, it can handle more complicated vendoring steps using custom scripts, or more simple vendoring steps using a predefined language.

Updatebot Development

This project requires Poetry and a version of Python at least greater than 3.5.

We talk to a database; currently MySQL is supported. Copy the local config file with cp localconfig.py.example localconfig.py and configure the database connection parameters. Updatebot will automatically create and populate the database with its structure and required data.

To get started developing Updatebot, or to run it locally you'll need to run poetry install and then poetry run ./automation.py

Testing is handled in a single step of poetry run ./test.py

For formatting code automatically please use poetry run autopep8 --in-place --recursive --ignore E501,E402,E275 .

For linting the codebase run poetry run flake8 --ignore=E501,E402,E275 .

Updatebot is currently in active development with a lot of churn. We welcome patches and bugfixes, but encourage you to reach out to June Wilde or Tom Ritter before spending too much time as we may be already addressing your issue.

How it works

Updatebot runs as a Linux-based cron job in mozilla-central every 6 hours (defined in .cron.yml). (There is a windows cron job in development, but ignore it for now.) This job runs in the Updatebot Docker Image. It will search the mozilla source tree for moz.yaml files that define an enabled Updatebot task. We will figure out which task type we are dealing with. The more commone one is a vendoring task but there is also a commit alert task.

From here we will look at all of the jobs in the database for this library and task type, and process them to see if there is anything we need to do for them. We might look at try results and summarize them on the bugzilla bug, trigger new jobs on a try run, or mark an open bugzilla bug as affecting a new Firefox release. This all happens in process_task and _process_existing_job in vendoring.py.

After looking at the prior jobs, we'll see if there is a new upstream revision we don't have a current job for. If so, we will go into _process_new_job in vendoring.py. We'll see if we should process the job based on it's request frequency, and if so figure out if it actually changes any files in m-c - if not we consider it a 'spurious update'. If it passes those checks it goes into the normal updatebot cycle. This involves creating a bug, creating a patch, submitting to try, submitting to phabricator. An important step here is that we look at the most recent filed bug for this library - if it is still open we will close it as a duplicate, duplicating it forward to our new bug. We have some logic in there to only do this to a bug once - we don't want Updatebot to get into a bug opening/closing loop with developers.

Updatebot uses a database that lives in Google CloudSQL. There is a dev and prod database, as well as dev and prod credentials for those databases, bugzilla, try server, phabricator, sentry, and sql-proxy (which is used to connect to the database). You can find them in grants.yml searching for 'updatebot'. The dev credentials are granted to holly, which is our reserved development instance because Updatebot can't tested on try safely. The prod credentials are only available to mozilla-central.

Architecture

Updatebot's architecture is.... not great.

There are a few bits of complexity elided in the overview and architecture details above:

Fine Print

This repo is subject to our quality standards and practices and any interaction here is governed by the Mozilla Community Participation Guidelines.