From d6d5945ab489e78f385df706655475a6fc2a93e7 Mon Sep 17 00:00:00 2001 From: Adam Babik Date: Wed, 29 Nov 2017 07:48:40 +0100 Subject: [PATCH] Clean up Jenkinsfile-manual and Travis (#478) Small clean up of Jenkinsfile-manual required after rebuilding Jenkins. Also improved .travis.yml a bit. --- .travis.yml | 5 ++- Jenkinsfile-manual | 87 ++++++++++++++++++++++++----------------- Makefile | 2 +- static/tools/mk/lint.mk | 2 +- 4 files changed, 57 insertions(+), 39 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7b28bab3b..2217e1848 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,14 +7,15 @@ sudo: false dist: trusty install: - go get golang.org/x/tools/cmd/cover -- make lint-deps +- make mock-install +- make lint-install jobs: include: - stage: Lint script: make lint - stage: Test unit and integration script: make test-unit-coverage - - stage: Test e2e on privite network + - stage: Test e2e on private network script: make test-e2e - stage: Test e2e on public network # disable running this stage for PRs as they do not have access diff --git a/Jenkinsfile-manual b/Jenkinsfile-manual index 2a3b4ae69..3c1916315 100644 --- a/Jenkinsfile-manual +++ b/Jenkinsfile-manual @@ -16,23 +16,30 @@ def getVersion(branch, sha, buildNumber) { } node('linux') { + env.GOPATH = "${env.WORKSPACE}" + + cloneDir = 'src/github.com/status-im/status-go' paramBranch = env.branch ? ('*/' + env.branch) : '*/develop' checkout( changelog: false, - poll: false, + poll: true, scm: [$class: 'GitSCM', branches: [[name: paramBranch]], doGenerateSubmoduleConfigurations: false, - extensions: [], + extensions: [ + [$class: 'RelativeTargetDirectory', relativeTargetDir: cloneDir] + ], submoduleCfg: [], userRemoteConfigs: [[url: 'https://github.com/status-im/status-go']]] ) def remoteOriginRegex = ~/^remotes\/origin\// - gitSHA = sh(returnStdout: true, script: 'git rev-parse HEAD').trim() - gitShortSHA = gitSHA.take(7) - gitBranch = sh(returnStdout: true, script: 'git name-rev --name-only HEAD').trim() - remoteOriginRegex + dir(cloneDir) { + gitSHA = sh(returnStdout: true, script: 'git rev-parse HEAD').trim() + gitShortSHA = gitSHA.take(8) + gitBranch = sh(returnStdout: true, script: 'git name-rev --name-only HEAD').trim() - remoteOriginRegex + } stage('Debug') { sh 'env' @@ -40,49 +47,59 @@ node('linux') { println(gitSHA) } - // TODO(adam): enable when unit tests start passing - // stage('Test') { - // sh 'make ci' - // } + stage('Test') { + sh ''' + make lint-install + make mock-install + + make ci + ''' + } stage('Build') { sh 'go get github.com/karalabe/xgo' parallel ( 'statusgo-android': { - sh 'make statusgo-android' + dir(cloneDir) { + sh 'make statusgo-android' + } }, 'statusgo-ios-simulator': { - sh ''' - make statusgo-ios-simulator - cd build/bin/statusgo-ios-9.3-framework/ - zip -r status-go-ios.zip Statusgo.framework - ''' + dir(cloneDir) { + sh ''' + make statusgo-ios-simulator + cd build/bin/statusgo-ios-9.3-framework/ + zip -r status-go-ios.zip Statusgo.framework + ''' + } } ) } stage('Deploy') { - // For branch builds, replace the old artifact. For develop keep all of them. - def version = gitBranch == 'develop' ? getVersion(gitBranch, gitShortSHA, '') : getVersion(gitBranch, gitShortSHA, env.BUILD_ID) - def server = Artifactory.server 'artifactory' - def uploadSpec = """{ - "files": [ - { - "pattern": "build/bin/statusgo-android-16.aar", - "target": "libs-release-local/status-im/status-go/${version}/status-go-${version}.aar" - }, - { - "pattern": "build/bin/statusgo-ios-9.3-framework/status-go-ios.zip", - "target": "libs-release-local/status-im/status-go-ios-simulator/${version}/status-go-ios-simulator-${version}.zip" - } - ] - }""" + dir(cloneDir) { + // For branch builds, replace the old artifact. For develop keep all of them. + def version = gitBranch == 'develop' ? getVersion(gitBranch, gitShortSHA, '') : getVersion(gitBranch, gitShortSHA, env.BUILD_ID) + def server = Artifactory.server 'artifacts' + def uploadSpec = """{ + "files": [ + { + "pattern": "build/bin/statusgo-android-16.aar", + "target": "libs-release-local/status-im/status-go/${version}/status-go-${version}.aar" + }, + { + "pattern": "build/bin/statusgo-ios-9.3-framework/status-go-ios.zip", + "target": "libs-release-local/status-im/status-go-ios-simulator/${version}/status-go-ios-simulator-${version}.zip" + } + ] + }""" - def buildInfo = Artifactory.newBuildInfo() - buildInfo.env.capture = false - buildInfo.name = 'status-go (' + gitBranch + '-' + gitShortSHA + ')' - server.upload(uploadSpec, buildInfo) - server.publishBuildInfo(buildInfo) + def buildInfo = Artifactory.newBuildInfo() + buildInfo.env.capture = false + buildInfo.name = 'status-go (' + gitBranch + '-' + gitShortSHA + ')' + server.upload(uploadSpec, buildInfo) + server.publishBuildInfo(buildInfo) + } } } diff --git a/Makefile b/Makefile index 5c78f4206..a3047648c 100644 --- a/Makefile +++ b/Makefile @@ -118,7 +118,7 @@ test-e2e: ##@tests Run e2e tests # e2e_test tag is required to include some files from ./lib without _test suffix go test -timeout 40m -tags e2e_test ./lib -network=$(networkid) -ci: lint mock-install mock test-unit test-e2e ##@tests Run all linters and tests at once +ci: lint mock test-unit test-e2e ##@tests Run all linters and tests at once clean: ##@other Cleanup rm -fr build/bin/* diff --git a/static/tools/mk/lint.mk b/static/tools/mk/lint.mk index de49ec178..4a2fd229c 100644 --- a/static/tools/mk/lint.mk +++ b/static/tools/mk/lint.mk @@ -2,7 +2,7 @@ LINT_EXCLUDE := --exclude='.*_mock.go' --exclude='geth/jail/doc.go' LINT_FOLDERS := extkeys cmd/... geth/... e2e/... LINT_FOLDERS_WITHOUT_TESTS := extkeys cmd/... geth/... -lint-deps: +lint-install: go get -u github.com/alecthomas/gometalinter gometalinter --install