diff --git a/.github/workflows/smart-proxy.yml b/.github/workflows/smart-proxy.yml index da22a08fd..a30323db6 100644 --- a/.github/workflows/smart-proxy.yml +++ b/.github/workflows/smart-proxy.yml @@ -69,12 +69,49 @@ jobs: - name: Run rake test run: bundle exec rake test + tests-on-windows: + name: "Test on Windows - Ruby ${{ matrix.ruby }}" + runs-on: windows-latest + needs: + - setup_matrix + defaults: + run: + shell: pwsh + strategy: + matrix: ${{ fromJson(needs.setup_matrix.outputs.matrix) }} + env: + BUNDLE_WITHOUT: "krb5 libvirt" + steps: + - name: Checkout this repo + uses: actions/checkout@v4 + - name: Set up Ruby (Windows) + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + - name: Show Ruby env (sanity) + run: | + ruby -v + gem -v + ridk version + - name: Rake sanity + run: | + bundle exec rake -T + - name: Archive Gemfile.lock + uses: actions/upload-artifact@v4 + with: + name: Gemfile-windows-ruby-${{ matrix.ruby }}.lock + path: Gemfile.lock + - name: Run rake test + run: bundle exec rake test + result: if: always() name: Test suite runs-on: ubuntu-24.04 needs: - tests + - tests-on-windows steps: - name: Decide whether the needed jobs succeeded or failed uses: re-actors/alls-green@release/v1 diff --git a/Gemfile b/Gemfile index 8e9ed747c..c16004cc9 100644 --- a/Gemfile +++ b/Gemfile @@ -10,4 +10,4 @@ end # Changed from a default gem to a bundled gem in Ruby 3.4 # See: https://stdgems.org/new-in/3.4/ -gem 'syslog' if RUBY_VERSION >= '3.4' +gem 'syslog', '>= 0.3.0' if RUBY_VERSION >= '3.4' diff --git a/Rakefile b/Rakefile index 2f85cff2a..4b843ac70 100644 --- a/Rakefile +++ b/Rakefile @@ -11,12 +11,22 @@ load 'tasks/rubocop.rake' desc 'Default: run unit tests.' task :default => :test + +# Collect all test files, excluding those specified in the SKIP_TEST_FILES environment variable +all_test_files = FileList['test/**/*_test.rb'] +skip_tests = ENV['SKIP_TEST_FILES'] ? ENV['SKIP_TEST_FILES'].split(',') : [] + +# remove all tests which start with test/#{skip_test} +test_files = all_test_files.reject do |file| + skip_tests.any? { |skip_test| file.start_with?("test/#{skip_test}") } +end + desc 'Test the Foreman Proxy plugin.' Rake::TestTask.new(:test) do |t| t.libs << '.' t.libs << 'lib' t.libs << 'test' - t.test_files = FileList['test/**/*_test.rb'] + t.test_files = test_files t.verbose = true t.ruby_opts = ["-W1"] end diff --git a/bundler.d/krb5.rb b/bundler.d/krb5.rb index 3bfce8a41..2b9dcadd3 100644 --- a/bundler.d/krb5.rb +++ b/bundler.d/krb5.rb @@ -2,3 +2,6 @@ gem 'rkerberos', '>= 0.1.1' gem 'gssapi' end + +tests = %w[dns realm] +ENV['SKIP_TEST_FILES'] = ((ENV['SKIP_TEST_FILES'] || "").split(",") + tests).uniq.join(",") diff --git a/bundler.d/libvirt.rb b/bundler.d/libvirt.rb index 9dedd09b4..ab94f207f 100644 --- a/bundler.d/libvirt.rb +++ b/bundler.d/libvirt.rb @@ -1,3 +1,6 @@ group :libvirt do gem 'ruby-libvirt', '>= 0.6.0' end + +tests = %w[dhcp_libvirt dns_libvirt migrations/libvirt_migration_test.rb] +ENV['SKIP_TEST_FILES'] = ((ENV['SKIP_TEST_FILES'] || "").split(",") + tests).uniq.join(",")