forked from typedb/typedb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
95 lines (81 loc) · 3.23 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!groovy
// In order to add a new integration test, create a new sub-folder under `grakn-test` with two executable scripts,
// `load.sh` and `validate.sh`. Add the name of the folder to the list `integrationTests` below.
// `validate.sh` will be passed the branch name (e.g. "master") as the first argument
def integrationTests = ["test-snb", "test-biomed"]
//This sets properties in the Jenkins server. In this case run every 8 hours
properties([pipelineTriggers([cron('H H/8 * * *')])])
def slackGithub(String message, String color = null) {
def user = sh(returnStdout: true, script: "git show --format=\"%aN\" | head -n 1").trim()
slackSend channel: "#github", color: color, message: """
${message} on ${env.BRANCH_NAME}: ${env.JOB_NAME} #${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)
authored by - ${user}"""
}
def runIntegrationTest(String workspace, String moduleName) {
String modulePath = "${workspace}/grakn-test/${moduleName}"
stage(moduleName) {
withPath("${modulePath}:${modulePath}/src/main/bash") {
withGrakn(workspace) {
timeout(180) {
stage('Load') {
sh "load.sh"
}
}
timeout(360) {
stage('Validate') {
sh "validate.sh ${env.BRANCH_NAME}"
}
}
}
}
}
}
def withGrakn(String workspace, Closure closure) {
withPath("${workspace}/grakn-test/test-integration/src/test/bash") {
//Everything is wrapped in a try catch so we can handle any test failures
//If one test fails then all the others will stop. I.e. we fail fast
try {
timeout(15) {
//Stages allow you to organise and group things within Jenkins
stage('Start Grakn') {
sh "build-grakn.sh ${env.BRANCH_NAME}"
archiveArtifacts artifacts: "grakn-dist/target/grakn-dist*.tar.gz"
sh 'init-grakn.sh'
}
}
closure()
} catch (error) {
slackGithub "Periodic Build Failed" "danger"
throw error
} finally { // Tears down test environment
timeout(5) {
stage('Stop Grakn') {
archiveArtifacts artifacts: 'grakn-package/logs/grakn.log'
sh 'tear-down.sh'
}
}
}
}
}
def withPath(String path, Closure closure) {
return withEnv(["PATH+EXTRA=${path}"], closure)
}
//Only run validation master/stable
if (env.BRANCH_NAME in ['master', 'stable']) {
properties([
buildDiscarder(logRotator(numToKeepStr: '30', artifactNumToKeepStr: '7'))
])
node {
String workspace = pwd()
checkout scm
slackGithub "Build started"
stage('Run the benchmarks') {
sh "mvn clean test --batch-mode -P janus -Dtest=*Benchmark -DfailIfNoTests=false -Dmaven.repo.local=${workspace}/maven -Dcheckstyle.skip=true -Dfindbugs.skip=true -Dpmd.skip=true"
archiveArtifacts artifacts: 'grakn-test/test-integration/benchmarks/*.json'
}
for (String moduleName : integrationTests) {
runIntegrationTest(workspace, moduleName)
}
slackGithub "Periodic Build Success" "good"
}
}