Skip to content

Commit

Permalink
Test using rbenv for foreman-installer tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ehelms committed Apr 11, 2024
1 parent 00fc3c2 commit 86236ff
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 18 deletions.
32 changes: 32 additions & 0 deletions theforeman.org/pipelines/lib/rbenv.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
def bundleInstall(version, gemfile=null) {
command = "bundle install"

if (gemfile) {
command = "${command} --gemfile=${gemfile}"
}

withRuby(version, "bundle config set path ~/.rubygems")
withRuby(version, command)
}

def bundleExec(version, command, gemfile=null) {
command = "bundle exec ${command}"

if (gemfile) {
command = "BUNDLE_GEMFILE=${gemfile} bundle exec ${command}"
}

withRuby(version, command)
}

def withRuby(version, command) {
echo command.toString()

sh """
set -x
eval "\$(rbenv init - bash)"
rbenv shell ${version}
${command}
"""
}
30 changes: 12 additions & 18 deletions theforeman.org/pipelines/test/foreman-installer.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pipeline {
axes {
axis {
name 'ruby'
values '2.7'
values '2.7.6'
}
axis {
name 'PUPPET_VERSION'
Expand All @@ -23,7 +23,7 @@ pipeline {
exclude {
axis {
name 'ruby'
notValues '2.7'
notValues '2.7.6'
}
axis {
name 'PUPPET_VERSION'
Expand All @@ -38,41 +38,35 @@ pipeline {
sh "cp Gemfile Gemfile.${ruby}-${PUPPET_VERSION}"
}
}
stage("Setup RVM") {
stage("bundle-install") {
steps {
configureRVM(ruby, "${ruby}-${PUPPET_VERSION}")
}
}
stage('Install dependencies') {
steps {
withRVM(["bundle install --gemfile=Gemfile.${ruby}-${PUPPET_VERSION}"], ruby, "${ruby}-${PUPPET_VERSION}")
bundleInstall(ruby, "Gemfile.${ruby}-${PUPPET_VERSION}")
}
}
stage('Run Rubocop') {
steps {
withRVM(["BUNDLE_GEMFILE=Gemfile.${ruby}-${PUPPET_VERSION} bundle exec rake rubocop TESTOPTS='-v' --trace"], ruby, "${ruby}-${PUPPET_VERSION}")
bundleExec(ruby, "rake rubocop TESTOPTS='-v' --trace", "Gemfile.${ruby}-${PUPPET_VERSION}")
}
}
stage('Run Tests') {
steps {
withRVM(["BUNDLE_GEMFILE=Gemfile.${ruby}-${PUPPET_VERSION} bundle exec rake spec TESTOPTS='-v' --trace"], ruby, "${ruby}-${PUPPET_VERSION}")
bundleExec(ruby, "rake spec TESTOPTS='-v' --trace", "Gemfile.${ruby}-${PUPPET_VERSION}")
}
}
stage('Test installer configuration') {
steps {
withRVM(["BUNDLE_GEMFILE=Gemfile.${ruby}-${PUPPET_VERSION} bundle exec rake install PREFIX=${ruby}-${PUPPET_VERSION} --trace"], ruby, "${ruby}-${PUPPET_VERSION}")
withRVM(["BUNDLE_GEMFILE=Gemfile.${ruby}-${PUPPET_VERSION} bundle exec ${ruby}-${PUPPET_VERSION}/sbin/foreman-installer --help --scenario foreman --trace"], ruby, "${ruby}-${PUPPET_VERSION}")
withRVM(["BUNDLE_GEMFILE=Gemfile.${ruby}-${PUPPET_VERSION} bundle exec ${ruby}-${PUPPET_VERSION}/sbin/foreman-installer --help --scenario foreman-proxy-content --trace"], ruby, "${ruby}-${PUPPET_VERSION}")
withRVM(["BUNDLE_GEMFILE=Gemfile.${ruby}-${PUPPET_VERSION} bundle exec ${ruby}-${PUPPET_VERSION}/sbin/foreman-installer --help --scenario katello --trace"], ruby, "${ruby}-${PUPPET_VERSION}")
withRVM(["BUNDLE_GEMFILE=Gemfile.${ruby}-${PUPPET_VERSION} bundle exec ${ruby}-${PUPPET_VERSION}/sbin/foreman-proxy-certs-generate --help --trace"], ruby, "${ruby}-${PUPPET_VERSION}")
withRVM(["BUNDLE_GEMFILE=Gemfile.${ruby}-${PUPPET_VERSION} bundle exec ${ruby}-${PUPPET_VERSION}/sbin/foreman-proxy-certs-generate --help|grep -q certs-update-server"], ruby, "${ruby}-${PUPPET_VERSION}")
bundleExec(ruby, "rake install PREFIX=${ruby}-${PUPPET_VERSION} --trace", "Gemfile.${ruby}-${PUPPET_VERSION}")
bundleExec(ruby, "${ruby}-${PUPPET_VERSION}/sbin/foreman-installer --help --scenario foreman --trace", "Gemfile.${ruby}-${PUPPET_VERSION}")
bundleExec(ruby, "${ruby}-${PUPPET_VERSION}/sbin/foreman-installer --help --scenario katello --trace", "Gemfile.${ruby}-${PUPPET_VERSION}")
bundleExec(ruby, "${ruby}-${PUPPET_VERSION}/sbin/foreman-installer --help --scenario foreman-proxy-content --trace", "Gemfile.${ruby}-${PUPPET_VERSION}")
bundleExec(ruby, "${ruby}-${PUPPET_VERSION}/sbin/foreman-proxy-certs-generate --help --trace", "Gemfile.${ruby}-${PUPPET_VERSION}")
bundleExec(ruby, "${ruby}-${PUPPET_VERSION}/sbin/foreman-proxy-certs-generate --help|grep -q certs-update-server", "Gemfile.${ruby}-${PUPPET_VERSION}")
}
}
}
post {
always {
archiveArtifacts artifacts: "Gemfile*lock"
cleanupRVM(ruby, "${ruby}-${PUPPET_VERSION}")
deleteDir()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
!include-raw:
- pipelines/lib/git.groovy
- pipelines/lib/rvm.groovy
- pipelines/lib/rbenv.groovy
- pipelines/test/foreman-installer.groovy

0 comments on commit 86236ff

Please sign in to comment.