Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
PengTian0 committed Aug 8, 2017
0 parents commit 95f5a24
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/pipeline/rackhd/source_code/UnitTest.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package pipeline.rackhd.source_code

def runTest(manifest_dict, repo_name){
/*
manifest is a map contains manifest stash name and stash path:
{"stash_name":xxx,
"stash_path":xxx}
repo_name is a String which is the name of the repository
*/
def shareMethod = new pipeline.common.ShareMethod()
String label_name="unittest"
lock(label:label_name,quantity:1){
node_name = shareMethod.occupyAvailableLockedResource(label_name, [])
node(node_name){
deleteDir()
String on_build_config_dir = "$WORKSPACE/on-build-config"
shareMethod.checkoutOnBuildConfig(on_build_config_dir)
String manifest_name = manifest_dict["stash_name"]
unstash "$manifest_name"
String manifest_path = "$WORKSPACE/" + manifest_dict["stash_path"]
def manifest = new pipeline.common.Manifest()
String repo_dir = manifest.checkoutTargetRepo(manifest_path, repo_name, on_build_config_dir)
try{
sh """#!/bin/bash -ex
pushd $repo_dir
./HWIMO-TEST
popd
"""
} finally{
dir(repo_dir){
junit "*.xml"
archiveArtifacts "*.xml"
}
}
}
}
}

return this

23 changes: 23 additions & 0 deletions workflows/pr_gate/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@Library('my_library') _
node{
timestamps{
def manifest = new pipeline.common.Manifest()
def unit_test = new pipeline.rackhd.source_code.UnitTest()

manifest.downloadManifest("https://dl.bintray.com/rackhd/binary/master-20170806","master-20170806")
stash name: "prgate_manifest", includes: "master-20170806"
manifest_dict = [:]
manifest_dict["stash_name"] = "prgate_manifest"
manifest_dict["stash_path"] = "master-20170806"
stage("Unit Test"){
def unit_test_branches = [:]
unit_test_branches["on-core"] = {
unit_test.runTest(manifest_dict, "on-core")
}
unit_test_branches["on-tasks"] = {
unit_test.runTest(manifest_dict, "on-tasks")
}
parallel unit_test_branches
}
}
}

0 comments on commit 95f5a24

Please sign in to comment.