Home

Awesome

joyent-repos

This repository defines a "jr-manifest.json" spec for how the set of repos for a Triton product can be defined, including metadata (labels). It also provides a tool (jr) for working with these repo manifests -- for example to enable easily cloning one, a few, or all repos and running commands in those clones. (This effort was done as part of RFD 70.)

Motivation

Joyent has a number of products, e.g. Manta, Triton Data Center ("Triton" for short), and SmartOS. Each of those products is comprised of a (often large) number of git repositories. The release process needs to know which repos represent top-level build components, which repos should be branched; a new employee likely wants to clone most/all repos for a given product; etc. Having some mechanism for structured and maintained repo metadata can help these and many automation use cases.

Overview

There is a "jr-manifest.json" file (following the spec defined below) in the "master" repo of each product:

Joyent ProductJR manifest
Tritontriton.git tools/jr-manifest.json
Mantamanta.git tools/jr-manifest.json
SmartOSsmartos-live.git tools/jr-manifest.json
Triton (private repos)triton-dev.git ./jr-manifest.json

Then automation can use those as required. The provided jr tool can work with the jr-manifest.json files in local clones of these repos.

Registered users

Having a registered set of tools/processes using jr and this spec can help immensely in maintaining it. Please add to this list if that's you.

Registered users:

JR Manifest Spec

A repo manifest is a JSON file that enumerates a set of repos, some metadata on those repos (currently just labels), fields that define the scope of repos for this manifest, and a set of repos that do not belong (to aid in maintaining the file). The file is typically called "jr-manifest.json". Typically the "set" represents the repos relevant for a Joyent product. Currently the manifest enumerates repo names, assuming they are all on GitHub and under the github.com/TritonDataCenter organization.

See the example jr-manifest.json file.

A repo manifest file has the following fields:

Blessed labels

jr

A tool to work with these jr-manifest.json files and the repos mentioned in them.

Setup

  1. Install it:

    git clone git@github.com:TritonDataCenter/joyent-repos.git
    cd joyent-repos
    make
    export PATH=`pwd`/bin:$PATH
    
  2. Update to the latest triton.git and triton-dev.git.

  3. Config it:

    $ export JR_MANIFESTS=`pwd`/triton/tools/jr-manifest.json,
    `pwd`/manta/tools/jr-manifest.json,`pwd`/smartos-live/tools/jr-manifest.json,
    `pwd`/triton-dev/jr-manifest.json
    

    where those paths are adjusted to where you have local clones of triton.git, manta.git, smartos-live.git, and triton-dev.git.

    If you want repositories to be checked out to directories with a given suffix (e.g. <repo_name>.git) then set:

    export JR_REPO_PATH_SUFFIX='.git'
    
  4. Check it by listing repos:

    jr --version
    jr list
    

How to use jr to update the sdc-scripts git submodule in all Triton repos

Say you have a ticket (TRITON-NNN) to update all the Triton repos that build service images to the latest sdc-scripts. Here is one way to use jr to help do that.

  1. Make a working dir and clone all the repos there:

    mkdir triton-NNN
    cd triton-NNN
    jr clone -y -l triton,vm
    
  2. Update the submodule in each clone:

    jr oneach 'git submodule update --init -- deps/sdc-scripts'
    jr oneach 'cd deps/sdc-scripts && git checkout master'
    

    Unfortunately triton-cmon and triton-cns do it differently: using an npm dep for sdc-scripts, rather than git submodule.

    (cd sdc-papi/deps/sdc-scripts/ && git log -1 --pretty=format:%H)
    vi triton-cns/package.json
    vi triton-cmon/package.json
    
  3. Inspect the diff in each repo to ensure it is copacetic:

    jr oneach 'git diff'
    
  4. Start a Gerrit CR for each (assuming you use grr):

    jr oneach 'grr TRITON-NNN'      # gathers info, creates feature branch
    jr oneach 'git commit -am "update to latest sdc-scripts"'
    jr oneach -c1 'grr'             # creates a CR
    open 'https://cr.joyent.us/#/q/is:open+TRITON-NNN'
    

    The -c1 is for a concurrency of just one when pushing things to cr.joyent.us, otherwise I've found it fails a lot.

  5. Get reviews on all those, then update the commit message:

    jr oneach 'grr'
    

    and submit them (TODO: finish grr -S for submitting).

  6. Then clean up:

    cd ..
    rm -rf triton-NNN
    

Here is an example run for TRITON-380: https://gist.github.com/trentm/2abe2335f9997c511b683e67bd622d42.

Maintenance of repo manifest files

The "joyent" org has a lot of repositories. Trying to keep track of which newly added repositories are relevant for a given repo manifest is tedious. The jr update-manifest MANIFEST-PATH command is intended to help with this. To support this command a manifest must have a repoCandidateSearch object (see the spec above).

Periodically one should run jr update-manifest MANIFEST-PATH and walk through the interactive steps to add (and/or explicitly exclude) new candidate repos. The command will fetch all repos from GitHub's API matching the repoCandidateSearch params and then have you edit the list to those that should be included in the manifest (along with optionally adding labels) and those that should be excluded.

Here is an example run:

$ jr update-manifest ~/joy/triton/tools/jr-manifest.json
Gathering candidate repos from GitHub.

* * *
The following 2 repo(s) have been archived, or are otherwise no longer
candidate repos for "/Users/trentm/joy/triton/tools/jr-manifest.json":
    node-tracker
    sdc-zookeeper
Remove them from the manifest? [Y/n]
Updated "/Users/trentm/joy/triton/tools/jr-manifest.json".

* * *
There are 3 candidate new repo(s) to work through:
    zoneinit
    keyapi
    cloud-init

The manifest defines relevant repos as follows:
    public github.com/TritonDataCenter repos directly relevant to development of TritonDC

The process is:
1. edit the list of repos to include in this manifest
   (possibly including additional labels)
2. edit the list of repos to exclude as not relevant
3. any left over repos are deferred until the next
   `jr update-manifest ...`

Hit <Enter> to open your editor, <Ctrl+C> to abort.
Updated "/Users/trentm/joy/triton/tools/jr-manifest.json".

* * *
Next we will handle *exclusions*, by editing the remaining
list of repos down to those to be excluded from this manifest.
Hit <Enter> to open your editor, <Ctrl+C> to abort.

No new repos to exclude.

When a manifest knows about all candidate repos, then a run will look like this:

$ jr update-manifest ~/joy/triton/tools/jr-manifest.json
Gathering candidate repos from GitHub.
No newly archived repos to remove from the manifest.
No new repos to add to the manifest.