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

Add support for viewing parallel test runs to CI plugin #980

Merged
merged 31 commits into from
Aug 14, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9fa8f38
Ran oclif plugin and start ci:info
raulb Aug 3, 2018
34391d8
Update dependencies and config
raulb Aug 7, 2018
a25c2d3
Add color
raulb Aug 7, 2018
8e0855d
Update heroku ci interfaces
raulb Aug 7, 2018
14fc94f
Update to use latest API schema
raulb Aug 7, 2018
7d884f0
Remove variant
raulb Aug 7, 2018
dcc7e55
Upgrade heroku-cli/schema
raulb Aug 8, 2018
2d8e976
ci:info working
raulb Aug 8, 2018
94f67a5
Adapt code to ts
raulb Aug 8, 2018
c9149eb
Restructure in utils
raulb Aug 8, 2018
837e3c9
Add ci:last
raulb Aug 8, 2018
df55ab9
Add tests to ci:info
raulb Aug 9, 2018
c422be2
Pulled interfaces from Kolkrabbi schema
raulb Aug 9, 2018
f11c781
WIP migrating ci:run
raulb Aug 9, 2018
2f6eb76
Move utilities and update dependencies
raulb Aug 10, 2018
c45bf8d
Use the right host
raulb Aug 10, 2018
50c110c
Add logs back
raulb Aug 10, 2018
0ac2849
using cli-ux to show progress and completion
jabrown85 Aug 10, 2018
a68e114
Display of test run works for single and multi-node
jabrown85 Aug 10, 2018
f0f5a8f
Add rerun command
jabrown85 Aug 10, 2018
6147f3e
Removing commands in favor of new commands
jabrown85 Aug 10, 2018
95050da
Fixed up tests
jabrown85 Aug 10, 2018
7b354c8
Delete test no longer necessary
raulb Aug 13, 2018
3eda3c6
Add typed sinon
raulb Aug 13, 2018
13387c0
Add test for run
raulb Aug 13, 2018
d461f42
Added new package to cli, got run command tests working
jabrown85 Aug 13, 2018
5c060b9
Adding re-run tests
jabrown85 Aug 13, 2018
8a88c30
more tests
jabrown85 Aug 13, 2018
da144ef
Updated readme and updated another test
jabrown85 Aug 13, 2018
213bd06
simplify test
jabrown85 Aug 13, 2018
6067b14
removing try...catch that was making test the error codes harder
jabrown85 Aug 13, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Removing commands in favor of new commands
  • Loading branch information
jabrown85 authored and raulb committed Aug 14, 2018
commit 6147f3e170672e86480934ef02a96238efb765af
39 changes: 0 additions & 39 deletions packages/ci-v5/commands/ci/info.js

This file was deleted.

40 changes: 0 additions & 40 deletions packages/ci-v5/commands/ci/last.js

This file was deleted.

69 changes: 0 additions & 69 deletions packages/ci-v5/commands/ci/rerun.js

This file was deleted.

58 changes: 0 additions & 58 deletions packages/ci-v5/commands/ci/run.js

This file was deleted.

