Skip to content

Instantly share code, notes, and snippets.

@jmatt
Last active May 9, 2017 20:46
Show Gist options
  • Save jmatt/3d2c0abd8210fb2b961b6d387bab54fa to your computer and use it in GitHub Desktop.
Save jmatt/3d2c0abd8210fb2b961b6d387bab54fa to your computer and use it in GitHub Desktop.
Community post for DM-7600 and DM-10493

Github branch protection, TravisCI, Flake8 and update automation for LSST DM

SQRE has built a command line interface, called sqre-gtf, to provide support for RFC-162.

sqre-gtf

sqre-gtf provides command line interfaces to use Github branch protection, TravisCI and Flake8. sqre-gtf runs on Python 2.7, 3.5 and 3.6. You can install it with

pip install sqre-gtf

If you haven't used sqre-codekit or sqre-gtf before you will need to create a Github personal access token and put it in ~/.sq_github_token. The github-auth script can do this on your behalf.

github-auth -u <your_github_login>

        Type in your password to get an auth token from github
        It will be stored in ~/.sq_github_token
        and used in subsequent occasions.

Password for <your_github_login>: <your_github_password>
Enter 2FA code: <your_github_2FA>
Token written to ~/.sq_github_token

There are three core features that sqre-gtf provides. Configuration of Github branch protection, enabling the TravisCI webhook and configuring your repository to use TravisCI to run Flake8 validation.

An example of using sqre-gtf on lsst.utils follows

github-protect --owner lsst --repo utils --branch_name master # Add Github branch protection.
github-travis --owner lsst --repo utils # Enable the TravisCI webhook
github-update --owner lsst --repo utils --task stack --branch_name tickets/DM-NNNNN --commit_message "DM-NNNNN: Add .travis.yml and setup.cfg to run flake8." --pull --pull_message "DM-NNNNN: Add .travis.yml and setup.cfg to run flake8." # Create a commit and pull request adding .travis.yml and setup.cfg.

Now Github branch protection is enabled and TravisCI is enabled for the repository. The last command creates a PR with a single commit similar to lsst/utils #33. From there, if the repository does not meet the requirements of RFC-162 it will fail TravisCI. Additional changes may be required to pass TravisCI. @timj made such changes on lsst/utils #33.

Things to be Aware of Before Making Changes

When updating a repository it is time sensitive. As soon as TravisCI is enabled for your repository it will attempt to run a default TravisCI script on your repository which will likely fail until the sqre-gtf PR is merged. Another notable change is enabling Github's branch protection. Users will be unable merge PRs until they pass TravisCI. This can always be disabled in the repository's settings by an Overlord.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment