forked from angular/components
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Introduces a gulp task that will run on Travis Push builds and will upload coverage results to a Firebase database. Closes angular#128.
- Loading branch information
1 parent
0560eab
commit 33e7c1c
Showing
7 changed files
with
58 additions
and
3 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
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,34 @@ | ||
import {task} from 'gulp'; | ||
import {existsSync} from 'fs-extra'; | ||
import {COVERAGE_RESULT_FILE} from '../constants'; | ||
import {spawnSync} from 'child_process'; | ||
import {isTravisPushBuild, openFirebaseDashboardDatabase} from '../task_helpers'; | ||
|
||
task('coverage:upload', () => { | ||
if (!existsSync(COVERAGE_RESULT_FILE)) { | ||
throw new Error('No coverage file has been found!'); | ||
} | ||
|
||
if (!isTravisPushBuild()) { | ||
throw new Error('Coverage results will be only uploaded inside of Travis Push builds.'); | ||
} | ||
|
||
let results = require(COVERAGE_RESULT_FILE)['total']; | ||
|
||
// To reduce database payload, the covered lines won't be pushed to the Firebase database. | ||
delete results['linesCovered']; | ||
|
||
return uploadResults(results); | ||
}); | ||
|
||
/** Uploads the coverage results to the firebase database. */ | ||
function uploadResults(results: any): Promise<void> { | ||
let latestSha = spawnSync('git', ['rev-parse', 'HEAD']).stdout.toString().trim(); | ||
let database = openFirebaseDashboardDatabase(); | ||
|
||
return database.ref('coverage-reports').child(latestSha).set(results) | ||
.then(() => database.goOffline(), () => database.goOffline()); | ||
} | ||
|
||
// TODO(devversion): In the future we might have a big database where we can store full summaries. | ||
// TODO(devversion): We could also move the coverage to a bot and reply with the results on PRs. |