Skip to content

Commit 6a4659e

Browse files
committed
update ci to docker and gradle wrapper
1 parent 3c2b700 commit 6a4659e

14 files changed

+264
-198
lines changed

.travis.yml

+13-15
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
---
2-
sudo: false
3-
language: ruby
4-
cache: bundler
2+
sudo: required
3+
services: docker
4+
addons:
5+
apt:
6+
packages:
7+
- docker-ce
58
matrix:
69
include:
7-
- rvm: jruby-9.1.13.0
8-
env: LOGSTASH_BRANCH=master
9-
- rvm: jruby-9.1.13.0
10-
env: LOGSTASH_BRANCH=6.x
11-
- rvm: jruby-9.1.13.0
12-
env: LOGSTASH_BRANCH=6.5
13-
- rvm: jruby-1.7.27
14-
env: LOGSTASH_BRANCH=5.6
10+
- env: ELASTIC_STACK_VERSION=5.x
11+
- env: ELASTIC_STACK_VERSION=6.x
12+
- env: ELASTIC_STACK_VERSION=7.x
13+
- env: SNAPSHOT=true ELASTIC_STACK_VERSION=6.x
14+
- env: SNAPSHOT=true ELASTIC_STACK_VERSION=7.x
1515
fast_finish: true
16-
install: true
17-
script: ci/build.sh
18-
jdk: oraclejdk8
19-
before_install: gem install bundler -v '< 2'
16+
install: ci/unit/docker-setup.sh
17+
script: ci/unit/docker-run.sh

Rakefile

+21-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
1-
# encoding: utf-8
2-
require "logstash/devutils/rake"
1+
@files=[]
32

4-
Dir.glob(File.join(File.dirname(__FILE__), "lib", "tasks", "*.rake")) { |f| load f }
3+
task :default do
4+
system("rake -T")
5+
end
6+
7+
require 'logstash/devutils/rake'
8+
require 'jars/installer'
9+
10+
task :install_jars do
11+
system('./gradlew vendor')
12+
end
13+
14+
task :vendor => :install_jars
15+
16+
task :test do
17+
require 'rspec/core/runner'
18+
require 'rspec'
19+
system './gradlew clean test'
20+
Rake::Task[:install_jars].invoke
21+
exit(RSpec::Core::Runner.run(Rake::FileList['spec/**/*_spec.rb']))
22+
end

build.gradle

+1-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ apply plugin: 'idea'
66
apply plugin: 'maven-publish'
77

88
group 'org.logstash.plugins.input.http'
9-
version "${new File("VERSION").text.trim()}"
9+
version rootProject.file('VERSION').text.trim()
1010

1111
description = "HTTP Input Netty implementation"
1212

@@ -85,8 +85,3 @@ publishing {
8585
}
8686
}
8787
}
88-
89-
task wrapper(type: Wrapper) {
90-
description = 'Install Gradle wrapper'
91-
gradleVersion = '2.14'
92-
}

ci/build.sh

-21
This file was deleted.

ci/setup.sh

-26
This file was deleted.

ci/unit/Dockerfile

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
ARG ELASTIC_STACK_VERSION
2+
FROM docker.elastic.co/logstash/logstash:$ELASTIC_STACK_VERSION
3+
COPY --chown=logstash:logstash Gemfile /usr/share/plugins/logstash-input-tcp/Gemfile
4+
COPY --chown=logstash:logstash *.gemspec /usr/share/plugins/logstash-input-tcp/
5+
COPY --chown=logstash:logstash VERSION /usr/share/plugins/logstash-input-tcp/
6+
RUN cp /usr/share/logstash/logstash-core/versions-gem-copy.yml /usr/share/logstash/versions.yml
7+
ENV PATH="${PATH}:/usr/share/logstash/vendor/jruby/bin"
8+
ENV LOGSTASH_SOURCE=1
9+
ENV JARS_SKIP="true"
10+
RUN gem install bundler
11+
WORKDIR /usr/share/plugins/logstash-input-tcp
12+
RUN bundle install
13+
COPY --chown=logstash:logstash src /usr/share/plugins/logstash-input-tcp/src
14+
COPY --chown=logstash:logstash Rakefile /usr/share/plugins/logstash-input-tcp/
15+
COPY --chown=logstash:logstash gradle /usr/share/plugins/logstash-input-tcp/gradle
16+
COPY --chown=logstash:logstash gradlew /usr/share/plugins/logstash-input-tcp/
17+
COPY --chown=logstash:logstash build.gradle /usr/share/plugins/logstash-input-tcp/
18+
COPY --chown=logstash:logstash settings.gradle /usr/share/plugins/logstash-input-tcp/
19+
COPY --chown=logstash:logstash . /usr/share/plugins/logstash-input-tcp
20+
RUN bundle exec rake vendor

