diff --git a/theforeman.org/pipelines/test/foreman_plugin.groovy b/theforeman.org/pipelines/test/foreman_plugin.groovy new file mode 100644 index 00000000..9794828f --- /dev/null +++ b/theforeman.org/pipelines/test/foreman_plugin.groovy @@ -0,0 +1,126 @@ +pipeline { + options { + timestamps() + timeout(time: 2, unit: 'HOURS') + ansiColor('xterm') + } + + agent none + + stages { + stage('Test') { + matrix { + agent { label 'fast' } + axes { + axis { + name 'ruby' + values '2.5', '2.6', '2.7' + } + } + stages { + stage('Configure Environment') { + steps { + configureRVM(ruby) + deleteDir() + checkout scm: [ + $class: 'GitSCM', + branches: [[name: params.plugin_branch]], + userRemoteConfigs: [[url: params.plugin_repo]], + extensions: [[$class: 'CloneOption', shallow: true, noTags: true]] + ], + poll: false + + dir('foreman') { + checkout scm: [ + $class: 'GitSCM', + branches: [[name: params.foreman_branch]], + userRemoteConfigs: [[url: params.foreman_repo]], + extensions: [[$class: 'CloneOption', shallow: true, noTags: true]] + ], + poll: false + + addGem() + databaseFile(gemset()) + configureDatabase(ruby) + } + } + } + stage('Unit Tests') { + steps { + dir('foreman') { + withRVM(['bundle exec rake jenkins:unit TESTOPTS="-v" --trace'], ruby) + } + } + } + stage('Acceptance Tests') { + when { + allOf { + equals expected: '2.7', actual: ruby + expression { fileExists('test/integration') } + } + } + steps { + dir('foreman') { + withRVM( + [ + 'bundle exec npm install', + 'bundle exec rake webpack:compile jenkins:integration TESTOPTS="-v" --trace' + ], + ruby + ) + } + } + } + stage('Javascript') { + when { + allOf { + equals expected: '2.7', actual: ruby + expression { fileExists('package.json') } + } + } + steps { + sh "npm install" + sh 'npm test' + } + } + stage('assets-precompile') { + steps { + dir('foreman') { + withRVM(["bundle exec rake plugin:assets:precompile[${params.plugin_name}] RAILS_ENV=production --trace"], ruby) + } + } + } + stage('Test db:seed') { + environment { + RAILS_ENV = 'test' + } + steps { + dir('foreman') { + withRVM( + [ + 'bundle exec rake db:drop || true', + 'bundle exec rake db:create', + 'bundle exec rake db:migrate', + 'bundle exec rake db:seed' + ], + ruby + ) + } + } + } + } + post { + always { + dir('foreman') { + archiveArtifacts artifacts: "log/test.log" + junit keepLongStdio: true, testResults: 'jenkins/reports/unit/*.xml' + cleanup(ruby) + } + deleteDir() + // ircNotify TODO + } + } + } + } + } +} diff --git a/theforeman.org/yaml/jobs/plugins/foreman-tasks.yaml b/theforeman.org/yaml/jobs/plugins/foreman-tasks.yaml deleted file mode 100644 index a23b7d5a..00000000 --- a/theforeman.org/yaml/jobs/plugins/foreman-tasks.yaml +++ /dev/null @@ -1,8 +0,0 @@ -- project: - name: foreman-tasks - defaults: plugin - branch: - - master: - foreman_branch: develop - jobs: - - 'test_plugin_{name}_{branch}' diff --git a/theforeman.org/yaml/jobs/plugins/foreman_ansible.yaml b/theforeman.org/yaml/jobs/plugins/foreman_ansible.yaml deleted file mode 100644 index 7c134649..00000000 --- a/theforeman.org/yaml/jobs/plugins/foreman_ansible.yaml +++ /dev/null @@ -1,6 +0,0 @@ -- project: - name: foreman_ansible - repo: foreman_ansible - defaults: plugin - jobs: - - 'test_plugin_{name}_{branch}' diff --git a/theforeman.org/yaml/jobs/plugins/foreman_bootdisk.yaml b/theforeman.org/yaml/jobs/plugins/foreman_bootdisk.yaml deleted file mode 100644 index 47c8783e..00000000 --- a/theforeman.org/yaml/jobs/plugins/foreman_bootdisk.yaml +++ /dev/null @@ -1,10 +0,0 @@ -- project: - name: foreman_bootdisk - defaults: plugin - branch: - - master: - foreman_branch: develop - - 17.0-stable: - foreman_branch: 2.1-stable - jobs: - - 'test_plugin_{name}_{branch}' diff --git a/theforeman.org/yaml/jobs/plugins/foreman_default_hostgroup.yaml b/theforeman.org/yaml/jobs/plugins/foreman_default_hostgroup.yaml deleted file mode 100644 index ee5b3548..00000000 --- a/theforeman.org/yaml/jobs/plugins/foreman_default_hostgroup.yaml +++ /dev/null @@ -1,6 +0,0 @@ -- project: - name: foreman_default_hostgroup - defaults: plugin - branch: develop - jobs: - - 'test_plugin_{name}_{branch}' diff --git a/theforeman.org/yaml/jobs/plugins/foreman_digitalocean.yaml b/theforeman.org/yaml/jobs/plugins/foreman_digitalocean.yaml deleted file mode 100644 index 0b05fbde..00000000 --- a/theforeman.org/yaml/jobs/plugins/foreman_digitalocean.yaml +++ /dev/null @@ -1,6 +0,0 @@ -- project: - name: foreman_digitalocean - repo: foreman-digitalocean - defaults: plugin - jobs: - - 'test_plugin_{name}_{branch}' diff --git a/theforeman.org/yaml/jobs/plugins/foreman_discovery.yaml b/theforeman.org/yaml/jobs/plugins/foreman_discovery.yaml deleted file mode 100644 index 9ce2fd1d..00000000 --- a/theforeman.org/yaml/jobs/plugins/foreman_discovery.yaml +++ /dev/null @@ -1,10 +0,0 @@ -- project: - name: foreman_discovery - defaults: plugin - branch: - - develop: - foreman_branch: develop - - 16.1-stable: - foreman_branch: 2.1-stable - jobs: - - 'test_plugin_{name}_{branch}' diff --git a/theforeman.org/yaml/jobs/plugins/foreman_hooks.yaml b/theforeman.org/yaml/jobs/plugins/foreman_hooks.yaml deleted file mode 100644 index 664bd88d..00000000 --- a/theforeman.org/yaml/jobs/plugins/foreman_hooks.yaml +++ /dev/null @@ -1,5 +0,0 @@ -- project: - name: foreman_hooks - defaults: plugin - jobs: - - 'test_plugin_{name}_{branch}' diff --git a/theforeman.org/yaml/jobs/plugins/foreman_host_extra_validator.yaml b/theforeman.org/yaml/jobs/plugins/foreman_host_extra_validator.yaml deleted file mode 100644 index 3d4bf691..00000000 --- a/theforeman.org/yaml/jobs/plugins/foreman_host_extra_validator.yaml +++ /dev/null @@ -1,8 +0,0 @@ -- project: - name: foreman_host_extra_validator - defaults: plugin - branch: - - master: - foreman_branch: develop - jobs: - - 'test_plugin_{name}_{branch}' diff --git a/theforeman.org/yaml/jobs/plugins/foreman_kubevirt.yaml b/theforeman.org/yaml/jobs/plugins/foreman_kubevirt.yaml deleted file mode 100644 index 00aea3db..00000000 --- a/theforeman.org/yaml/jobs/plugins/foreman_kubevirt.yaml +++ /dev/null @@ -1,8 +0,0 @@ -- project: - name: foreman_kubevirt - defaults: plugin - branch: - - master: - foreman_branch: develop - jobs: - - 'test_plugin_{name}_{branch}' diff --git a/theforeman.org/yaml/jobs/plugins/foreman_openscap.yaml b/theforeman.org/yaml/jobs/plugins/foreman_openscap.yaml deleted file mode 100644 index 9e1de45a..00000000 --- a/theforeman.org/yaml/jobs/plugins/foreman_openscap.yaml +++ /dev/null @@ -1,6 +0,0 @@ -- project: - name: foreman_openscap - repo: foreman_openscap - defaults: plugin - jobs: - - 'test_plugin_{name}_{branch}' diff --git a/theforeman.org/yaml/jobs/plugins/foreman_remote_execution.yaml b/theforeman.org/yaml/jobs/plugins/foreman_remote_execution.yaml deleted file mode 100644 index a505cfce..00000000 --- a/theforeman.org/yaml/jobs/plugins/foreman_remote_execution.yaml +++ /dev/null @@ -1,8 +0,0 @@ -- project: - name: foreman_remote_execution - defaults: plugin - branch: - - master: - foreman_branch: develop - jobs: - - 'test_plugin_{name}_{branch}' diff --git a/theforeman.org/yaml/jobs/plugins/foreman_salt.yaml b/theforeman.org/yaml/jobs/plugins/foreman_salt.yaml deleted file mode 100644 index ef843b1e..00000000 --- a/theforeman.org/yaml/jobs/plugins/foreman_salt.yaml +++ /dev/null @@ -1,5 +0,0 @@ -- project: - name: foreman_salt - defaults: plugin - jobs: - - 'test_plugin_{name}_{branch}' diff --git a/theforeman.org/yaml/jobs/plugins/foreman_setup.yaml b/theforeman.org/yaml/jobs/plugins/foreman_setup.yaml deleted file mode 100644 index 34e90c1f..00000000 --- a/theforeman.org/yaml/jobs/plugins/foreman_setup.yaml +++ /dev/null @@ -1,5 +0,0 @@ -- project: - name: foreman_setup - defaults: plugin - jobs: - - 'test_plugin_{name}_{branch}' diff --git a/theforeman.org/yaml/jobs/plugins/foreman_templates.yaml b/theforeman.org/yaml/jobs/plugins/foreman_templates.yaml deleted file mode 100644 index 158f1a93..00000000 --- a/theforeman.org/yaml/jobs/plugins/foreman_templates.yaml +++ /dev/null @@ -1,5 +0,0 @@ -- project: - name: foreman_templates - defaults: plugin - jobs: - - 'test_plugin_{name}_{branch}' diff --git a/theforeman.org/yaml/jobs/plugins/puppetdb_foreman.yaml b/theforeman.org/yaml/jobs/plugins/puppetdb_foreman.yaml deleted file mode 100644 index 7cc6e17f..00000000 --- a/theforeman.org/yaml/jobs/plugins/puppetdb_foreman.yaml +++ /dev/null @@ -1,8 +0,0 @@ -- project: - name: puppetdb_foreman - defaults: plugin - branch: - - master: - foreman_branch: develop - jobs: - - 'test_plugin_{name}_{branch}' diff --git a/theforeman.org/yaml/jobs/test_plugin_pipeline.yaml b/theforeman.org/yaml/jobs/test_plugin_pipeline.yaml new file mode 100644 index 00000000..c2bda11b --- /dev/null +++ b/theforeman.org/yaml/jobs/test_plugin_pipeline.yaml @@ -0,0 +1,135 @@ +# parameters: +# name: plugin name, e.g. foreman_bootdisk +# repo: git repo name as it may differ, e.g. foreman_bootdisk +# branch: git repo branch to test, e.g. master +# foreman_branch: foreman git repo branch to run on, e.g. develop +- job-template: + name: 'test_foreman_plugin_{plugin}_{branch}' + project-type: pipeline + sandbox: true + properties: + - github: + url: '{repo}' + - tfm-build-discarder + parameters: + - string: + name: plugin_repo + default: '{repo}' + description: "Git URL containing the Foreman plugin, e.g.
https://github.com/theforeman/foreman_example
" + - string: + name: plugin_branch + default: '{branch}' + description: "Git branch name of the Foreman plugin, e.g.
master
" + - string: + name: plugin_name + default: '{plugin}' + description: "Name of the Foreman plugin/gem, in the format that should be in the Gemfile, e.g.
foreman_test
" + - string: + name: foreman_repo + default: https://github.com/theforeman/foreman + description: "Git URL containing Foreman itself, which the plugin will be added to, + e.g.
https://github.com/theforeman/foreman
" + - string: + name: foreman_branch + default: '{foreman_branch}' + description: "Git branch name of Foreman itself, e.g.
develop
" + quiet-period: 1200 + triggers: + - github + - pollscm: + cron: 'H/15 * * * *' + - timed: 'H H * * 6' + dsl: + !include-raw: + - pipelines/lib/rvm.groovy{empty} + - pipelines/lib/foreman.groovy{empty} + - pipelines/test/foreman_plugin.groovy{empty} + publishers: + - ircbot_freenode + +# Foreman plugins that follow the conventions +- project: + name: foreman-plugins-standard + plugin: + - ansible + - bootdisk + - default_hostgroup + - extra_hosts + - host_extra_validator + - kubevirt + - monitoring + - omaha + - openscap + - remote_execution + - salt + - setup + - templates + branch: master + foreman_branch: develop + repo: 'https://github.com/theforeman/foreman_{plugin}' + empty: '' + jobs: + - 'test_foreman_plugin_{plugin}_{branch}' + +# Git repo uses a dash instead of an underscore +- project: + name: foreman-plugin-digitalocean + plugin: digitalocean + repo: https://github.com/theforeman/foreman-digitalocean + branch: master + foreman_branch: develop + empty: '' + jobs: + - 'test_foreman_plugin_{plugin}_{branch}' + +# Project name doesn't start with foreman_ +- project: + name: foreman-plugin-puppetdb + plugin: puppetdb + repo: https://github.com/theforeman/puppetdb_foreman + branch: master + foreman_branch: develop + empty: '' + jobs: + - 'test_foreman_plugin_{plugin}_{branch}' + +# Multiple branches +- project: + name: foreman-plugin-bootdisk + plugin: bootdisk + repo: https://github.com/theforeman/foreman_discovery + branch: + - master: + foreman_branch: develop + - 17.0-stable: + foreman_branch: 2.1-stable + empty: '' + jobs: + - 'test_foreman_plugin_{plugin}_{branch}' + name: foreman-plugin-discovery + plugin: discovery + repo: https://github.com/theforeman/foreman_discovery + branch: + - develop: + foreman_branch: develop + - 16.1-stable: + foreman_branch: 2.1-stable + empty: '' + jobs: + - 'test_foreman_plugin_{plugin}_{branch}' + +# Multiple branches and git repo uses a dash +- project: + name: foreman-plugin-tasks + plugin: tasks + repo: https://github.com/theforeman/foreman-tasks + branch: + - master: + foreman_branch: develop + - 0.16.x: + foreman_branch: 1.23-stable + - 0.15.x: + foreman_branch: 1.22-stable + empty: '' + jobs: + - 'test_foreman_plugin_{plugin}_{branch}'