Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compose duties for public API #64

Open
stellarhoof opened this issue Jan 25, 2019 · 0 comments
Open

Compose duties for public API #64

stellarhoof opened this issue Jan 25, 2019 · 0 comments

Comments

@stellarhoof
Copy link
Member

stellarhoof commented Jan 25, 2019

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),
  ...
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant