Skip to content
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

run tests on ruby 2.6 #2851

Merged
merged 8 commits into from
Mar 20, 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
10 changes: 5 additions & 5 deletions .kokoro/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ruby --version
# https://github.com/bundler/bundler/issues/6154
export BUNDLE_GEMFILE=

RUBY_VERSIONS=("2.3.8" "2.4.5" "2.5.4")
versions=($RUBY_VERSIONS)

# Capture failures
EXIT_STATUS=0 # everything passed
Expand All @@ -29,16 +29,16 @@ function set_failed_status {
}

if [ "$PACKAGE" = "post" ]; then
rbenv global ${RUBY_VERSIONS[-1]}
rbenv global ${versions[2]}
(bundle update && bundle exec rake kokoro:post) || set_failed_status
elif [ "$JOB_TYPE" = "nightly" ]; then
for version in "${RUBY_VERSIONS[@]}"; do
for version in "${versions[@]}"; do
rbenv global "$version"
(bundle update && bundle exec rake kokoro:nightly) || set_failed_status
done
elif [ "$JOB_TYPE" = "continuous" ]; then
git fetch --depth=10000
for version in "${RUBY_VERSIONS[@]}"; do
for version in "${versions[@]}"; do
rbenv global "$version"
(bundle update && bundle exec rake kokoro:continuous) || set_failed_status
done
Expand All @@ -48,7 +48,7 @@ elif [ "$JOB_TYPE" = "release" ]; then
python3 -m releasetool publish-reporter-script > /tmp/publisher-script; source /tmp/publisher-script
(bundle update && bundle exec rake kokoro:release) || set_failed_status
else
for version in "${RUBY_VERSIONS[@]}"; do
for version in "${versions[@]}"; do
rbenv global "$version"
(bundle update && bundle exec rake kokoro:presubmit) || set_failed_status
done
Expand Down
2 changes: 1 addition & 1 deletion .kokoro/continuous/linux/common.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ build_file: "google-cloud-ruby/.kokoro/trampoline.sh"
# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/google-cloud-ruby/ruby-multi-ubuntu"
value: "gcr.io/cloud-devrel-kokoro-resources/yoshi-ruby/ruby-multi"
}

env_vars: {
Expand Down
8 changes: 5 additions & 3 deletions .kokoro/docker/ruby-multi/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ RUN git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ru

# Install ruby
ENV RUBY_CONFIGURE_OPTS --disable-install-doc
ENV RUBY_VERSIONS "2.3.8 2.4.5 2.5.5 2.6.2"
RUN echo 'gem: --no-rdoc --no-ri' >> /.gemrc
RUN rbenv install 2.3.8 && rbenv global 2.3.8 && gem install bundler --version 1.17.3
RUN rbenv install 2.4.5 && rbenv global 2.4.5 && gem install bundler --version 1.17.3
RUN rbenv install 2.5.4 && rbenv global 2.5.4 && gem install bundler --version 1.17.3
RUN for version in ${RUBY_VERSIONS}; do \
rbenv install "$version" && rbenv global "$version" && \
gem install bundler:1.17.3 && gem update --system \
; done

TheRoyalTnetennba marked this conversation as resolved.
Show resolved Hide resolved
RUN apt-get -y autoremove && apt-get -y autoclean
4 changes: 2 additions & 2 deletions .kokoro/docker/ruby-release/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ RUN apt-get -y autoclean
# Install Ruby
RUN mkdir $HOME/.ruby
RUN git clone https://github.com/rbenv/ruby-build.git $HOME/.ruby-build
RUN $HOME/.ruby-build/bin/ruby-build 2.5.4 $HOME/.ruby
RUN $HOME/.ruby-build/bin/ruby-build 2.5.5 $HOME/.ruby
ENV PATH /root/.ruby/bin:$PATH
ENV RUBY_CONFIGURE_OPTS --disable-install-doc
RUN echo 'gem: --no-rdoc --no-ri' >> /.gemrc
RUN gem install bundler:1.17.3 rake
RUN gem install bundler:1.17.3 && gem update --system

# Install Python
RUN git clone https://github.com/pyenv/pyenv.git ~/.pyenv
Expand Down
2 changes: 1 addition & 1 deletion .kokoro/nightly/linux/common.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ build_file: "google-cloud-ruby/.kokoro/trampoline.sh"
# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/google-cloud-ruby/ruby-multi-ubuntu"
value: "gcr.io/cloud-devrel-kokoro-resources/yoshi-ruby/ruby-multi"
}

