Skip to content

Commit

Permalink
feat(723): eventFactory also creates builds (#195)
Browse files Browse the repository at this point in the history
* feat(723): eventFactory also creates builds

* fix: Add case when PR job already exists

* feat(723): Use new workflow parser and pull in workflowGraph

* fix: Fix JSdocs comments

* fix: Sync pipeline before starting and creating jobs

* fix: Use PR configuration workflowGraph

* fix: Get workflow info from sync

* fix: Remove extra pipeline workflowGraph test

* fix: Add assertion for type is pr
  • Loading branch information
d2lam authored and tkyi committed Oct 18, 2017
1 parent 87c679a commit 377e603
Show file tree
Hide file tree
Showing 8 changed files with 677 additions and 68 deletions.
79 changes: 52 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ factory.get({ scmUri }).then(model => {

| Parameter | Type | Description |
| :------------- | :---- | :-------------|
| id | String | The unique ID for the pipeline |
| id | Number | The unique ID for the pipeline |
| config.scmUri | String | Source Code URI for the application |


Expand Down Expand Up @@ -159,7 +159,7 @@ const factory = Model.JobFactory.getInstance({
});
const config = {
params: {
pipelineId: 'aabbccdd1234'
pipelineId: 1
},
paginate {
page: 2,
Expand Down Expand Up @@ -189,7 +189,7 @@ factory.create(config).then(model => {
| Parameter | Type | Description |
| :------------- | :---- | :-------------|
| config | Object | Configuration Object |
| config.pipelineId | String | The pipelineId that the job belongs to |
| config.pipelineId | Number | The pipelineId that the job belongs to |
| config.name | String | The name of the job |

#### Get
Expand All @@ -206,8 +206,8 @@ factory.get({ pipelineId, name }).then(model => {

| Parameter | Type | Description |
| :------------- | :---- | :-------------|
| id | String | The unique ID for the job |
| config.pipelineId | String | Id of the pipeline the job is associated with |
| id | Number | The unique ID for the job |
| config.pipelineId | Number | Id of the pipeline the job is associated with |
| config.name | String Name of the job |

### Job Model
Expand Down Expand Up @@ -260,7 +260,7 @@ const factory = Model.BuildFactory.getInstance({
});
const config = {
params: {
jobId: 'aaabbccdd1234'
jobId: 4
},
paginate {
page: 2,
Expand Down Expand Up @@ -297,7 +297,7 @@ factory.create(config).then(model => {
| config.container | String | No | Container for the build to run in |
| config.sha | String | No | SHA used to kick off the build |
| config.prRef | String | No | PR branch or reference; required for PR jobs |
| config.eventId | String | No | Id of the event this build belongs to |
| config.eventId | Number | No | Id of the event this build belongs to |

#### Get
Get a build based on id. Can pass the generatedId for the build, or the unique keys for the model, and the id will be determined automatically.
Expand All @@ -313,8 +313,8 @@ factory.get({ jobId, number }).then(model => {

| Parameter | Type | Description |
| :------------- | :---- | :-------------|
| id | String | The unique ID for the build |
| config.jobId | String | The unique ID for a job |
| id | Number | The unique ID for the build |
| config.jobId | Number | The unique ID for a job |
| config.number | Number | build number |

### Build Model
Expand Down Expand Up @@ -438,7 +438,7 @@ factory.get({ token }).then(model => {

| Parameter | Type | Description |
| :------------- | :---- | :-------------|
| id | String | The unique ID for the build |
| id | Number | The unique ID for the build |
| config.username | String | User name |
| config.scmContext | String | Scm context to which user belongs |
| config.accessToken | String | A user access token value |
Expand Down Expand Up @@ -520,7 +520,7 @@ const factory = Model.SecretFactory.getInstance({
});
const config = {
params: {
pipelineId: '2d991790bab1ac8576097ca87f170df73410b55c'
pipelineId: 1
},
paginate {
page: 2,
Expand Down Expand Up @@ -550,7 +550,7 @@ factory.create(config).then(model => {
| Parameter | Type | Required | Description |
| :------------- | :---- | :-------------| :-------------|
| config | Object | Yes | Configuration Object |
| config.pipelineId | String | Yes | Pipeline that this secret belongs to |
| config.pipelineId | Number | Yes | Pipeline that this secret belongs to |
| config.name | String | Yes | Secret name |
| config.value | String | Yes | Secret value |
| config.allowInPR | String | Yes | Flag to denote if this secret can be shown in PR builds |
Expand All @@ -569,8 +569,8 @@ factory.get({ pipelineId, name }).then(model => {

| Parameter | Type | Description |
| :------------- | :---- | :-------------|
| id | String | The unique ID for the build |
| config.pipelineId | String | Pipeline that the secret belongs to |
| id | Number | The unique ID for the build |
| config.pipelineId | Number | Pipeline that the secret belongs to |
| config.name | String | Secret name |


Expand All @@ -583,7 +583,7 @@ const factory = Model.SecretFactory.getInstance({
password // Password for encryption operations
});
const config = {
pipelineId: '2d991790bab1ac8576097ca87f170df73410b55c',
pipelineId: 1,
name: 'NPM_TOKEN',
value: banana,
allowInPR: false
Expand Down Expand Up @@ -611,7 +611,7 @@ const factory = Model.EventFactory.getInstance({
});
const config = {
params: {
pipelineId: '2d991790bab1ac8576097ca87f170df73410b55c'
pipelineId: 1
}
}

Expand All @@ -636,9 +636,10 @@ factory.create(config).then(model => {
| :------------- | :---- | :-------------| :-------------|
| config | Object | Yes | Configuration Object |
| config.type | String | No | Event type: pipeline or pr |
| config.pipelineId | String | Yes | Unique identifier of pipeline |
| config.pipelineId | Number | Yes | Unique identifier of pipeline |
| config.sha | String | Yes | Commit sha that the event was based on |
| config.workflow | Array | Yes | Workflow of the pipeline |
| config.workflow | Array | No | Workflow of the pipeline |
| config.workflowGraph | Object | No | Workflow graph of the pipeline, with edges and nodes |
| config.username | String | Yes | Username of the user that creates this event |
| config.causeMessage | String | No | Message that describes why the event was created |

Expand All @@ -656,8 +657,8 @@ factory.get({ pipelineId, sha }).then(model => {

| Parameter | Type | Description |
| :------------- | :---- | :-------------|
| id | String | The unique ID for the build |
| config.pipelineId | String | Unique identifier of pipeline |
| id | Number | The unique ID for the build |
| config.pipelineId | Number | Unique identifier of pipeline |
| config.sha | String | Commit sha that the event was based on |

### Event Model
Expand All @@ -669,9 +670,21 @@ const factory = Model.EventFactory.getInstance({
scm
});
const config = {
pipelineId: '12345f642bbfd1886623964b4cff12db59869e5d',
pipelineId: 1,
sha: 'ccc49349d3cffbd12ea9e3d41521480b4aa5de5f',
workflow: ['main', 'publish'],
workflowGraph: {
nodes: [
{ name: '~pr' },
{ name: '~commit' },
{ name: 'main' },
{ name: 'publish' }
],
edges: [
{ src: '~pr', dest: 'main' },
{ src: '~commit', dest: 'main' },
{ src: 'main', dest: 'publish' }
]
},
username: 'stjohn',
causeMessage: 'Merge pull request #26 from screwdriver-cd/models'
}
Expand All @@ -685,7 +698,7 @@ Example event model that got created:
```json
{
"type": "pipeline",
"pipelineId": "12345f642bbfd1886623964b4cff12db59869e5d",
"pipelineId": "1",
"sha": "ccc49349d3cffbd12ea9e3d41521480b4aa5de5f",
"createTime": "2038-01-19T03:14:08.131Z",
"commit": {
Expand All @@ -698,7 +711,19 @@ Example event model that got created:
"username": "imbatman"
}
},
"workflow": ["main", "publish"],
"workflowGraph": {
"nodes": [
{ "name": "~pr" },
{ "name": "~commit" },
{ "name": "main" },
{ "name": "publish" }
],
"edges": [
{ "src": "~pr", "dest": "main" },
{ "src": "~commit", "dest": "main" },
{ "src": "main", "dest": "publish" }
]
},
"causeMessage": "Merge pull request #26 from screwdriver-cd/models",
"creator": {
"avatar": "https://avatars.githubusercontent.com/u/2042?v=3",
Expand Down Expand Up @@ -765,7 +790,7 @@ factory.create(config).then(model => {
| config.description | String | Yes | Description of the template |
| config.maintainer | Array | Yes | Maintainer's email |
| config.config | Object | Yes | Config of the screwdriver-template.yaml |
| config.pipelineId | String | Yes | pipelineId of the template |
| config.pipelineId | Number | Yes | pipelineId of the template |
| config.labels | Array | No | Labels attached to the template |

#### Get
Expand All @@ -778,7 +803,7 @@ factory.get(id).then(model => {

| Parameter | Type | Description |
| :------------- | :---- | :-------------|
| id | String | The unique ID for the Template |
| id | Number | The unique ID for the Template |

#### Get Template
Get the latest template by name or get a specific template using name and version or name and tag. The version can be in any valid version format: either major, major.minor, or major.minor.patch. If no version is specified, the function will resolve with the latest version published. If no match is found, the function will resolve null.
Expand Down Expand Up @@ -844,7 +869,7 @@ factory.get(id).then(model => {

| Parameter | Type | Description |
| :------------- | :---- | :-------------|
| id | String | The unique ID for the Template Tag |
| id | Number | The unique ID for the Template Tag |

### Token Factory
#### Search
Expand Down
Loading

0 comments on commit 377e603

Please sign in to comment.