From 98ec03b53a9916e469c917c148de3535f5d7fb85 Mon Sep 17 00:00:00 2001 From: Thomas Thomassen Date: Wed, 3 Jan 2024 17:39:43 +0100 Subject: [PATCH] Add GitHub Action for RuboCop. (#218) --- .github/workflows/rubocop.yml | 31 +++++++++++++++++++++++++++++++ .gitignore | 1 + .rubocop.yml | 28 ++++++++++------------------ Gemfile | 15 ++++++++++++--- 4 files changed, 54 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/rubocop.yml diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml new file mode 100644 index 0000000..39f5708 --- /dev/null +++ b/.github/workflows/rubocop.yml @@ -0,0 +1,31 @@ +name: RuboCop + +on: + workflow_dispatch: + push: + branches: [ "main", "dev/ci", "dev/ci-rubocop" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: read + +jobs: + analysis: + + runs-on: ubuntu-latest + strategy: + matrix: + ruby-version: ['2.7', '3.2'] + + steps: + - uses: actions/checkout@v3 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + - name: RuboCop version information + run: bundle exec rubocop -V + - name: Run RuboCop + run: bundle exec rubocop diff --git a/.gitignore b/.gitignore index 4a47559..0105887 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ /archive/ /build/ /tests_old/ +/vendor/ Debug*/ Release*/ ipch/ diff --git a/.rubocop.yml b/.rubocop.yml index 806bf6a..372aea9 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -5,30 +5,20 @@ require: - rubocop-sketchup AllCops: + NewCops: disable DisabledByDefault: true # TODO: Reenable DisplayStyleGuide: true SuggestExtensions: false SketchUp: SourcePath: src TargetSketchUpVersion: 2014 - SketchupPerformance: - Exclude: - - ruby-c-extension/**/* - - skippy/**/* - - tests/**/* - - tools/**/* - SketchupRequirements: - Exclude: - - ruby-c-extension/**/* - - skippy/**/* - - tests/**/* - - tools/**/* - SketchupSuggestions: - Exclude: - - ruby-c-extension/**/* - - skippy/**/* - - tests/**/* - - tools/**/* + Exclude: + - Gemfile + - ruby-c-extension/**/* + - skippy/**/* + - tests/**/* + - tools/**/* + - vendor/**/* TargetRubyVersion: 2.0 Exclude: - archive/**/* @@ -40,6 +30,7 @@ AllCops: - src/testup/third-party/**/*.rb - tests/**/*.rb # TODO - for now ignore. - tools/**/*.rb + - vendor/**/*.rb SketchupDeprecations: Enabled: true @@ -183,6 +174,7 @@ Style/IfUnlessModifier: Style/MultilineIfModifier: Exclude: + - Gemfile - src/testup/file_reporter.rb - src/testup/ui.rb - src/testup/ui/adapters/htmldialog.rb diff --git a/Gemfile b/Gemfile index 2c7589d..122e94d 100644 --- a/Gemfile +++ b/Gemfile @@ -1,14 +1,23 @@ source 'https://rubygems.org' +# Even if you configure Bundler to install only one group it will fail if any +# of the unused groups have dependencies that cannot be resolved. +# On Ruby 3.2 the Minitest 5.4.3 will fail, so applying this kludge to work +# around that until Minitest is updated. +CI_BUILD = ENV['CI'] + group :development do gem 'colorize', '~> 0.8.1' gem 'minitest', '5.4.3' gem 'minitest-reporters-json_reporter' - gem 'rubocop', '>= 0.82', '< 2.0' - gem 'rubocop-sketchup', '~> 1.3.0' - gem 'rubocop-performance', '~> 1.15.0' gem 'rubyzip', '~> 1.2' gem 'sketchup-api-stubs' gem 'skippy', '~> 0.5.1.a' gem 'solargraph' +end unless CI_BUILD + +group :analytics do + gem 'rubocop', '>= 0.82', '< 2.0' + gem 'rubocop-sketchup', '~> 1.3.0' + gem 'rubocop-performance', '~> 1.15.0' end