ci/unit/docker-compose.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: '3'
2+
3+
# run tests: cd ci/unit; docker-compose up --build --force-recreate
4+
# manual: cd ci/unit; docker-compose run logstash bash
5+
services:
6+
7+
logstash:
8+
build:
9+
context: ../../
10+
dockerfile: ci/unit/Dockerfile
11+
args:
12+
- ELASTIC_STACK_VERSION=$ELASTIC_STACK_VERSION
13+
command: /usr/share/plugins/logstash-input-tcp/ci/unit/run.sh
14+
environment:
15+
LS_JAVA_OPTS: "-Xmx256m -Xms256m"
16+
LOGSTASH_SOURCE: 1
17+
JARS_SKIP: "true"
18+
OSS: "true"
19+
tty: true

ci/unit/docker-run.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
# This is intended to be run inside the docker container as the command of the docker-compose.
4+
set -ex
5+
docker-compose -f ci/unit/docker-compose.yml up --exit-code-from logstash

ci/unit/docker-setup.sh

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
3+
# This is intended to be run the plugin's root directory. `ci/unit/docker-test.sh`
4+
# Ensure you have Docker installed locally and set the ELASTIC_STACK_VERSION environment variable.
5+
set -e
6+
7+
VERSION_URL="https://raw.githubusercontent.com/elastic/logstash/master/ci/logstash_releases.json"
8+
9+
if [ "$ELASTIC_STACK_VERSION" ]; then
10+
echo "Fetching versions from $VERSION_URL"
11+
VERSIONS=$(curl $VERSION_URL)
12+
if [[ "$SNAPSHOT" = "true" ]]; then
13+
ELASTIC_STACK_RETRIEVED_VERSION=$(echo $VERSIONS | jq '.snapshots."'"$ELASTIC_STACK_VERSION"'"')
14+
echo $ELASTIC_STACK_RETRIEVED_VERSION
15+
else
16+
ELASTIC_STACK_RETRIEVED_VERSION=$(echo $VERSIONS | jq '.releases."'"$ELASTIC_STACK_VERSION"'"')
17+
fi
18+
if [[ "$ELASTIC_STACK_RETRIEVED_VERSION" != "null" ]]; then
19+
# remove starting and trailing double quotes
20+
ELASTIC_STACK_RETRIEVED_VERSION="${ELASTIC_STACK_RETRIEVED_VERSION%\"}"
21+
ELASTIC_STACK_RETRIEVED_VERSION="${ELASTIC_STACK_RETRIEVED_VERSION#\"}"
22+
echo "Translated $ELASTIC_STACK_VERSION to ${ELASTIC_STACK_RETRIEVED_VERSION}"
23+
export ELASTIC_STACK_VERSION=$ELASTIC_STACK_RETRIEVED_VERSION
24+
fi
25+
26+
echo "Testing against version: $ELASTIC_STACK_VERSION"
27+
28+
if [[ "$ELASTIC_STACK_VERSION" = *"-SNAPSHOT" ]]; then
29+
cd /tmp
30+
wget https://snapshots.elastic.co/docker/logstash-"$ELASTIC_STACK_VERSION".tar.gz
31+
tar xfvz logstash-"$ELASTIC_STACK_VERSION".tar.gz repositories
32+
echo "Loading docker image: "
33+
cat repositories
34+
docker load < logstash-"$ELASTIC_STACK_VERSION".tar.gz
35+
rm logstash-"$ELASTIC_STACK_VERSION".tar.gz
36+
cd -
37+
fi
38+
39+
if [ -f Gemfile.lock ]; then
40+
rm Gemfile.lock
41+
fi
42+
43+
docker-compose -f ci/unit/docker-compose.yml down
44+
docker-compose -f ci/unit/docker-compose.yml build
45+
#docker-compose -f ci/unit/docker-compose.yml up --exit-code-from logstash --force-recreate
46+
else
47+
echo "Please set the ELASTIC_STACK_VERSION environment variable"
48+
echo "For example: export ELASTIC_STACK_VERSION=6.2.4"
49+
exit 1
50+
fi
51+