7 changes: 4 additions & 3 deletions packages/ci/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
"@heroku-cli/schema": "^1.0.12",
"@oclif/command": "^1",
"@oclif/config": "^1",
"async-file": "^2.0.2",
"@types/inquirer": "0.0.42",
"@types/validator": "^9.4.1",
"async-file": "^2.0.2",
"cli-ux": "^4.7.3",
"got": "^8.3.2",
"inquirer": "^6.0.0",
"tslib": "^1",
Expand All @@ -23,15 +24,15 @@
"@oclif/dev-cli": "^1",
"@oclif/plugin-help": "^2",
"@oclif/test": "^1.1.0",
"@types/nock": "^9.3.0",
"nock": "^9.2.5",
"@oclif/tslint": "^1",
"@types/chai": "^4",
"@types/mocha": "^5",
"@types/nock": "^9.3.0",
"@types/node": "^10",
"chai": "^4",
"globby": "^8",
"mocha": "^5",
"nock": "^9.2.5",
"nyc": "^12",
"ts-node": "^6",
"tslint": "^5",
Expand Down
4 changes: 2 additions & 2 deletions packages/ci/src/commands/ci/last.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export default class CiLast extends Command {

try {
const headers = {Range: 'number ..; order=desc,max=1'}
const {body: latestTestRun} = await this.heroku.get<Heroku.TestRun>(`/pipelines/${pipeline.id}/test-runs`, {headers})
const {body: testRun} = await this.heroku.get<Heroku.TestRun>(`/pipelines/${pipeline.id}/test-runs/${latestTestRun[0].number}`)
const {body: latestTestRuns} = await this.heroku.get<Heroku.TestRun[]>(`/pipelines/${pipeline.id}/test-runs`, {headers})
const {body: testRun} = await this.heroku.get<Heroku.TestRun>(`/pipelines/${pipeline.id}/test-runs/${latestTestRuns[0].number}`)
const {body: testNodes} = await this.heroku.get<Heroku.TestNode[]>(`/test-runs/${testRun.id}/test-nodes`)

await displayTestRunInfo(this, testRun, testNodes, flags.node)
Expand Down
11 changes: 6 additions & 5 deletions packages/ci/src/commands/ci/rerun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
import {Command, flags} from '@heroku-cli/command'
import * as Heroku from '@heroku-cli/schema'

import cli from 'cli-ux'

import * as Kolkrabbi from '../../interfaces/kolkrabbi'

import {getPipeline} from '../../utils/pipelines'
import {displayAndExit} from '../../utils/test-run'

import {createSourceBlob} from '../../utils/source'
import cli from 'cli-ux'

export default class CiReRun extends Command {
static description = 'rerun tests against current directory'
Expand All @@ -29,17 +30,17 @@ export default class CiReRun extends Command {
const {flags, args} = this.parse(CiReRun)
const pipeline = await getPipeline(flags, this)

let sourceTestRun:Heroku.TestRun;
let sourceTestRun: Heroku.TestRun

if (args.number) {
const testRunResponse = await this.heroku.get<Heroku.TestRun>(`/pipelines/${pipeline.id}/test-runs/${args.number}`)
sourceTestRun = testRunResponse.body;
sourceTestRun = testRunResponse.body
} else {
// TODO: why is this returning more than 1 record with that header in place?
const {body: testRuns} = await this.heroku.get<Heroku.TestRun[]>(`/pipelines/${pipeline.id}/test-runs`, {headers: {Range: 'number ..; order=desc,max=1'}})
sourceTestRun = testRuns[0];
sourceTestRun = testRuns[0]
}
this.log(`Rerunning test run #${sourceTestRun.number}...`);
this.log(`Rerunning test run #${sourceTestRun.number}...`)

cli.action.start('Preparing source')
const sourceBlobUrl = await createSourceBlob(sourceTestRun.commit_sha, this)
Expand Down
3 changes: 2 additions & 1 deletion packages/ci/src/commands/ci/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
import {Command, flags} from '@heroku-cli/command'
import * as Heroku from '@heroku-cli/schema'

import cli from 'cli-ux'

import * as Kolkrabbi from '../../interfaces/kolkrabbi'

import {getPipeline} from '../../utils/pipelines'
import {displayAndExit} from '../../utils/test-run'

import {createSourceBlob} from '../../utils/source'
import cli from 'cli-ux'

const git = require('../../utils/git')
export default class CiRun extends Command {
Expand Down
5 changes: 3 additions & 2 deletions packages/ci/src/utils/test-run.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import color from '@heroku-cli/color'
import {get, RequestOptions} from 'https'

import cli from 'cli-ux'

import {Command} from '@heroku-cli/command'

import * as Heroku from '@heroku-cli/schema'
import * as http from 'http'
import cli from 'cli-ux'

function logStream(url: RequestOptions | string, fn: (res: http.IncomingMessage) => void) {
return get(url, fn)
Expand Down Expand Up @@ -80,7 +81,7 @@ const RUNNING_STATES = [RUNNING].concat(TERMINAL_STATES)
const BUILDING_STATES = [BUILDING, RUNNING].concat(TERMINAL_STATES)

async function waitForStates(states: string[], testRun: Heroku.TestRun, command: Command) {
let newTestRun = testRun;
let newTestRun = testRun

while (!states.includes(newTestRun.status!.toString())) {
let {body: bodyTestRun} = await command.heroku.get<Heroku.TestRun>(`/pipelines/${testRun.pipeline!.id}/test-runs/${testRun.number}`)
Expand Down
7 changes: 2 additions & 5 deletions packages/ci/test/commands/ci/info.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,15 @@ describe('ci:info', () => {
pipeline: {id: pipeline.id},
status: 'succeeded',
setup_stream_url: `https://test-output.heroku.com/streams/${testRun.id.substring(0, 3)}/test-runs/${testRun.id}`,
output_stream_url: `https://test-output.heroku.com/streams/${testRun.id.substring(0, 3)}/test-runs/${testRun.id}`,
output_stream_url: `https://test-output.heroku.com/streams/${testRun.id.substring(0, 3)}/test-runs/${testRun.id}`
}
])
})
.nock('https://test-output.heroku.com/streams', testOutputAPI => {
testOutputAPI.get(`${testRun.id.substring(0, 3)}/test-runs/${testRun.id}`)
testOutputAPI.get(`/${testRun.id.substring(0, 3)}/test-runs/${testRun.id}`)
.reply(200, 'Test output')
})
.command(['ci:info', `${testRun.number}`, `--pipeline=${pipeline.name}`])
.catch(e => {
expect(e.message).to.contain('WTH')
})
.it('and a pipeline without parallel test runs it shows node output', ({stdout}) => {
expect(stdout).to.equal('Show info here----\n')
})
Expand Down
Loading