-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3d60a2c
commit 8be4bfc
Showing
105 changed files
with
10,896 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
root = true | ||
|
||
[*] | ||
|
||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 2 | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules/ | ||
.env | ||
.nyc_output/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
*.log | ||
*.dump | ||
*.swp | ||
.DS_Store | ||
.env | ||
.nyc_output | ||
.travis.yml | ||
.editorconfig | ||
Dockerfile | ||
deploy | ||
test | ||
coverage | ||
start-couchdb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
language: node_js | ||
services: | ||
- docker | ||
cache: | ||
directories: | ||
- node_modules | ||
notifications: | ||
email: false | ||
node_js: | ||
- '7' | ||
before_install: | ||
- npm install -g npm | ||
- npm install -g greenkeeper-shrinkwrap@1 | ||
before_script: greenkeeper-shrinkwrap-update | ||
after_script: greenkeeper-shrinkwrap-upload | ||
after_success: | ||
- npm run deploy | ||
branches: | ||
except: | ||
- /^v\d+\.\d+\.\d+$/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM mhart/alpine-node:7 | ||
|
||
ARG PKG_VERSION | ||
ADD greenkeeper-jobs-${PKG_VERSION}.tgz ./ | ||
WORKDIR /package | ||
|
||
CMD ["npm", "start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,194 @@ | ||
# Greenkeeper Jobs | ||
|
||
[![Greenkeeper badge](https://badges.greenkeeper.io/greenkeeperio/jobs.svg)](https://greenkeeper.io/) | ||
[![Build Status](https://travis-ci.org/greenkeeperio/jobs.svg?branch=master)](https://travis-ci.org/greenkeeperio/jobs) | ||
|
||
This is the core service of Greenkeeper. It takes care of the dependency update logic and the related pull request/issue creation. | ||
|
||
## Job Types | ||
> 🚨🚧 The following documentation might be outdated. We are currently working on improving this section. | ||
### github-event | ||
|
||
The `github-event` job gets created by our [hooks](https://github.com/greenkeeperio/hooks) service. | ||
It's answering all incoming webhooks from GitHub and creates this job with the full payload from github as `job.data`. | ||
It only adds one additional `type` property to it with the name of the webhook event. | ||
|
||
#### github-event:integration_installation | ||
|
||
Depending on `action` a new entry is added/removed to/from the installations database. | ||
All repositories are requested from GitHub to sync them with our database. | ||
All repositories with a package.json receive their initial pull request (`create-initial-branch`). | ||
|
||
#### github-event:integration_installation_repositories | ||
|
||
Depending on `action` entries are added/removed to/from the repositories database. | ||
Added repositories with a package.json receive their initial pull request (`create-initial-branch`). | ||
|
||
#### github-event:push | ||
|
||
The package.json contents are retrieved, parsed and synced to our database. | ||
|
||
#### github-event:status | ||
|
||
If the status affects a Greenkeeper pull_request the results are recorded in our repositories database with all metadata. | ||
|
||
If the status of a branch is `failing`, it will create a new branch to pin to the last working version `create-pin-branch`. | ||
When the status for that pin branch is coming, an issue is created with `create-issue`. | ||
If that issue already exists and it's still failing it will comment `comment-issue`, but if it's | ||
succeeding it will close that issue with `close-issue`. | ||
|
||
#### github-event:pull_request | ||
|
||
When an initial Greenkeeper pull request is merged the repository gets enabled (`enable-repository`). | ||
|
||
When a Greenkeeper pull request is merged older/included pull requests for the same dependency are closed (`delete-older-branches`). | ||
Unmergeable Greenkeeper pull requests get "rebased" (`rebase-unmergeable-branches`). | ||
|
||
### registry-change | ||
|
||
The `registry-change` job gets created by our [changes](https://github.com/greenkeeperio/changes) service. | ||
It's listening for changes from npm and creates this job with the full payload from npm as `job.data`. | ||
|
||
It figures out whether the change actually contains a new version, and on which dist-tag. It stores the versions in our npm database. | ||
|
||
It figures out who is depending on the dependency that changed and schedules branch creation jobs for enabled ones. (`create-version-branch`) | ||
|
||
### create-pin-branch | ||
|
||
Creates a branch for a dependency, pinning to the version before. | ||
|
||
### create-issue | ||
|
||
Creates an issue with the information that a dependency is failing. | ||
|
||
### comment-issue | ||
|
||
Comments to an issue that a dependency is still failing. | ||
|
||
### close-issue | ||
|
||
Closes an issue because the dependency is no longer failing. | ||
|
||
### create-version-branch | ||
|
||
Used to be package-bump with our oAuth App. | ||
|
||
If there are no tests detected, or the update is outside of the version range triggers `create-version-pr` right away. | ||
|
||
### create-version-pr | ||
|
||
Used to be package-send-pr with our oAuth App. | ||
|
||
### delete-branches | ||
|
||
Deletes all branches related to a dependency which version is less or equal to the specified one. | ||
|
||
### create-initial-branch | ||
|
||
Used to be package-pin with our oAuth App. | ||
|
||
### enable-repository | ||
|
||
Used to happen inside webservice with our oAuth App. | ||
|
||
### delete-older-branches | ||
|
||
Used to happen inside pull-request-close with our oAuth App. | ||
|
||
### rebase-unmergeable-branches | ||
|
||
Used to happen inside pull-request-close with our oAuth App. | ||
|
||
## Deprecated Job Types (oAuth) | ||
|
||
There were certain hacks/workarounds that we used in our old oAuth application. The following jobs are no longer required: | ||
|
||
1. check-follower | ||
2. package-webhooks-enable | ||
3. package-webhooks-disable | ||
4. pull-request-email | ||
|
||
## documents | ||
|
||
### installations | ||
```js | ||
{ | ||
_id: '8422', // github account id | ||
installation: 10, // installation id, | ||
plan: 'free', // plan | ||
login: 'finnp', // github name | ||
type: 'User' // 'User' or 'Organization' | ||
} | ||
``` | ||
|
||
### repositories | ||
#### type: repository | ||
```js | ||
{ | ||
_id: '111', // String(repo.id), | ||
type: 'repository', | ||
enabled: false, | ||
accountId: '8422', // account id (key for installations) | ||
fullName: 'greenkeeperio/jobs', | ||
private: true, | ||
fork: false, | ||
hasIssues: true, | ||
packages: { | ||
'package.json': {} | ||
} | ||
} | ||
``` | ||
|
||
#### type:branch | ||
```js | ||
{ | ||
_id: '111:branch:deadbeefdeadbeef', // repositoryId + sha | ||
type: 'branch', | ||
purpose: undefined, // can be 'pin', otherwise not defined | ||
sha: 'deadbeefdeadbeef', | ||
base: 'master', // base branch | ||
head: 'greenkeeper-lodash-8.0.0', // branch name | ||
dependency: 'lodash', | ||
version: '8.0.0', | ||
oldVersion: '~7.0.0', | ||
oldVersionResolved: '7.0.0', | ||
dependencyType: 'devDependencies', | ||
repositoryId: '111', | ||
accountId: '8422', | ||
processed: true, // the branch was processed | ||
referenceDeleted: true, // the branch reference was deleted | ||
state: 'failure', // ci status | ||
updated_at: '2016-09-28T15:07:03.022Z' | ||
} | ||
``` | ||
|
||
#### type:pr | ||
```js | ||
{ | ||
_id: '111:pr:6', // repositoryId, PrId | ||
type: 'pr', | ||
repositoryId: 11, | ||
accountId: 42 | ||
initial: true, // is this an initial pull request? | ||
number: 6, | ||
head: 'greenkeeper-lodash-8.0.0', // branch name | ||
state: 'open', // 'closed' | ||
merged: true, | ||
updated_at, '2016-09-28T15:07:03.022Z' | ||
} | ||
``` | ||
|
||
#### type:issue | ||
```js | ||
{ | ||
_id: '111:issue:6', | ||
type: 'issue', | ||
repositoryId: '111', | ||
dependency: 'lodash', | ||
version: '1.0.0', | ||
number: 6, | ||
state: 'open', | ||
updated_at | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const _ = require('lodash') | ||
const md = require('./template') | ||
|
||
const getSha = (commit) => _.take(commit.sha, 7).join('') | ||
|
||
const commitListItem = (commit) => md`- ${md.link(md.code(getSha(commit)), commit.html_url)} <code>${commit.commit.message.split('\n')[0]}</code>` | ||
|
||
module.exports = (diff) => md` | ||
The new version differs by ${diff.total_commits} commits${diff.behind_by && ` ahead by ${diff.ahead_by}, behind by ${diff.behind_by}`}. | ||
${_.take(diff.commits.reverse(), 15).map(commitListItem)} | ||
${diff.commits.length > 15 && `There are ${diff.commits.length} commits in total.`} | ||
See the [full diff](${diff.html_url}) | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
const _ = require('lodash') | ||
const md = require('./template') | ||
|
||
const notDevDependency = ({dependency}) => md` | ||
${dependency} is a direct dependency of this project **this is very likely breaking your project right now**. If other packages depend on you it’s very likely also breaking them. | ||
I recommend you give this issue a very high priority. I’m sure you can resolve this :muscle: | ||
` | ||
|
||
const devDependency = ({dependency, dependencyType}) => md` | ||
As ${dependency} is “only” a ${dependencyType.replace(/ies$/, 'y')} of this project it **might not break production or downstream projects**, but “only” your build or test tools – **preventing new deploys or publishes**. | ||
I recommend you give this issue a high priority. I’m sure you can resolve this :muscle: | ||
` | ||
|
||
const ciStatuses = ({statuses}) => md` | ||
<details> | ||
<summary>Status Details</summary> | ||
${statuses.map(status => `- ${status.state === 'success' ? '✅' : '❌'} **${status.context}** ${status.description} [Details](${status.target_url})`)} | ||
</details> | ||
` | ||
|
||
module.exports = ({version, dependencyLink, owner, repo, head, dependency, oldVersionResolved, dependencyType, statuses, release, diffCommits}) => md` | ||
## Version **${version}** of ${dependencyLink} just got published. | ||
<table> | ||
<tr> | ||
<th align=left> | ||
Branch | ||
</th> | ||
<td> | ||
<a href="/${owner}/${repo}/compare/${encodeURIComponent(head)}">Build failing 🚨</a> | ||
</td> | ||
</tr> | ||
<tr> | ||
<th align=left> | ||
Dependency | ||
</td> | ||
<td> | ||
${dependency} | ||
</td> | ||
</tr> | ||
<tr> | ||
<th align=left> | ||
Current Version | ||
</td> | ||
<td> | ||
${oldVersionResolved} | ||
</td> | ||
</tr> | ||
<tr> | ||
<th align=left> | ||
Type | ||
</td> | ||
<td> | ||
${dependencyType.replace(/ies$/, 'y')} | ||
</td> | ||
</tr> | ||
</table> | ||
This version is **covered** by your **current version range** and after updating it in your project **the build failed**. | ||
${ | ||
dependencyType === 'dependencies' | ||
? notDevDependency({dependency}) | ||
: devDependency({dependency, dependencyType}) | ||
} | ||
${_.get(statuses, 'length') && ciStatuses({statuses})} | ||
--- | ||
${_.compact([release, diffCommits])} | ||
<details> | ||
<summary>Not sure how things should work exactly?</summary> | ||
There is a collection of [frequently asked questions](https://greenkeeper.io/faq.html) and of course you may always [ask my humans](https://github.com/greenkeeperio/greenkeeper/issues/new). | ||
</details> | ||
--- | ||
Your [Greenkeeper](https://greenkeeper.io) Bot :palm_tree: | ||
` |
Oops, something went wrong.