diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml new file mode 100644 index 00000000..ceae5ab3 --- /dev/null +++ b/.github/workflows/ruby.yml @@ -0,0 +1,17 @@ +name: Run Specs +on: [ push, pull_request ] + +jobs: + unit_specs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: { lfs: true } + - uses: ruby/setup-ruby@v1 + with: { working-directory: src/bosh_openstack_cpi/ } + - name: lint-and-test + run: | + bundle install + bundle exec rake rubocop + bundle exec rake spec:unit + working-directory: src/bosh_openstack_cpi/ diff --git a/src/bosh_aws_cpi/Gemfile b/src/bosh_aws_cpi/Gemfile index 44d22b29..52572ea0 100644 --- a/src/bosh_aws_cpi/Gemfile +++ b/src/bosh_aws_cpi/Gemfile @@ -14,5 +14,6 @@ group :development, :test do gem 'pry-byebug' gem 'rspec' gem 'rake' + gem 'rubocop' gem 'webmock' end diff --git a/src/bosh_aws_cpi/Gemfile.lock b/src/bosh_aws_cpi/Gemfile.lock index bb825067..4c7c2ecc 100644 --- a/src/bosh_aws_cpi/Gemfile.lock +++ b/src/bosh_aws_cpi/Gemfile.lock @@ -3,6 +3,7 @@ GEM specs: addressable (2.8.7) public_suffix (>= 2.0.2, < 7.0) + ast (2.4.2) aws-eventstream (1.3.0) aws-partitions (1.981.0) aws-sdk-autoscaling (1.121.0) @@ -45,6 +46,8 @@ GEM hashdiff (1.1.1) httpclient (2.8.3) jmespath (1.6.2) + json (2.7.2) + language_server-protocol (3.17.0.3) little-plugger (1.1.4) logging (2.2.2) little-plugger (~> 1.1) @@ -53,6 +56,10 @@ GEM method_source (1.1.0) multi_json (1.15.0) openssl (3.2.0) + parallel (1.26.3) + parser (3.3.5.0) + ast (~> 2.4.1) + racc pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) @@ -60,7 +67,10 @@ GEM byebug (~> 11.0) pry (>= 0.13, < 0.15) public_suffix (6.0.1) + racc (1.8.1) + rainbow (3.1.1) rake (13.2.1) + regexp_parser (2.9.2) rexml (3.3.8) rspec (3.13.0) rspec-core (~> 3.13.0) @@ -75,7 +85,21 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) rspec-support (3.13.1) + rubocop (1.66.1) + json (~> 2.3) + language_server-protocol (>= 3.17.0) + parallel (~> 1.10) + parser (>= 3.3.0.2) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 2.4, < 3.0) + rubocop-ast (>= 1.32.2, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.32.3) + parser (>= 3.3.1.0) + ruby-progressbar (1.13.0) semi_semantic (1.2.0) + unicode-display_width (2.6.0) webmock (3.24.0) addressable (>= 2.8.0) crack (>= 0.3.2) @@ -96,6 +120,7 @@ DEPENDENCIES rake rexml rspec + rubocop webmock BUNDLED WITH diff --git a/src/bosh_aws_cpi/Rakefile b/src/bosh_aws_cpi/Rakefile new file mode 100644 index 00000000..a286d4dd --- /dev/null +++ b/src/bosh_aws_cpi/Rakefile @@ -0,0 +1,12 @@ +require 'rspec/core/rake_task' +require 'rubocop/rake_task' + +namespace :spec do + RSpec::Core::RakeTask.new(:unit) do |t| + t.pattern = 'spec/unit/**{,/*/**}/*_spec.rb' + end +end + +RuboCop::RakeTask.new do |t| + t.options = ['--fail-level=E'] # only fail on `Error` +end \ No newline at end of file diff --git a/src/bosh_aws_cpi/spec/unit/bosh_release/jobs/cpi/templates/cpi.json.erb_spec.rb b/src/bosh_aws_cpi/spec/unit/bosh_release/jobs/cpi/templates/cpi.json.erb_spec.rb index 12959093..137f395b 100644 --- a/src/bosh_aws_cpi/spec/unit/bosh_release/jobs/cpi/templates/cpi.json.erb_spec.rb +++ b/src/bosh_aws_cpi/spec/unit/bosh_release/jobs/cpi/templates/cpi.json.erb_spec.rb @@ -1,6 +1,7 @@ require 'spec_helper' require 'json' require 'yaml' +require 'ostruct' describe 'cpi.json.erb' do let(:cpi_specification_file) { File.absolute_path(File.join(jobs_root, 'aws_cpi/spec')) }