8000 Compose duties for public API · Issue #64 · smartprocure/duti · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Compose duties for public API #64
Open
@stellarhoof

Description

@stellarhoof

Duties can be executed in different environments (non-exhaustive list):

  • On (actual) CI
  • On the local machine
    • With github metadata (danger pr and danger ci)
    • Without github metadata (danger local)
  • (Internal) For testing purposes

Different duties have different implicit assumptions about their
environment right now, but those assumptions are not checked. Clients of
our library have to write those checks themselves if they want to have a
robust dangerfile that works in a variety of scenarios without breaking.
This is error prone for consumers of our API.

We can provide public helpers that check those assumptions and fail if
they aren't met. Users can compose them with duties they write
themselves if they want. We can also use them internally when exporting
our duties to the world. Ex:

src/duties/pr.js:

module.exports = {
  // No changes here. Export uncomposed duties for testing
}

src/duties/index.js:

let pr = require('./pr')
let autoFix = require('./autoFix')
let { checkGithub } = require('./utils')

module.exports = Object.assign(
  {},
  _.mapValues(duti => _.flow(checkGithub, duti), pr),
  _.mapValues(duti => _.flow(checkActualCI, checkGithub, duti), autoFix),
  ...
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0