Artsy's peril settings
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.github Create ISSUE_TEMPLATE.md Jan 31, 2018
.vscode Make the whole repo consistent Aug 27, 2018
fixtures Convert to use RFC 74 Aug 4, 2018
org Use a username + pass Nov 16, 2018
tasks Move to the real async behavior Sep 2, 2018
tests Adds a link to the RFC resolver after a week Oct 3, 2018
.gitignore Adds infra to edit Dangerfiles with Types, and add a blank js May 5, 2017
.travis.yml Adds a testing infrastructure for danger rules Sep 12, 2017
LICENSE Initial commit Sep 12, 2016
README.md
package.json
peril.settings.json Update peril.settings.json Nov 16, 2018
spellcheck.json
tsconfig.json
wallaby.js Add support for wallaby js Jan 27, 2018
yarn.lock Use a username + pass Nov 16, 2018

README.md

Artsy Peril Settings

What is this project?

This is the configuration repo for Peril on the Artsy org. There is a settings file and org-wide dangerfiles which are inside the org folder.

Here's some links to the key things

TLDR on this Repo?

Peril is Danger running on a web-server, this repo is the configuration for that, currently the dangerfiles in org run on every issue and pull request for all our repos.

To Develop

git clone https://github.com/artsy/peril-settings.git
cd peril-settings
yarn install
yarn jest
code .

You will need node and yarn installed beforehand. You can get them both by running brew install yarn. This will give you auto-completion and types for Danger/Peril mainly.

RFCs

It's likely that any time you want to make a change here you should consult the Artsy RFC process and apply it on artsy/README.

Implementing an RFC

Adding a rule

A rule should include a link to its rfc:

// Keep our Markdown documents awesome
// https://github.com/artsy/peril-settings/issues/2
//
export default async (webhook: any) => {
  // [...]
})

This self-documents where a rule has come from, making it easy for others to understand how we came to specific rules. The closure passed to rfc can be async as well.

Testing a rule

We use Jest to test our Dangerfiles. It uses the same techniques as testing a danger plugin where the global imports from danger are fake.

  1. Create a file for your RFC: tests/rfc_[x].test.ts.

  2. Add a before and after setting up and resetting mocks:

    jest.mock("danger", () => jest.fn())
    import * as danger from "danger"
    const dm = danger as any
    
    beforeEach(() => {
      dm.danger = {}
      dm.fail = jest.fn() // as necessary
    })
    
    afterEach(() => {
      dm.fail = undefined
    })
  3. Set up your danger object and run the function exported in all-prs.ts:

    import rfcN from "../org/all-prs"
    
    it("warns when there's there's no assignee and no WIP in the title", async () => {
      dm.danger.github = { pr: { title: "Changes to the setup script", assignee: null } }
      await rfcN()
    
      expect(something).toHappen()
        // [...]
      })
    })
  4. Validate that the fail/warn/message/markdown is called.