-
Notifications
You must be signed in to change notification settings - Fork 7
[CI] Enable multibranch pipeline #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
37b8092
c3779ff
fe75ce0
5b30cb3
6484ac8
6a989f6
fbb406e
53cdc3c
df94cc9
75e0a74
3ec4ac2
262b7ed
ac8bea0
b1c6a83
56ec9f9
0d34bb0
c40849f
56f275e
48dd355
fd09797
1593726
2af9098
b3e3dba
dfda5c9
4a0b1a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| #!/usr/bin/env groovy | ||
| @Library('apm@current') _ | ||
|
|
||
| pipeline { | ||
| agent { label 'linux && immutable' } | ||
| environment { | ||
| REPO = 'ecs-logging-ruby' | ||
| BASE_DIR = "src/github.com/elastic/${env.REPO}" | ||
| DOCKER_REGISTRY = 'docker.elastic.co' | ||
| DOCKER_SECRET = 'secret/apm-team/ci/docker-registry/prod' | ||
| PIPELINE_LOG_LEVEL = 'INFO' | ||
| NOTIFY_TO = credentials('notify-to') | ||
| JOB_GCS_BUCKET = credentials('gcs-bucket') | ||
| VERSION = '2.7.2' | ||
| HOME = "${WORKSPACE}" | ||
| PATH = "${WORKSPACE}/.rbenv/bin:${WORKSPACE}/.rbenv/versions/${VERSION}/bin:${PATH}" | ||
| } | ||
| options { | ||
| timeout(time: 2, unit: 'HOURS') | ||
| buildDiscarder(logRotator(numToKeepStr: '20', artifactNumToKeepStr: '20', daysToKeepStr: '30')) | ||
| timestamps() | ||
| ansiColor('xterm') | ||
| disableResume() | ||
| durabilityHint('PERFORMANCE_OPTIMIZED') | ||
| rateLimitBuilds(throttle: [count: 60, durationName: 'hour', userBoost: true]) | ||
| quietPeriod(10) | ||
| } | ||
| triggers { | ||
| issueCommentTrigger('(?i).*(?:jenkins\\W+)?run\\W+(?:the\\W+)?tests(?:\\W+please)?.*') | ||
| } | ||
| stages { | ||
| stage('Checkout') { | ||
| options { skipDefaultCheckout() } | ||
| steps { | ||
| pipelineManager([ cancelPreviousRunningBuilds: [ when: 'PR' ] ]) | ||
| deleteDir() | ||
| gitCheckout(basedir: "${BASE_DIR}", githubNotifyFirstTimeContributor: true) | ||
| stash allowEmpty: true, name: 'source', useDefaultExcludes: false | ||
| } | ||
| } | ||
| stage('Tests') { | ||
| failFast false | ||
| matrix { | ||
| agent { label 'linux && docker && ubuntu-18.04 && immutable' } | ||
| options { skipDefaultCheckout() } | ||
| axes { | ||
| axis { | ||
| name 'RUBY_VERSION' | ||
| values 'ruby:2.7', 'ruby:2.6', 'ruby:2.5', 'ruby:2.4', 'ruby:2.3', 'jruby:9.2', 'jruby:9.1' | ||
| } | ||
| axis { | ||
| name 'FRAMEWORK' | ||
| values 'rails-6.0', 'rails-5.2', 'rails-5.1', 'sinatra-2.0' | ||
| } | ||
| } | ||
| stages { | ||
| stage('Tests') { | ||
| steps { | ||
| withGithubNotify(context: "Tests-${RUBY_VERSION}-${FRAMEWORK}") { | ||
| deleteDir() | ||
| unstash 'source' | ||
| dir("${BASE_DIR}"){ | ||
| dockerLogin(secret: "${DOCKER_SECRET}", registry: "${DOCKER_REGISTRY}") | ||
| sh(label: 'install rbenv', script: '.ci/install-rbenv.sh "${VERSION}"') | ||
| sh("bin/dev -i${RUBY_VERSION} -f${FRAMEWORK}") | ||
| } | ||
| } | ||
| } | ||
| post { | ||
| always { | ||
| junit(allowEmptyResults: true, keepLongStdio: true, testResults: "${BASE_DIR}/spec/junit-reports/**/*-junit.xml") | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| post { | ||
| cleanup { | ||
| notifyBuildResult() | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| #!/usr/bin/env bash | ||
| VERSION=${1:-"2.7.2"} | ||
| export PATH="$HOME/.rbenv/bin:$PATH" | ||
| git clone https://github.com/rbenv/rbenv.git ~/.rbenv | ||
| git clone git@github.com:rbenv/ruby-build.git ~/.rbenv/plugins/ruby-buildCloning | ||
| eval "$(rbenv init -)" | ||
| rbenv install "${VERSION}" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,3 +10,6 @@ | |
| # rspec failure tracking | ||
| .rspec_status | ||
| /vendor | ||
|
|
||
| # junit reports folder | ||
| spec/junit-reports | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,10 +22,11 @@ ENV BUNDLE_APP_CONFIG=$BUNDLE_PATH \ | |
| ENV PATH=/app/bin:$BUNDLE_BIN:$PATH | ||
|
|
||
| ENV FRAMEWORKS $FRAMEWORKS | ||
| ENV RUBY_IMAGE $RUBY_IMAGE | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will help to generate junit files with the ruby_image value in their names |
||
|
|
||
| RUN mkdir -p $VENDOR_PATH \ | ||
| && chown -R $USER_ID_GROUP $VENDOR_PATH | ||
|
|
||
| # Copy cached folder to speed up docker containers | ||
| COPY vendor /vendor | ||
| RUN chown -R $USER_ID_GROUP /vendor | ||
|
Comment on lines
+27
to
+29
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is required to use the cached artifacts if required, otherwise the docker build uses the When building a docker image there is now way to mount volumes but using the |
||
| USER $USER_ID_GROUP | ||
|
|
||
| # Upgrade RubyGems and install required Bundler version | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ gemspec | |
|
|
||
| gem "rake" | ||
| gem "rspec" | ||
| gem 'yarjuf' | ||
|
|
||
| gem "rack-test", require: nil | ||
| gem "sinatra", require: nil | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,35 @@ | ||
| #!/bin/bash | ||
| set -x | ||
|
|
||
| runRspec(){ | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Delegate the how to the function then junit reporting are generated with a different name |
||
| local case=${1:-""} | ||
| local bn=${case} | ||
|
|
||
| if [ -n "${case}" ]; then | ||
| bn="$(basename "${case}")/" | ||
| fi | ||
| if [ -n "${RUBY_VERSION}" ]; then | ||
| bn="$RUBY_VERSION-$bn" | ||
| fi | ||
| if [ -n "${FRAMEWORKS}" ]; then | ||
| bn="$FRAMEWORKS-$bn" | ||
| fi | ||
| bundle exec rspec \ | ||
| -f progress \ | ||
| -r yarjuf -f JUnit -o "spec/junit-reports/${bn}ruby-agent-junit.xml" ${case} | ||
| } | ||
|
|
||
| bundle check || (rm Gemfile.lock && bundle) | ||
|
|
||
| # If first arg is a spec path, run spec(s) | ||
| if [[ $1 == spec/* ]]; then | ||
| bundle exec rspec $@ | ||
| runRspec $@ | ||
| exit $? | ||
| fi | ||
|
|
||
| # If no arguments, run all specs | ||
| if [[ $# == 0 ]]; then | ||
| bundle exec rspec | ||
| runRspec | ||
| exit $? | ||
| fi | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
List of supported ruby versions to be tested: