sonatype-nexus-community/salesforce-cla

Name: salesforce-cla

Owner: Sonatype Community

Description: Salesforce Contributor License Agreement Bot for Validating GitHub Pull Requests

Created: 2018-02-16 20:01:22.0

Updated: 2018-04-19 19:50:30.0

Pushed: 2018-04-20 16:47:15.0

Homepage:

Size: 2325

Language: Scala

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

DR CLA

This is a set of tools for dealing with Contributor License Agreements for Open Source Salesforce projects.

The tools provided are:

This application is built with:

How it Works

When someone sends a Pull Request to a project on GitHub, a Webhook sends details to this app. The authors of the commits in the PR are checked to see if they are collaborators on the repo. If not, the app checks if they have signed CLAs. If there are missing CLAs then the status of the PR is set to failed. Otherwise it is set to success. Also if there are missing CLAs then a comment is posted on the PR asking the contributors to sign the CLA. Once a contributor signs a CLA, all of the open PRs are revalidated.

Deploy on Heroku

Local Dev Setup
  1. Install Java 8

  2. Install Postgres

  3. Install ngrok

  4. Start ngrok: ngrok http 9000

  5. Create local Postgres databases:

    $ psql
    # CREATE ROLE salesforcecla LOGIN password 'password';
    # CREATE DATABASE salesforcecla ENCODING 'UTF8' OWNER salesforcecla;
    # CREATE DATABASE "salesforcecla-test" ENCODING 'UTF8' OWNER salesforcecla;
    
  6. Setup a new oAuth App

    • This will be at: https://github.com/organizations/{your-organization}/settings/applications/new
    • Application name = Something descriptive
    • Authorization callback URL = https://YOUR_NGROK_ID.ngrok.io/_github_oauth_callback
    • Homepage URL = https://YOUR_NGROK_ID.ngrok.io/
    • Once finished, set the GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET env vars accordingly
  7. Setup a new GitHub App with the following settings:

    • Webhook URL = https://YOUR_NGROK_ID.ngrok.io/webhook-integration
    • Repository administration = Read-only
    • Commit statuses = Read & Write
    • Issues = Read & Write
    • Pull requests = Read & Write
    • Repository contents = Read-only
    • Organization members = Read-only
    • Under Subscribe to events select Pull request

    It is not required, but if you set the GitHub Integration Secret Token, then set the GITHUB_INTEGRATION_SECRET_TOKEN env var accordingly.

  8. Generate and save a new Private key for the new Integration, then set the GITHUB_INTEGRATION_PRIVATE_KEY env var accordingly, like:

    export GITHUB_INTEGRATION_PRIVATE_KEY=$(cat ~/somewhere/your-integration.2017-02-07.private-key.pem)
    
  9. Your new GitHub App will have a numeric id, set the GITHUB_INTEGRATION_ID env var accordingly.

  10. Your new GitHub App will have a slug / URL friendly name, set the GITHUB_INTEGRATION_SLUG env var accordingly.

  11. Set the GITHUB_BOT_NAME env var to the value of what you'd like your public facing bot to appear as

rt GITHUB_BOT_NAME=salesforce-cla
Run the Web App
  1. Start the web app:

    $ ./sbt ~run
    
  2. Authenticate to GitHub with your test user

  3. Open the audit page: https://SOMETHING.ngrok.com/audit

  4. You should see a list of organizations which have the GitHub App installed and which you are an admin of

  5. In GitHub edit the README file the testing repo and submit a pull request

  6. This will make a webhook request to your local application and validate the CLA status of the submitter

  7. You can see event deliveries in the Developer Settings for your GitHub App

  8. If you make a PR with a testing user that is not part of the org, you should see the PR validation failure and be able to sign the CLA

Run the Tests
  1. You will need two GitHub testing users. For each, create a personal access token with the following permissions: admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, repo, user

  2. For user one, create a new testing organization (because this can't be done via the API). Add the second user as a member of this org.

  3. For user one, install the GitHub App into the user's account and into the testing org.

  4. Set the GITHUB_TEST_TOKEN1, GITHUB_TEST_ORG, and GITHUB_TEST_TOKEN2 env vars.

  5. Run all of the tests continuously:

    $ ./sbt ~test
    

1 Run just the GitHubSpec tests continuously:

    $ ./sbt ~testOnly utils.GitHubSpec

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.