Skip to content

Commit

Permalink
enable jenkins ci.
Browse files Browse the repository at this point in the history
  • Loading branch information
andyliuliming authored and bingosummer committed Jul 19, 2018
1 parent 709b615 commit 131cb6e
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 9 deletions.
16 changes: 16 additions & 0 deletions Jenkinsfile
@@ -0,0 +1,16 @@
pipeline {
agent { docker { image 'ruby:2.4.4' } }
stages {
stage('rubocop') {
steps {
sh 'gem install rubocop'
sh 'src/bosh_azure_cpi/bin/rubocop_check'
}
}
stage('unit-test') {
steps {
sh 'src/bosh_azure_cpi/bin/test-unit -sb'
}
}
}
}
10 changes: 8 additions & 2 deletions src/bosh_azure_cpi/bin/rubocop_check
Expand Up @@ -2,9 +2,15 @@
which rubocop > /dev/null 2>&1
[[ "$?" -eq "1" ]] && {
echo "You need to install rubocop using 'gem install rubocop'"
exit
exit 1
}
export XDG_CACHE_HOME=$(pwd)
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
pushd $DIR/..
rubocop -P
rubocop -P
if [ "$?" != "0" ]; then
echo "rubocop find some issues."
popd
exit 1
fi
popd
41 changes: 34 additions & 7 deletions src/bosh_azure_cpi/bin/test-unit
@@ -1,17 +1,44 @@
#!/usr/bin/env bash
skip_ruby_check=1
specs=spec/unit/*

args=$@
[[ "$#" != "1" ]] && args=spec/unit/*

pushd $SRC_DIR
. bin/check-ruby-version
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-s|--spec)
specs="$2"
shift # past argument
shift # past value
;;
-sb|--skip-ruby-check)
echo "will skip the ruby check."
skip_ruby_check=0
shift
;;
*) # unknown option
echo "Usage: ./test-unit [[-s|--spec] spec/unit/*] [-sb|--skip-ruby-check]"
break
;;
esac
done
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
pushd $DIR/..
if [[ "$skip_ruby_check" -ne "0" ]]; then
. ./bin/check-ruby-version
fi

echo "Running unit tests with Ruby version $RUBY_VERSION..."
bundle install

# AZURE_STORAGE_ACCOUNT and AZURE_STORAGE_ACCESS_KEY are specified fake values as a workaround
# to make sure Azure::Storage::Client is mocked successfully in unit tests.
# After https://github.com/Azure/azure-storage-ruby/issues/87 is resolved, they can be removed.
# echo "bar" | base64 => YmFyCg==
AZURE_STORAGE_ACCOUNT="foo" AZURE_STORAGE_ACCESS_KEY="YmFyCg==" bundle exec rspec ${args} --format documentation
AZURE_STORAGE_ACCOUNT="foo" AZURE_STORAGE_ACCESS_KEY="YmFyCg==" bundle exec rspec ${specs} --format documentation
if [ $? -ne 0 ]; then
echo "rspec find some issues."
popd
exit 1
fi
popd

0 comments on commit 131cb6e

Please sign in to comment.