Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(travis): Add explicit Travis integration
This will add a new Travis trigger and a new Travis stage. Corresponds with spinnaker/echo#141 and spinnaker/orca#1213. BREAKING CHANGE: Existing pipelines will continue to work, but `travis` will have to be added to `triggerTypes` in `settings.js` before you can set up new travis triggers/stages or edit any existing travis triggers/stages.
- Loading branch information
Showing
33 changed files
with
1,339 additions
and
56 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
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
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
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,47 @@ | ||
import {IPromise, module, IQService} from 'angular'; | ||
|
||
import {API_SERVICE, Api} from 'core/api/api.service'; | ||
import {IBuild} from 'core/domain/IBuild'; | ||
import {IJobConfig} from 'core/domain/IJobConfig'; | ||
|
||
export enum BuildServiceType { | ||
Jenkins, Travis | ||
} | ||
|
||
export class IgorService { | ||
static get $inject() { return ['API', '$q']; } | ||
|
||
constructor(private API: Api, private $q: IQService) {} | ||
|
||
public listMasters(type: BuildServiceType = null): IPromise<string[]> { | ||
const allMasters: IPromise<string[]> = this.API.one('v2').one('builds').get(); | ||
if (!allMasters) { | ||
return this.$q.reject('An error occurred when retrieving build masters'); | ||
} | ||
switch (type) { | ||
case BuildServiceType.Jenkins: | ||
return allMasters.then(masters => masters.filter(master => !(/^travis-/.test(master)))); | ||
case BuildServiceType.Travis: | ||
return allMasters.then(masters => masters.filter(master => /^travis-/.test(master))); | ||
default: | ||
return allMasters; | ||
} | ||
} | ||
|
||
public listJobsForMaster(master: string): IPromise<string[]> { | ||
return this.API.one('v2').one('builds').one(master).one('jobs').get(); | ||
} | ||
|
||
public listBuildsForJob(master: string, job: string): IPromise<IBuild[]> { | ||
return this.API.one('v2').one('builds').one(master).one('builds').one(job).get(); | ||
} | ||
|
||
public getJobConfig(master: string, job: string): IPromise<IJobConfig> { | ||
return this.API.one('v2').one('builds').one(master).one('jobs').one(job).get(); | ||
} | ||
} | ||
|
||
export const IGOR_SERVICE = 'spinnaker.core.ci.jenkins.igor.service'; | ||
module(IGOR_SERVICE, [ | ||
API_SERVICE, | ||
]).factory('igorService', (API: Api, $q: IQService) => new IgorService(API, $q)); |
This file was deleted.
Oops, something went wrong.
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
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 @@ | ||
export interface IArtifact { | ||
displayPath: string; | ||
fileName: string; | ||
relativePath: string; | ||
} | ||
|
||
export interface IBuild { | ||
building: boolean; | ||
duration: number; | ||
name: string; | ||
number: number; | ||
result: string; | ||
timestamp: Date; | ||
url: string; | ||
artifacts: IArtifact[]; | ||
} |
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,15 @@ | ||
export interface ParameterDefinitionList { | ||
defaultValue: string; | ||
description?: string; | ||
name: string; | ||
} | ||
|
||
export interface IJobConfig { | ||
buildable: boolean; | ||
concurrentBuild: boolean; | ||
description: string; | ||
displayName: string; | ||
name: string; | ||
parameterDefinitionList: ParameterDefinitionList[]; | ||
url: string; | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
3 changes: 2 additions & 1 deletion
3
app/scripts/modules/core/pipeline/config/stages/jenkins/jenkinsStage.module.js
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 |
---|---|---|
@@ -1,12 +1,13 @@ | ||
'use strict'; | ||
|
||
let angular = require('angular'); | ||
import {IGOR_SERVICE} from 'core/ci/igor.service'; | ||
|
||
module.exports = angular.module('spinnaker.core.pipeline.stage.jenkins', [ | ||
require('./jenkinsStage.js'), | ||
require('../stage.module.js'), | ||
require('../core/stage.core.module.js'), | ||
require('core/utils/timeFormatters.js'), | ||
require('core/ci/jenkins/igor.service.js'), | ||
IGOR_SERVICE, | ||
require('./jenkinsExecutionDetails.controller.js'), | ||
]); |
79 changes: 79 additions & 0 deletions
79
...ipts/modules/core/pipeline/config/stages/travis/travisExecutionDetails.controller.spec.ts
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,79 @@ | ||
import {IScope, IControllerService, IRootScopeService, mock} from 'angular'; | ||
|
||
import {TRAVIS_EXECUTION_DETAILS_CONTROLLER, TravisExecutionDetailsCtrl} from './travisExecutionDetails.controller'; | ||
|
||
describe('Travis Execution Details Controller:', () => { | ||
let $scope: IScope, | ||
$ctrl: IControllerService; | ||
|
||
beforeEach(mock.module(TRAVIS_EXECUTION_DETAILS_CONTROLLER)); | ||
|
||
beforeEach(mock.inject(($controller: IControllerService, $rootScope: IRootScopeService) => { | ||
$ctrl = $controller; | ||
$scope = $rootScope.$new(); | ||
})); | ||
|
||
const initializeController = ((stage: any): TravisExecutionDetailsCtrl => { | ||
$scope.stage = stage; | ||
return $ctrl(TravisExecutionDetailsCtrl, { | ||
$scope, | ||
executionDetailsSectionService: { synchronizeSection: ({}, fn: () => any) => fn(), }, | ||
}); | ||
}); | ||
|
||
describe('getting failure message', () => { | ||
|
||
it('should count number of failing tests', () => { | ||
const stage = { | ||
context: { | ||
buildInfo: { | ||
testResults: [ | ||
{ failCount: 0 }, | ||
{ failCount: 3 }, | ||
{ failCount: 2 } | ||
] | ||
} | ||
} | ||
}; | ||
|
||
const controller = initializeController(stage); | ||
|
||
expect(controller.failureMessage).toBe('5 tests failed.'); | ||
}); | ||
|
||
it ('should fall back to "build failed" message when no failed tests found, but result is "FAILURE"', () => { | ||
let stage = { | ||
context: { | ||
buildInfo: { | ||
result: 'FAILURE', | ||
testResults: [] as any | ||
} | ||
} | ||
}; | ||
|
||
let controller = initializeController(stage); | ||
|
||
expect(controller.failureMessage).toBe('Build failed.'); | ||
|
||
stage = { | ||
context: { | ||
buildInfo: { | ||
result: 'FAILURE', | ||
testResults: [ { failCount: 0 }] | ||
} | ||
} | ||
}; | ||
|
||
controller = initializeController(stage); | ||
|
||
expect(controller.failureMessage).toBe('Build failed.'); | ||
}); | ||
|
||
it ('should set failureMessage to undefined when not failing', function () { | ||
const controller = initializeController({}); | ||
expect(controller.failureMessage).toBeUndefined(); | ||
}); | ||
|
||
}); | ||
|
||
}); |
Oops, something went wrong.