-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- migrate to settings DSL - drop old Foreman version support - switch to upstream CI - switch to upstream rubocop
- Loading branch information
1 parent
55dc0de
commit 559209a
Showing
24 changed files
with
149 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,34 @@ | ||
name: CI | ||
on: [push, pull_request] | ||
env: | ||
RAILS_ENV: test | ||
DATABASE_URL: postgresql://postgres:@localhost/test | ||
DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL: true | ||
name: Ruby test | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
|
||
concurrency: | ||
group: ${{ github.ref_name }}-${{ github.workflow }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
rubocop: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Setup Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: 2.4 | ||
- name: Setup | ||
run: | | ||
gem install bundler | ||
bundle install --jobs=3 --retry=3 | ||
- name: Run rubocop | ||
run: bundle exec rubocop | ||
uses: theforeman/actions/.github/workflows/rubocop.yml@v0 | ||
with: | ||
command: bundle exec rubocop --parallel --format github | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
name: Ruby | ||
needs: rubocop | ||
services: | ||
postgres: | ||
image: postgres:12.1 | ||
ports: ['5432:5432'] | ||
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
foreman-core-branch: [1.21-stable, 1.22-stable, 1.23-stable, 1.24-stable, 2.0-stable, 2.1-stable, 2.2-stable, develop] | ||
ruby-version: [2.4, 2.5, 2.6] | ||
node-version: [10] | ||
exclude: | ||
- foreman-core-branch: 2.0-stable | ||
ruby-version: 2.4 | ||
- foreman-core-branch: 2.1-stable | ||
ruby-version: 2.4 | ||
- foreman-core-branch: 2.2-stable | ||
ruby-version: 2.4 | ||
- foreman-core-branch: develop | ||
ruby-version: 2.4 | ||
steps: | ||
- name: Install dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install build-essential libcurl4-openssl-dev libvirt-dev ruby-libvirt zlib1g-dev libpq-dev | ||
- uses: actions/checkout@v2 | ||
with: | ||
repository: theforeman/foreman | ||
ref: ${{ matrix.foreman-core-branch }} | ||
- uses: actions/checkout@v2 | ||
with: | ||
path: foreman_rescue | ||
- name: Setup Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: ${{ matrix.ruby-version }} | ||
- name: Setup Node | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: Setup Bundler | ||
run: | | ||
echo "gem 'foreman_rescue', path: './foreman_rescue'" > bundler.d/foreman_rescue.local.rb | ||
gem install bundler | ||
bundle config path vendor/bundle | ||
bundle config set without journald development console mysql2 sqlite | ||
bundle lock --update | ||
- name: Cache gems | ||
uses: actions/cache@v2 | ||
with: | ||
path: vendor/bundle | ||
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-gems- | ||
- name: Setup Plugin | ||
run: | | ||
bundle install --jobs=3 --retry=3 | ||
bundle exec rake db:create | ||
bundle exec rake db:migrate | ||
npm install | ||
bundle exec rake webpack:compile | ||
- name: Run plugin tests | ||
run: | | ||
bundle exec rake test:foreman_rescue | ||
bundle exec rake test TEST="test/unit/foreman/access_permissions_test.rb" | ||
- name: Precompile plugin assets | ||
run: bundle exec rake 'plugin:assets:precompile[foreman_rescue]' | ||
env: | ||
RAILS_ENV: production | ||
foreman: | ||
- "develop" | ||
- "3.10-stable" | ||
- "3.9-stable" | ||
uses: theforeman/actions/.github/workflows/foreman_plugin.yml@v0 | ||
with: | ||
plugin: foreman_rescue | ||
foreman_version: ${{ matrix.foreman }} | ||
environment_variables: | | ||
FOREMAN_VERSION=${{ matrix.foreman }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
source 'https://rubygems.org' | ||
|
||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 9 additions & 7 deletions
16
app/helpers/concerns/foreman_rescue/hosts_helper_extensions.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module ForemanRescue | ||
module HostExtensions | ||
def self.prepended(base) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module ForemanRescue | ||
module Orchestration | ||
module TFTP | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
class Setting | ||
class Rescue < ::Setting | ||
BLANK_ATTRS.concat ['rescue_pxegrub_tftp_template', 'rescue_pxegrub2_tftp_template'] | ||
|
||
def self.default_settings | ||
[ | ||
set('rescue_pxelinux_tftp_template', | ||
N_('PXELinux template used when booting rescue system'), | ||
'Kickstart rescue PXELinux', N_('PXELinux rescue template'), nil, | ||
:collection => proc { Setting::Rescue.templates('PXELinux') }), | ||
set('rescue_pxegrub_tftp_template', | ||
N_('PXEGrub template used when booting rescue system'), | ||
'', N_('PXEGrub rescue template'), nil, | ||
:collection => proc { Setting::Rescue.templates('PXEGrub') }), | ||
set('rescue_pxegrub2_tftp_template', | ||
N_('PXEGrub2 template used when booting rescue system'), | ||
'', N_('PXEGrub2 rescue template'), nil, | ||
:collection => proc { Setting::Rescue.templates('PXEGrub2') }) | ||
] | ||
end | ||
|
||
def self.load_defaults | ||
# Check the table exists | ||
return unless super | ||
|
||
transaction do | ||
default_settings.each { |s| create! s.update(:category => 'Setting::Rescue') } | ||
end | ||
|
||
true | ||
end | ||
|
||
def self.templates(kind) | ||
template_kind = TemplateKind.find_by(name: kind) | ||
templates = ProvisioningTemplate.where(:template_kind => template_kind) | ||
templates.each_with_object({}) do |template, hsh| | ||
hsh[template.name] = template.name | ||
end | ||
end | ||
|
||
def self.humanized_category | ||
N_('Rescue System') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
db/migrate/20170901131321_add_rescue_mode_to_host.foreman_rescue.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
db/migrate/20240506132712_migrate_rescue_settings_category_to_dsl.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
class MigrateRescueSettingsCategoryToDsl < ActiveRecord::Migration[6.0] | ||
class MigrationSettings < ApplicationRecord | ||
self.table_name = :settings | ||
end | ||
|
||
def up | ||
MigrationSettings.where(category: 'Setting::Rescue').update_all(category: 'Setting') if column_exists?( | ||
:settings, :category | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'foreman_rescue/engine' | ||
|
||
module ForemanRescue | ||
|
Oops, something went wrong.