Skip to content
This repository has been archived by the owner on Mar 8, 2020. It is now read-only.

Refactor CI #134

Merged
merged 13 commits into from
Oct 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 75 additions & 63 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,89 +1,101 @@
dist: xenial
language: scala
jdk:
- openjdk8
scala:
- 2.11.11

services:
- docker
# Build and test in Linux --> [if tag] Push .so to GH releases -------|
# |
# Build in OSX -------------> [if tag] Push .dylib to GH releases ------> [if tag] Download so,dylib,dll,
# | build, push to Maven
# Build in Windows ---------> [if tag] Push .dll to GH releases -------|


scala:
- 2.11.11

cache:
directories:
- $HOME/.ivy2
- $HOME/.sbt

stages:
- name: test
- name: build
- name: release
if: tag IS present

env:
global:
# TODO(#87): Improve CI
# OSXCROSS_PATCH_REV and OSXCROSS_REV versions of osxcross repo.
# OSXCROSS_REV is used to retrieve a version of that tool that does not include the .patch file for
# hash_table. Cannot use the most recent one for downloading the tool and the repo because it lacks
# some dependencies now. This boilerplate can be deleted if OSX_VERSION_MIN is bumped to 10.7.
# macOS SDK for that version does include stdlib, and we could just download osxcross without any
# patch (build.sh there does the work of patching as long as stlib is included in SDK)
- OSXCROSS_PATCH_REV=f67ce5033d0a01292c9ef156b95c025a3e1edcbc
- OSXCROSS_REV=3034f7149716d815bc473d0a7b35d17e4cf175aa
- XGO_REV=2d6d1848fb02b001c4019f4f4556720d4e8c4cea
- SDK_VERSION=10.11
- DARWIN_VERSION=15
- OSX_VERSION_MIN=10.6
- OSXCROSS_SDK_URL="https://s3.dockerproject.org/darwin/v2/MacOSX10.11.sdk.tar.xz"
deploy:
provider: releases
api_key:
secure: $GITHUB_TOKEN
file_glob: true
file: src/main/resources/lib/libscalauast*
skip_cleanup: true
on:
tags: true

before_install:
- chmod +x build.sh
- ./build.sh --clean --get-dependencies

