ci: break down to multiple stages \w prallel jobs

Biggest benefit of using separate stage for tests and release
is that we are not waiting for osx VM instance instance any
more on every PR, just to run
`if [[ -z "$TRAVIS_TAG" ]]; then echo "Skipping this build for non-tag builds."; exit 0; fi`
there.

It alos adds clarity to CI structure => is easier to maintain.

Signed-off-by: Alexander Bezzubov <bzz@apache.org>
This commit is contained in:
Alexander Bezzubov 2018-10-17 23:22:47 +03:00
parent ccb6264699
commit 20f6f11a43
No known key found for this signature in database
GPG Key ID: 8039F5787EFCD05D

View File

@ -5,14 +5,13 @@ language: go
go: go:
- '1.10.x' - '1.10.x'
go_import_path: gopkg.in/src-d/enry.v1
addons: addons:
apt: apt:
packages: packages:
- libonig-dev - libonig-dev
matrix:
fast_finish: true
env: env:
global: global:
- GO_VERSION='1.10.x' - GO_VERSION='1.10.x'
@ -20,120 +19,91 @@ env:
- ONIGURUMA=0 - ONIGURUMA=0
- ONIGURUMA=1 - ONIGURUMA=1
install: stages:
- go version - name: test
- rm -rf $GOPATH/src/gopkg.in/src-d - name: release
- mkdir -p $GOPATH/src/gopkg.in/src-d if: tag IS present
- ln -s $PWD $GOPATH/src/gopkg.in/src-d/enry.v1
- cd $GOPATH/src/gopkg.in/src-d/enry.v1
- if [ "$ONIGURUMA" == "1" ]; then tags="$tags oniguruma"; fi; go get -v -t --tags "$tags" ./...
script:
- make test-coverage
after_success:
- bash <(curl -s https://codecov.io/bash)
before_deploy:
- make packages
deploy:
provider: releases
api_key:
secure: $GITHUB_TOKEN
file_glob: true
file: build/*.tar.gz
skip_cleanup: true
on:
tags: true
jobs: jobs:
env:
- ONIGURUMA=0
include: include:
- stage: test - name: 'golang unitTests'
stage: test
install:
- if [ "$ONIGURUMA" == "1" ]; then tags="$tags oniguruma"; fi; go get -v -t --tags "$tags" ./...
script:
- make test-coverage
after_success:
- bash <(curl -s https://codecov.io/bash)
- name: 'java unitTests'
stage: test
language: scala language: scala
jdk: oraclejdk8 jdk: oraclejdk8
install: install:
- gimme version - gimme version
- eval "$(curl -sL https://raw.githubusercontent.com/travis-ci/gimme/master/gimme | GIMME_GO_VERSION=$GO_VERSION bash)" - eval "$(curl -sL https://raw.githubusercontent.com/travis-ci/gimme/master/gimme | GIMME_GO_VERSION=$GO_VERSION bash)"
- go version - go version
- export GOPATH=$HOME/gopath
- mkdir -p $GOPATH/src/gopkg.in/src-d/enry.v1
- rsync -az ${TRAVIS_BUILD_DIR}/ $GOPATH/src/gopkg.in/src-d/enry.v1
- go get -v gopkg.in/src-d/enry.v1/... - go get -v gopkg.in/src-d/enry.v1/...
before_script: before_script:
- cd java - cd java
- make - make
script: script:
- make test - make test
before_deploy: - name: 'linux packages'
- cd .. stage: release
script: make packages
deploy: deploy:
provider: releases provider: releases
api_key:
secure: $GITHUB_TOKEN
file_glob: true
file: build/*.tar.gz
skip_cleanup: true
- name: 'linux shared lib'
stage: release
script: make linux-shared
deploy:
provider: release
api_key: api_key:
secure: $GITHUB_TOKEN secure: $GITHUB_TOKEN
file: file:
- ./.shared/linux-x86-64/libenry.so - ./.shared/linux-x86-64/libenry.so
skip_cleanup: true skip_cleanup: true
on:
tags: true
- stage: Build MacOS shared
- name: 'macOS shared lib'
stage: release
sudo: true
env: env:
- OSXCROSS_PACKAGE="osxcross_3034f7149716d815bc473d0a7b35d17e4cf175aa.tar.gz" - OSXCROSS_PACKAGE="osxcross_3034f7149716d815bc473d0a7b35d17e4cf175aa.tar.gz"
- OSXCROSS_URL="https://github.com/bblfsh/client-scala/releases/download/v1.5.2/${OSXCROSS_PACKAGE}" - OSXCROSS_URL="https://github.com/bblfsh/client-scala/releases/download/v1.5.2/${OSXCROSS_PACKAGE}"
- PATH="/$HOME/osxcross/bin:$PATH" - PATH="/$HOME/osxcross/bin:$PATH"
sudo: true
install: install:
- if [[ -z "$TRAVIS_TAG" ]]; then echo "Skipping this build for non-tag builds."; exit 0; fi
- rm -rf $GOPATH/src/gopkg.in/src-d
- mkdir -p $GOPATH/src/gopkg.in/src-d
- ln -s $PWD $GOPATH/src/gopkg.in/src-d/enry.v1
- cd $GOPATH/src/gopkg.in/src-d/enry.v1
- go get -v -t ./... - go get -v -t ./...
- sudo apt-get update - sudo apt-get update
- sudo apt-get install -y --no-install-recommends clang g++ gcc gcc-multilib libc6-dev libc6-dev-i386 mingw-w64 patch xz-utils - sudo apt-get install -y --no-install-recommends clang g++ gcc gcc-multilib libc6-dev libc6-dev-i386 mingw-w64 patch xz-utils
- cd ${HOME} - cd ${HOME}
- curl -sSL ${OSXCROSS_URL} | tar -C ${HOME} -xzf - - curl -sSL ${OSXCROSS_URL} | tar -C ${HOME} -xzf -
- cd $GOPATH/src/gopkg.in/src-d/enry.v1 - cd $GOPATH/src/gopkg.in/src-d/enry.v1
script: make darwin-shared
script:
- make darwin-shared
before_deploy:
- echo "skip before_deploy"
deploy: deploy:
provider: releases provider: releases
api_key: api_key:
secure: $GITHUB_TOKEN secure: $GITHUB_TOKEN
file: ./.shared/darwin/libenry.dylib file: ./.shared/darwin/libenry.dylib
skip_cleanup: true skip_cleanup: true
on:
tags: true
- stage: Publish Maven - name: 'java: publish to maven'
stage: release
language: scala language: scala
jdk: oraclejdk8 jdk: oraclejdk8
install: install:
- eval "$(curl -sL https://raw.githubusercontent.com/travis-ci/gimme/master/gimme | GIMME_GO_VERSION=$GO_VERSION bash)" - eval "$(curl -sL https://raw.githubusercontent.com/travis-ci/gimme/master/gimme | GIMME_GO_VERSION=$GO_VERSION bash)"
- go version - go version
- export GOPATH=$HOME/gopath - go version
- mkdir -p $GOPATH/src/gopkg.in/src-d/enry.v1
- rsync -az ${TRAVIS_BUILD_DIR}/ $GOPATH/src/gopkg.in/src-d/enry.v1
- go get -v gopkg.in/src-d/enry.v1/... - go get -v gopkg.in/src-d/enry.v1/...
before_script: before_script:
- if [[ -z "$TRAVIS_TAG" ]]; then echo "Skipping this build for non-tag builds."; exit 0; fi
- cd java - cd java
- make - make
- curl -o ./shared/linux-x86-64/libenry.so -sL "https://github.com/$TRAVIS_REPO_SLUG/releases/download/$TRAVIS_TAG/libenry.so" - curl -o ./shared/linux-x86-64/libenry.so -sL "https://github.com/$TRAVIS_REPO_SLUG/releases/download/$TRAVIS_TAG/libenry.so"
@ -141,19 +111,16 @@ jobs:
- curl -o ./shared/darwin/libenry.dylib -sL "https://github.com/$TRAVIS_REPO_SLUG/releases/download/$TRAVIS_TAG/libenry.dylib" - curl -o ./shared/darwin/libenry.dylib -sL "https://github.com/$TRAVIS_REPO_SLUG/releases/download/$TRAVIS_TAG/libenry.dylib"
- openssl aes-256-cbc -K $encrypted_a0e1c69dbbc7_key -iv $encrypted_a0e1c69dbbc7_iv -in key.asc.enc -out key.asc -d - openssl aes-256-cbc -K $encrypted_a0e1c69dbbc7_key -iv $encrypted_a0e1c69dbbc7_iv -in key.asc.enc -out key.asc -d
- gpg --no-default-keyring --primary-keyring ./project/.gnupg/pubring.gpg --secret-keyring ./project/.gnupg/secring.gpg --keyring ./project/.gnupg/pubring.gpg --fingerprint --import key.asc - gpg --no-default-keyring --primary-keyring ./project/.gnupg/pubring.gpg --secret-keyring ./project/.gnupg/secring.gpg --keyring ./project/.gnupg/pubring.gpg --fingerprint --import key.asc
script: script:
- make test # ensure the shared objects are functional - make test # ensure the shared objects are functional
- ./sbt publishLocal - ./sbt publishLocal
- ./sbt publishSigned - ./sbt publishSigned
- ./sbt sonatypeRelease - ./sbt sonatypeRelease
before_deploy: before_deploy:
- rm ./target/enry-java-*-javadoc.jar - rm ./target/enry-java-*-javadoc.jar
- rm ./target/enry-java-*-sources.jar - rm ./target/enry-java-*-sources.jar
- rm ./target/enry-java-*-tests.jar - rm ./target/enry-java-*-tests.jar
- rm ./target/enry-java-assembly-*.jar - rm ./target/enry-java-assembly-*.jar
deploy: deploy:
provider: releases provider: releases
api_key: api_key:
@ -161,5 +128,3 @@ jobs:
file_glob: true file_glob: true
file: ./target/enry-java*.jar file: ./target/enry-java*.jar
skip_cleanup: true skip_cleanup: true
on:
tags: true