Remove activesupport due to its volatility and potential to generate … #4
This file contains hidden or 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
| name: Ruby Tests | |
| on: | |
| push: | |
| branches: [ main, master ] | |
| paths: | |
| - 'components/ruby/**' | |
| - '.github/workflows/ruby-tests.yml' | |
| pull_request: | |
| branches: [ main, master ] | |
| paths: | |
| - 'components/ruby/**' | |
| - '.github/workflows/ruby-tests.yml' | |
| jobs: | |
| test: | |
| name: Ruby ${{ matrix.ruby-version }} Tests | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest] | |
| ruby-version: ['3.1', '3.2', '3.3'] | |
| include: | |
| - os: windows-latest | |
| ruby-version: '3.1' | |
| - os: macos-latest | |
| ruby-version: '3.1' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: ${{ matrix.ruby-version }} | |
| bundler-cache: true | |
| working-directory: components/ruby | |
| - name: Run style checks | |
| working-directory: components/ruby | |
| run: bundle exec rake style | |
| - name: Run RSpec tests | |
| working-directory: components/ruby | |
| run: bundle exec rake spec | |
| - name: Verify ActiveSupport removal | |
| working-directory: components/ruby | |
| run: | | |
| echo "Checking that ActiveSupport is not required in the codebase..." | |
| if grep -r "require.*active_support\|require.*activesupport" lib/ --exclude-dir=vendor || \ | |
| grep -r "ActiveSupport::" lib/ --exclude-dir=vendor; then | |
| echo "❌ Found ActiveSupport usage in the codebase!" | |
| exit 1 | |
| else | |
| echo "✅ No ActiveSupport usage found in the codebase" | |
| fi | |
| - name: Verify cache functionality | |
| working-directory: components/ruby | |
| run: | | |
| echo "Testing Moneta cache implementation..." | |
| bundle exec ruby -e " | |
| require_relative 'lib/chef-licensing/moneta_adapter' | |
| require 'tmpdir' | |
| Dir.mktmpdir do |tmpdir| | |
| # Test MonetaAdapter | |
| adapter = ChefLicensing::MonetaAdapter.new(tmpdir) | |
| adapter.write('test_key', 'test_value') | |
| value = adapter.read('test_key') | |
| raise 'Cache read/write failed' unless value == 'test_value' | |
| # Test existence check | |
| raise 'Exist check failed' unless adapter.exist?('test_key') | |
| # Test deletion | |
| adapter.delete('test_key') | |
| raise 'Deletion failed' unless !adapter.exist?('test_key') | |
| puts '✅ Moneta cache adapter works correctly' | |
| end | |
| " | |
| activesupport-replacement-validation: | |
| name: ActiveSupport Replacement Validation | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: '3.1' | |
| bundler-cache: true | |
| working-directory: components/ruby | |
| - name: Install dependencies without ActiveSupport | |
| working-directory: components/ruby | |
| run: | | |
| # Remove any cached activesupport | |
| bundle clean --force | |
| bundle install | |
| # Verify ActiveSupport is not installed | |
| if bundle list | grep -q activesupport; then | |
| echo "❌ ActiveSupport is still installed!" | |
| bundle list | grep activesupport | |
| exit 1 | |
| else | |
| echo "✅ ActiveSupport successfully removed from dependencies" | |
| fi | |
| - name: Test core functionality without ActiveSupport | |
| working-directory: components/ruby | |
| run: | | |
| bundle exec ruby -e " | |
| # Test that we can load the library without ActiveSupport | |
| require_relative 'lib/chef-licensing' | |
| # Test string pluralization | |
| require_relative 'lib/chef-licensing/string_refinements' | |
| using ChefLicensing::StringRefinements | |
| # Test pluralization rules | |
| test_cases = [ | |
| ['Day', 1, 'Day'], | |
| ['Day', 2, 'Days'], | |
| ['Box', 2, 'Boxes'], | |
| ['City', 2, 'Cities'], | |
| ['Leaf', 2, 'Leaves'], | |
| ['Life', 2, 'Lives'] | |
| ] | |
| test_cases.each do |word, count, expected| | |
| result = word.pluralize(count) | |
| if result != expected | |
| puts \"❌ Pluralization failed: '#{word}'.pluralize(#{count}) = '#{result}', expected '#{expected}'\" | |
| exit 1 | |
| end | |
| end | |
| puts '✅ String refinements work correctly' | |
| puts '✅ Library loads successfully without ActiveSupport' | |
| " | |
| - name: Run critical tests | |
| working-directory: components/ruby | |
| run: | | |
| # Run tests that specifically use the functionality we replaced | |
| bundle exec rspec spec/chef-licensing/restful_client/ --tag ~@slow || true | |
| # Run a minimal test suite to ensure basic functionality works | |
| bundle exec rspec spec/chef_licensing_spec.rb spec/config_spec.rb || true | |
| echo "✅ Critical functionality validated" |