Git Product home page Git Product logo

peril-settings's Introduction

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 concepts:

An overview of what Peril does for Artsy is available in the README repo at /culture/peril.md.

TL:DR 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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.