jobs:
include:
- name: 'All tests'
stage: test
install: &test_setup_anchor
- &linux_build
name: 'Build and test in Linux'
stage: build
os: linux
dist: xenial
jdk: openjdk8
services:
- docker
before_install:
- docker run --privileged -d -p 9432:9432 --name bblfsh bblfsh/bblfshd
- docker exec -it bblfsh bblfshctl driver install --recommended
- sudo apt-get clean && sudo rm -r /var/lib/apt/lists/* && sudo apt-get update
- sudo apt-get install -y --no-install-recommends g++ gcc gcc-multilib libc6-dev libc6-dev-i386 patch xz-utils
- chmod +x build.sh
- ./build.sh --clean --get-dependencies
script:
- ./sbt assembly test
- ./build.sh --all
- ./sbt test
after_failure: &failure_logs_anchor
- docker logs bblfsh
- ls hs_* 1> /dev/null 2>&1 && cat hs_*

- &release
name: 'Cross-compile, release & publish to Sonatype'
- &osx_build
name: 'Build in OSX'
stage: build
os: osx
osx_image: xcode8.3
before_script:
# This is equivalent macosx-version-min=10.7
- export MACOSX_DEPLOYMENT_TARGET=10.7
# Travis osx support includes oraclejdk8 not openjdk8
- export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/
script:
- ./build.sh --all

- &windows_build
name: 'Build in Windows'
os: windows
# scala is not available, default one is ruby
language: cpp
before_script:
# Note the revision 8.222 could be changed as long as we update the JAVA_HOME
# variable appropriately. For sbt/scala jdk8 is needed.
- choco install adoptopenjdk8 --version=8.222
- export JAVA_HOME="/C/Program Files/AdoptOpenJDK/jdk8u222-b10"
- export PATH=$PATH:$JAVA_HOME:$JAVA_HOME/bin
script:
- ./build.sh --all

- <<: *linux_build
name: 'Release to Maven'
stage: release
env:
- OSXCROSS_PATH="$HOME/osxcross"
before_install:
- sudo apt-get clean && sudo rm -r /var/lib/apt/lists/* && sudo apt-get update
- sudo apt-get install -y --no-install-recommends clang mingw-w64
install:
- mkdir -p /tmp/osxcross
- cd /tmp/osxcross
# This downloads osxcross and builds the cross compiler
- curl -sSL "https://codeload.github.com/tpoechtrager/osxcross/tar.gz/${OSXCROSS_REV}" | tar -C "${PWD}" --strip=1 -xzf -
- curl -sSL -o tarballs/MacOSX${SDK_VERSION}.sdk.tar.xz ${OSXCROSS_SDK_URL}
- sudo tools/get_dependencies.sh
- UNATTENDED=yes ./build.sh >/dev/null
# This is the stdlib. Since we are using min Mac OS 10.6, we need one
- curl -sSL "https://github.com/karalabe/xgo/blob/${XGO_REV}/docker/base/patch.tar.xz?raw=true" | xz -dc - | tar -xf -
- mv v1 "target/SDK/MacOSX${SDK_VERSION}.sdk/usr/include/c++/v1"
# Fixes __hash_table file with a patch included in osxcross
# If this patch is not applied, we cannot import unordered_map in our .cpp files
- curl -sSL "https://github.com/tpoechtrager/osxcross/blob/${OSXCROSS_PATCH_REV}/patches/libcxx__hash_table.patch?raw=true" -o hash_table.patch
- patch -d target/SDK/MacOSX${SDK_VERSION}.sdk/ -N -p1 < hash_table.patch
- mv target "${OSXCROSS_PATH}"
- rm -rf /tmp/osxcross "${OSXCROSS_PATH}/SDK/MacOSX${SDK_VERSION}.sdk/usr/share/man"
- cd $TRAVIS_BUILD_DIR
before_script:
- ASSETS_URL="https://github.com/bblfsh/scala-client/releases/download/$TRAVIS_TAG"
- DEST_FOLDER="src/main/resources/lib"
- mkdir -p $DEST_FOLDER
script:
- ./sbt assembly || travis_terminate 1
- ./sbt publishLocal
- wget $ASSETS_URL/libscalauast.dylib -o $DEST_FOLDER/libscalauast.dylib
- wget $ASSETS_URL/libscalauast.dll -o $DEST_FOLDER/libscalauast.dll
- openssl aes-256-cbc -K $encrypted_97aef7f4ae04_key -iv $encrypted_97aef7f4ae04_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
- ./sbt publishSigned sonatypeRelease

- <<: *release
name: 'Check that project can be cross-compiled correctly'
stage: test
script: ./sbt assembly
- ./build.sh --all
- ./sbt publishLocal publishSigned sonatypeRelease
deploy:
skip_cleanup: true
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,32 @@ The latest `scala-client` *v2.x* supports the [UASTv2 protocol](https://doc.bblf
```
git clone https://github.com/bblfsh/scala-client.git
cd scala-client
./sbt assembly
./build.sh --clean --get-dependencies --all
```

gRPC/protobuf files are re-generate from `src/main/proto` on every `./sbt compile`
and are stored under `./target/src_managed/`.
This command would fetch dependencies for the package, compile native code (JNI) and the Scala code.
gRPC/protobuf files are re-generate from `src/main/proto` on every `./sbt compile` and are stored under
`./target/src_managed/`.

The jar file and the native module are generated in the `build/` directory. If
you move the jar file to some other path, the native (`.so` or `.dylib`)
library must be in the same path.

If the build fails because it can't find the `jni.h` header file, run it with:
If the build fails because it can't find the `jni.h` header file, run it setting `JAVA_HOME` (appropriately
setting it to the right location for your system):

```
./sbt -java-home /usr/lib/jvm/java-8-openjdk-amd64 assembly
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
./build.sh --clean --get-dependencies --all
```

Changing the JDK directory to the one right for your system.
If the build fails with: `build.sh: Permission denied`, add execution permissions to the script:

```
chmod +x ./build.sh
```

`build.sh` script has been tested in Unix (Linux and macOS) and with [Git Bash](https://gitforwindows.org/) in Windows.

For more developer documentation please check our [CONTRIBUTING](./CONTRIBUTING.md) guideline.

Expand Down
Loading