Skip to content

Commit

Permalink
Convert jobs to rbenv
Browse files Browse the repository at this point in the history
  • Loading branch information
ehelms committed Apr 22, 2024
1 parent 2c160b8 commit 81ff2fb
Show file tree
Hide file tree
Showing 45 changed files with 83 additions and 226 deletions.
11 changes: 3 additions & 8 deletions theforeman.org/pipelines/deploy/website.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pipeline {
}

environment {
ruby_version = '2.7'
ruby = '2.7.6'
// Sync to the pivot-point on the web node
target_path = '[email protected]:rsync_cache/'
rsync_log = 'deploy-website.log'
Expand All @@ -21,13 +21,8 @@ pipeline {
git url: 'https://github.com/theforeman/theforeman.org', branch: 'gh-pages'

script {
try {
configureRVM(ruby_version)
withRVM(['bundle install --jobs=5 --retry=5'], ruby_version)
withRVM(['bundle exec jekyll build'], ruby_version)
} finally {
cleanupRVM(ruby_version)
}
bundleInstall(ruby)
bundleExec(ruby, "jekyll build")
}

sshagent(['deploy-website']) {
Expand Down
32 changes: 12 additions & 20 deletions theforeman.org/pipelines/lib/foreman.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,19 @@ def addSettings(settings) {
sh "cp config/settings.yaml.example config/settings.yaml"
}

def configureDatabase(ruby, name = '') {
withRVM(['bundle install --without=development --jobs=5 --retry=5'], ruby, name)
def configureDatabase(ruby) {
bundleInstall(ruby, '--without=development')
archiveArtifacts(artifacts: 'Gemfile.lock')
withRVM(['bundle exec rake db:drop >/dev/null 2>/dev/null || true'], ruby, name)
withRVM(['bundle exec rake db:create --trace'], ruby, name)
withRVM(['RAILS_ENV=production bundle exec rake db:create --trace'], ruby, name)
withRVM(['bundle exec rake db:migrate --trace'], ruby, name)
bundleExec(ruby, 'rake db:drop >/dev/null 2>/dev/null || true')
bundleExec(ruby, 'rake db:create --trace')
bundleExec(ruby, 'rake db:create --trace RAILS_ENV=production')
bundleExec(ruby, 'rake db:migrate --trace')
}

def cleanup(ruby, name = '') {
try {

withRVM(['bundle exec rake db:drop RAILS_ENV=production DISABLE_DATABASE_ENVIRONMENT_CHECK=true >/dev/null 2>/dev/null || true'], ruby, name)
withRVM(['bundle exec rake db:drop RAILS_ENV=test DISABLE_DATABASE_ENVIRONMENT_CHECK=true >/dev/null 2>/dev/null || true'], ruby, name)
withRVM(['bundle exec rake db:drop RAILS_ENV=development DISABLE_DATABASE_ENVIRONMENT_CHECK=true >/dev/null 2>/dev/null || true'], ruby, name)

} finally {

cleanupRVM(ruby, name)

}
def cleanup(ruby) {
bundleExec(ruby, 'rake db:drop RAILS_ENV=production DISABLE_DATABASE_ENVIRONMENT_CHECK=true >/dev/null 2>/dev/null || true')
bundleExec(ruby, 'rake db:drop RAILS_ENV=test DISABLE_DATABASE_ENVIRONMENT_CHECK=true >/dev/null 2>/dev/null || true')
bundleExec(ruby, 'rake db:drop RAILS_ENV=development DISABLE_DATABASE_ENVIRONMENT_CHECK=true >/dev/null 2>/dev/null || true')
}

def postgresqlTemplate(id) {
Expand Down Expand Up @@ -68,7 +60,7 @@ production:
"""
}

def filter_package_json(ruby, gemset = '') {
def filter_package_json(ruby) {
if (env.NODE_LABELS.contains('el8')) {
python = 'python3.11'
} else {
Expand All @@ -77,7 +69,7 @@ def filter_package_json(ruby, gemset = '') {

sh "${python} script/filter-package-json.py"

withRVM(["bundle exec ruby script/plugin_webpack_directories.rb > plugin_webpack.json"], ruby, gemset)
bundleExec(ruby, "ruby script/plugin_webpack_directories.rb > plugin_webpack.json")
def plugin_webpack = readJSON file: 'plugin_webpack.json'
plugin_webpack['plugins'].each { plugin, config ->
sh "${python} script/filter-package-json.py --package-json ${config['root']}/package.json"
Expand Down
19 changes: 7 additions & 12 deletions theforeman.org/pipelines/lib/nightly_packaging.groovy
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
def generate_sourcefiles(args) {
def sourcefile_paths = []
def project_name = args.project_name
def ruby_version = args.ruby_version ?: '2.7'
def ruby_version = args.ruby_version ?: '2.7.6'
def source_type = args.source_type

dir(project_name) {

echo source_type
if (source_type == 'gem') {
withRVM(["gem build *.gemspec"], ruby_version)
withRuby(ruby_version, "gem build *.gemspec")
sourcefiles = list_files('./').findAll { "${it}".endsWith('.gem') }
archiveArtifacts(artifacts: sourcefiles.join(','))
sourcefile_paths = sourcefiles.collect { "${pwd()}/${it}" }
} else {
try {
configureRVM(ruby_version)
withRVM(["bundle install --jobs 5 --retry 5"], ruby_version)
withRVM(["bundle exec rake pkg:generate_source"], ruby_version)
archiveArtifacts(artifacts: 'pkg/*')
sourcefile_paths = list_files('pkg/').collect {
"${pwd()}/pkg/${it}"
}
} finally {
cleanupRVM(ruby_version)
bundleInstall(ruby_version)
bundleExec(ruby_version, "rake pkg:generate_source")
archiveArtifacts(artifacts: 'pkg/*')
sourcefile_paths = list_files('pkg/').collect {
"${pwd()}/pkg/${it}"
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions theforeman.org/pipelines/lib/rbenv.groovy
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
def bundleInstall(version, gemfile=null) {
command = "bundle install"
def bundleInstall(version, options=null) {
command = "bundle install --jobs 5 --retry 5"

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

withRuby(version, "bundle config set path ~/.rubygems")
Expand Down
48 changes: 0 additions & 48 deletions theforeman.org/pipelines/lib/rvm.groovy

This file was deleted.

14 changes: 4 additions & 10 deletions theforeman.org/pipelines/release/source/foreman-installer.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pipeline {
}
stage("test ruby 2.7 & puppet 7") {
steps {
run_test(ruby: '2.7', puppet: '7')
run_test(ruby: '2.7.6', puppet: '7')
}
}
stage('Build and Archive Source') {
Expand Down Expand Up @@ -55,14 +55,8 @@ pipeline {
def run_test(args) {
def ruby = args.ruby
def puppet = args.puppet
def gemset = "ruby-${ruby}-puppet-${puppet}"

try {
configureRVM(ruby, gemset)
withRVM(["PUPPET_VERSION='${puppet}' bundle install --without=development --jobs=5 --retry=5"], ruby, gemset)
archiveArtifacts(artifacts: 'Gemfile.lock')
withRVM(["PUPPET_VERSION='${puppet}' bundle exec rake spec"], ruby, gemset)
} finally {
cleanupRVM(ruby, gemset)
}
withRuby(ruby, "PUPPET_VERSION='${puppet}' bundle install --without=development --jobs=5 --retry=5")
archiveArtifacts(artifacts: 'Gemfile.lock')
withRuby(ruby, "PUPPET_VERSION='${puppet}' bundle exec rake spec")
}
40 changes: 17 additions & 23 deletions theforeman.org/pipelines/release/source/foreman.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ pipeline {
stage('ruby-2.7-postgres') {
agent { label 'fast' }
environment {
RUBY_VER = '2.7'
GEMSET = 'ruby2.7'
RUBY_VER = '2.7.6'
}
stages {
stage("setup-2.7-postgres") {
Expand All @@ -24,14 +23,13 @@ pipeline {
script {
archive_git_hash()
}
configureRVM(env.RUBY_VER, env.GEMSET)
databaseFile(gemset(env.GEMSET))
configureDatabase(env.RUBY_VER, env.GEMSET)
databaseFile("${env.JOB_NAME}-${env.BUILD_ID}")
configureDatabase(env.RUBY_VER)
}
}
stage("unit-tests-2.7-postgres") {
steps {
withRVM(['bundle exec rake jenkins:unit TESTOPTS="-v" --trace'], env.RUBY_VER, env.GEMSET)
bundleExec(env.RUBY_VER, 'rake jenkins:unit TESTOPTS="-v" --trace')
}
}
}
Expand All @@ -40,31 +38,29 @@ pipeline {
junit(testResults: 'jenkins/reports/unit/*.xml')
}
cleanup {
cleanup(env.RUBY_VER, env.GEMSET)
cleanup(env.RUBY_VER)
deleteDir()
}
}
}
stage('ruby-2.7-postgres-integrations') {
agent { label 'fast' }
environment {
RUBY_VER = '2.7'
GEMSET = 'ruby2.7-ui'
RUBY_VER = '2.7.6'
}
stages {
stage("setup-2.7-postgres-ui") {
steps {
git url: git_url, branch: git_ref
configureRVM(env.RUBY_VER, env.GEMSET)
databaseFile(gemset(env.GEMSET))
configureDatabase(env.RUBY_VER, env.GEMSET)
withRVM(['npm install --no-audit'], env.RUBY_VER, env.GEMSET)
databaseFile("${env.JOB_NAME}-${env.BUILD_ID}-ui")
configureDatabase(env.RUBY_VER)
withRuby(env.RUBY_VER, 'npm install --no-audit')
archiveArtifacts(artifacts: 'package-lock.json')
}
}
stage("integration-tests-2.7-postgres-ui") {
steps {
withRVM(['bundle exec rake jenkins:integration TESTOPTS="-v" --trace'], env.RUBY_VER, env.GEMSET)
bundleExec(env.RUBY_VER, 'rake jenkins:integration TESTOPTS="-v" --trace')
}
}
}
Expand All @@ -73,37 +69,35 @@ pipeline {
junit(testResults: 'jenkins/reports/unit/*.xml')
}
cleanup {
cleanup(env.RUBY_VER, env.GEMSET)
cleanup(env.RUBY_VER)
deleteDir()
}
}
}
stage('ruby-2.7-nulldb-assets') {
agent { label 'fast' }
environment {
RUBY_VER = '2.7'
GEMSET = 'ruby2.7-assets'
RUBY_VER = '2.7.6'
}
stages {
stage("setup-2.7-nulldb") {
steps {
git url: git_url, branch: git_ref
configureRVM(env.RUBY_VER, env.GEMSET)
withRVM(['bundle install --without=development --jobs=5 --retry=5'], env.RUBY_VER, env.GEMSET)
bundleInstall(env.RUBY_VER, '--without=development')
sh "cp db/schema.rb.nulldb db/schema.rb"
filter_package_json(env.RUBY_VER, env.GEMSET)
withRVM(['npm install --no-audit'], env.RUBY_VER, env.GEMSET)
filter_package_json(env.RUBY_VER)
withRuby(env.RUBY_VER, 'npm install --no-audit')
}
}
stage("assets-precompile-2.7-nulldb") {
steps {
withRVM(['bundle exec rake assets:precompile RAILS_ENV=production DATABASE_URL=nulldb://nohost'], env.RUBY_VER, env.GEMSET)
bundleExec(env.RUBY_VER, 'rake assets:precompile RAILS_ENV=production DATABASE_URL=nulldb://nohost')
}
}
}
post {
cleanup {
cleanup(env.RUBY_VER, env.GEMSET)
cleanup(env.RUBY_VER)
deleteDir()
}
}
Expand Down
11 changes: 4 additions & 7 deletions theforeman.org/pipelines/release/source/hammer-cli-x.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pipeline {
}
stage("test-ruby-2.7") {
steps {
run_test(ruby: '2.7')
run_test(ruby: '2.7.6')
}
}
stage('Build and Archive Source') {
Expand Down Expand Up @@ -63,16 +63,13 @@ def add_hammer_cli_git_repos(repos = []) {

def run_test(args) {
def ruby = args.ruby
def gemset = "ruby-${ruby}"

try {
configureRVM(ruby, gemset)
withRVM(['bundle install --without=development --jobs=5 --retry=5'], ruby, gemset)
bundleInstall(ruby, '--without=development')
archiveArtifacts(artifacts: 'Gemfile.lock')
withRVM(['bundle show'], ruby, gemset)
withRVM(['bundle exec rake ci:setup:minitest test TESTOPTS="-v"'], ruby, gemset)
withRuby(ruby, 'bundle show')
bundleExec(ruby, 'rake ci:setup:minitest test TESTOPTS="-v"')
} finally {
cleanupRVM(ruby, gemset)
junit(testResults: 'test/reports/*.xml')
}
}
Loading

0 comments on commit 81ff2fb

Please sign in to comment.