env_vars: {
Expand Down
40 changes: 25 additions & 15 deletions .kokoro/osx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,38 @@ env | grep KOKORO

cd github/google-cloud-ruby/

# Print out Ruby version
ruby --version

# Temporary workaround for a known bundler+docker issue:
# https://github.com/bundler/bundler/issues/6154
export BUNDLE_GEMFILE=

# Capture failures
EXIT_STATUS=0 # everything passed
function set_failed_status {
EXIT_STATUS=1
}

gem install bundler --version 1.17.3

if [ "$JOB_TYPE" = "nightly" ]; then
(bundle update && bundle exec rake kokoro:nightly) || set_failed_status
elif [ "$JOB_TYPE" = "continuous" ]; then
git fetch --depth=10000
(bundle update && bundle exec rake kokoro:continuous) || set_failed_status
source ~/.rvm/scripts/rvm
rvm get head --auto-dotfiles

versions=(2.3.8 2.4.5 2.5.5 2.6.2)
rvm_versions=$(rvm list rubies)

if [ "$JOB_TYPE" = "presubmit" ]; then
version=${versions[2]}
if [[ $rvm_versions != *$version* ]]; then
rvm install $version
fi
rvm use $version@global --default
gem update --system
bundle update
bundle exec rake kokoro:presubmit || set_failed_status
else
(bundle update && bundle exec rake kokoro:presubmit) || set_failed_status
for version in "${versions[@]}"; do
if [[ $rvm_versions != *$version* ]]; then
rvm install "$version"
fi
rvm use "$version"@global --default
git fetch --depth=10000
gem update --system
bundle update
bundle exec rake kokoro:"$JOB_TYPE" || set_failed_status
done
fi

exit $EXIT_STATUS
2 changes: 1 addition & 1 deletion .kokoro/presubmit/linux/common.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ env_vars: {
# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/google-cloud-ruby/ruby-multi-ubuntu"
value: "gcr.io/cloud-devrel-kokoro-resources/yoshi-ruby/ruby-multi"
}

env_vars: {
Expand Down
2 changes: 1 addition & 1 deletion .kokoro/release/common.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ build_file: "google-cloud-ruby/.kokoro/trampoline.sh"
# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/google-cloud-ruby/ruby-release"
value: "gcr.io/cloud-devrel-kokoro-resources/yoshi-ruby/ruby-release"
}

env_vars: {
Expand Down
36 changes: 5 additions & 31 deletions .kokoro/templates/osx.sh.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,57 +20,31 @@ function set_failed_status {
EXIT_STATUS=1
}

echo "script started"
echo $PATH
source ~/.rvm/scripts/rvm
echo "rvm sourced"
rvm get head --auto-dotfiles
echo "ran rvm auto-dotfiles"

versions=(<%= ruby_versions.join " " %>)
echo "set versions"
rvm_versions=$(rvm list rubies)

if [ "$JOB_TYPE" = "presubmit" ]; then
version=${versions[<%= ruby_versions.size - 2 %>]}
echo "set version to $version"
echo "recognized presubmit"
if [[ $rvm_versions == *$version* ]]; then
echo "found it, gonna use it"
else
echo "couldn't find it, gonna install it"
if [[ $rvm_versions != *$version* ]]; then
rvm install $version
fi
echo "installed it, gonna use it"
rvm use $version@global --default
echo "using it"
echo $PATH
gem uninstall --force --silent bundler bundle
echo "uninstalled bundler"
gem install bundler --version 1.17.3
echo "installed bundler"
echo $PATH
which bundler
which ruby
gem update --system
echo "updated system"
echo $PATH
which bundler
which ruby
(bundle update && bundle exec rake kokoro:presubmit) || set_failed_status
bundle update
bundle exec rake kokoro:presubmit || set_failed_status
else
for version in "${versions[@]}"; do
if [[ $rvm_versions != *$version* ]]; then
rvm install "$version"
fi
rvm use "$version"@global --default
git fetch --depth=10000
gem install bundler --version 1.17.3
gem update --system
gem regenerate_binstubs
ruby --version
which bundle
(bundle update && bundle exec rake kokoro:"$JOB_TYPE") || set_failed_status
bundle update
bundle exec rake kokoro:"$JOB_TYPE" || set_failed_status
done
fi

Expand Down
39 changes: 39 additions & 0 deletions .kokoro/templates/ruby-multi.Dockerfile.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM ubuntu:latest

ENTRYPOINT /bin/bash

# Set the locale
RUN apt-get update && apt-get install -y --no-install-recommends locales && rm -rf /var/lib/apt/lists/* \
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
ENV LANG en_US.utf8

# Install dependencies
RUN apt-get update && apt-get install -y git curl autoconf bison build-essential libssl1.0-dev \
libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm5 libgdbm-dev
RUN apt-get -y autoclean

# Install rbenv
RUN git clone https://github.com/rbenv/rbenv.git /root/.rbenv
RUN cd /root/.rbenv && src/configure && make -C src

ENV PATH /root/.rbenv/bin:$PATH
ENV PATH /root/.rbenv/shims:$PATH

RUN echo 'eval "$(rbenv init -)"' >> /etc/profile
RUN echo 'eval "$(rbenv init -)"' >> .bashrc

# Install ruby-build
RUN mkdir -p "$(rbenv root)"/plugins
RUN git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build


# Install ruby
ENV RUBY_CONFIGURE_OPTS --disable-install-doc
ENV RUBY_VERSIONS "<%= ruby_versions.join(" ") %>"
RUN echo 'gem: --no-rdoc --no-ri' >> /.gemrc
RUN for version in ${RUBY_VERSIONS}; do \
rbenv install "$version" && rbenv global "$version" && \
gem install bundler:1.17.3 && gem update --system \
; done

RUN apt-get -y autoremove && apt-get -y autoclean
35 changes: 35 additions & 0 deletions .kokoro/templates/ruby-release.Dockerfile.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM ubuntu:latest

ENTRYPOINT /bin/bash

# Set the locale
RUN apt-get update && apt-get install -y --no-install-recommends locales && rm -rf /var/lib/apt/lists/* \
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
ENV LANG en_US.utf8

# Install dependencies
RUN apt-get update && apt-get install -y git curl autoconf bison build-essential libssl1.0-dev \
libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm5 libgdbm-dev \
make libbz2-dev libreadline-dev wget llvm libncursesw5-dev xz-utils liblzma-dev python-openssl \
sqlite3 libsqlite3-dev
RUN apt-get -y autoclean

# Install Ruby
RUN mkdir $HOME/.ruby
RUN git clone https://github.com/rbenv/ruby-build.git $HOME/.ruby-build
RUN $HOME/.ruby-build/bin/ruby-build <%= ruby_versions[-2] %> $HOME/.ruby
ENV PATH /root/.ruby/bin:$PATH
ENV RUBY_CONFIGURE_OPTS --disable-install-doc
RUN echo 'gem: --no-rdoc --no-ri' >> /.gemrc
RUN gem install bundler:1.17.3 && gem update --system

# Install Python
RUN git clone https://github.com/pyenv/pyenv.git ~/.pyenv
ENV PYENV_ROOT /root/.pyenv
ENV PATH /root/.pyenv/bin:$PATH
ENV PATH /root/.pyenv/shims:$PATH
RUN pyenv install 3.6.8
RUN pyenv global 3.6.8
RUN ln -s $(which python) /bin/python3

RUN apt-get -y autoremove && apt-get -y autoclean
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ Please note that the auto-generated portions of the GA libraries (the ones in mo

Contributions to this library are always welcome and highly encouraged.

See [CONTRIBUTING](CONTRIBUTING.md) for more information on how to get started.
See [CONTRIBUTING](.github/CONTRIBUTING.md) for more information on how to get started.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. See [Code of Conduct](CODE_OF_CONDUCT.md) for more information.

Expand Down
35 changes: 34 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ require "erb"
require "fileutils"
require "timeout"

KOKORO_RUBY_VERSIONS = ["2.3.8", "2.4.5", "2.5.5", "2.6.2"]

task :bundleupdate do
valid_gems.each do |gem|
Dir.chdir gem do
Expand Down Expand Up @@ -545,6 +547,8 @@ namespace :kokoro do
desc "Generate configs for kokoro"
task :build do
generate_kokoro_configs
update_kokoro_ruby_versions
update_supported_ruby_versions
end

task :presubmit do
Expand Down Expand Up @@ -647,7 +651,6 @@ namespace :kokoro do
1
end
end

end

def run_command_with_timeout command, timeout
Expand Down Expand Up @@ -693,6 +696,36 @@ def generate_kokoro_configs
end
end

def update_kokoro_ruby_versions
ruby_versions = KOKORO_RUBY_VERSIONS
["ruby-multi", "ruby-release"].each do |docker_image|
File.open("./.kokoro/docker/#{docker_image}/Dockerfile", "w") do |f|
docker_file = ERB.new(File.read("./.kokoro/templates/#{docker_image}.Dockerfile.erb"))
f.write(docker_file.result(binding))
end
end
File.open("./.kokoro/osx.sh", "w") do |f|
docker_file = ERB.new(File.read("./.kokoro/templates/osx.sh.erb"))
f.write(docker_file.result(binding))
end
end

def update_supported_ruby_versions
readme_text = ""
File.open("./README.md", "r+") do |f|
readme_text = f.read
end
earliest_ruby = KOKORO_RUBY_VERSIONS.first.split(".")[0...-1].join(".")
ruby_version_text = "These libraries are currently supported on Ruby "
new_content = readme_text.gsub(
/#{ruby_version_text}(.*)\+/,
"#{ruby_version_text}#{earliest_ruby}+"
)
File.open("./README.md", "w") do |f|
f.write new_content
end
end

def gems
`git ls-files -- */*.gemspec`.split("\n").map { |gem| gem.split("/").first }.sort
end
Expand Down