ci/unit/run.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
# This is intended to be run inside the docker container as the command of the docker-compose.
4+
set -ex
5+
6+
bundle exec rspec -fd --pattern spec/**/*_spec.rb,spec/**/*_specs.rb

gradle/wrapper/gradle-wrapper.jar

3.39 KB
Binary file not shown.
+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#Mon May 16 11:33:44 EDT 2016
21
distributionBase=GRADLE_USER_HOME
32
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-bin.zip

gradlew

+43-35
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,43 @@
1-
#!/usr/bin/env bash
1+
#!/usr/bin/env sh
22

33
##############################################################################
44
##
55
## Gradle start up script for UN*X
66
##
77
##############################################################################
88

9-
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10-
DEFAULT_JVM_OPTS=""
9+
# Attempt to set APP_HOME
10+
# Resolve links: $0 may be a link
11+
PRG="$0"
12+
# Need this for relative symlinks.
13+
while [ -h "$PRG" ] ; do
14+
ls=`ls -ld "$PRG"`
15+
link=`expr "$ls" : '.*-> \(.*\)$'`
16+
if expr "$link" : '/.*' > /dev/null; then
17+
PRG="$link"
18+
else
19+
PRG=`dirname "$PRG"`"/$link"
20+
fi
21+
done
22+
SAVED="`pwd`"
23+
cd "`dirname \"$PRG\"`/" >/dev/null
24+
APP_HOME="`pwd -P`"
25+
cd "$SAVED" >/dev/null
1126

1227
APP_NAME="Gradle"
1328
APP_BASE_NAME=`basename "$0"`
1429

30+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31+
DEFAULT_JVM_OPTS='"-Xmx64m"'
32+
1533
# Use the maximum available, or set MAX_FD != -1 to use that value.
1634
MAX_FD="maximum"
1735

18-
warn ( ) {
36+
warn () {
1937
echo "$*"
2038
}
2139

22-
die ( ) {
40+
die () {
2341
echo
2442
echo "$*"
2543
echo
@@ -30,6 +48,7 @@ die ( ) {
3048
cygwin=false
3149
msys=false
3250
darwin=false
51+
nonstop=false
3352
case "`uname`" in
3453
CYGWIN* )
3554
cygwin=true
@@ -40,31 +59,11 @@ case "`uname`" in
4059
MINGW* )
4160
msys=true
4261
;;
62+
NONSTOP* )
63+
nonstop=true
64+
;;
4365
esac
4466

45-
# For Cygwin, ensure paths are in UNIX format before anything is touched.
46-
if $cygwin ; then
47-
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48-
fi
49-
50-
# Attempt to set APP_HOME
51-
# Resolve links: $0 may be a link
52-
PRG="$0"
53-
# Need this for relative symlinks.
54-
while [ -h "$PRG" ] ; do
55-
ls=`ls -ld "$PRG"`
56-
link=`expr "$ls" : '.*-> \(.*\)$'`
57-
if expr "$link" : '/.*' > /dev/null; then
58-
PRG="$link"
59-
else
60-
PRG=`dirname "$PRG"`"/$link"
61-
fi
62-
done
63-
SAVED="`pwd`"
64-
cd "`dirname \"$PRG\"`/" >&-
65-
APP_HOME="`pwd -P`"
66-
cd "$SAVED" >&-
67-
6867
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
6968

7069
# Determine the Java command to use to start the JVM.
@@ -90,7 +89,7 @@ location of your Java installation."
9089
fi
9190

9291
# Increase the maximum file descriptors if we can.
93-
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
92+
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
9493
MAX_FD_LIMIT=`ulimit -H -n`
9594
if [ $? -eq 0 ] ; then
9695
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
@@ -114,6 +113,7 @@ fi
114113
if $cygwin ; then
115114
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116115
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116+
JAVACMD=`cygpath --unix "$JAVACMD"`
117117

118118
# We build the pattern for arguments to be converted via cygpath
119119
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
@@ -154,11 +154,19 @@ if $cygwin ; then
154154
esac
155155
fi
156156

157-
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158-
function splitJvmOpts() {
159-
JVM_OPTS=("$@")
157+
# Escape application args
158+
save () {
159+
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160+
echo " "
160161
}
161-
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162-
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
162+
APP_ARGS=$(save "$@")
163+
164+
# Collect all arguments for the java command, following the shell quoting and substitution rules
165+
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166+
167+
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168+
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169+
cd "$(dirname "$0")"
170+
fi
163171

164-
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
172+
exec "$JAVACMD" "$@"

0 commit comments

Comments
 (0)