I am trying to setup a CI pipeline using Github Actions. At bundle exec rubocop
in my workflow it fails. But the command completely passes locally when run on the rails project.
name: CI - To check on linters and run test
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:
jobs:
build-n-test:
runs-on: ubuntu-latest
env:
RAILS_ENV: test
steps:
- uses: actions/checkout@v1
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: RuboCop
run: bundle exec rubocop
- name: RSpec
run: bundle exec rspec
What I may be missing in the workflow.
It fails with:
Unable to find gem rubocop-discourse; is the gem installed? Gem::MissingSpecError
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/config_loader_resolver.rb:278:in `rescue in gem_config_path'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/config_loader_resolver.rb:268:in `gem_config_path'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/config_loader_resolver.rb:69:in `block (2 levels) in resolve_inheritance_from_gems'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/config_loader_resolver.rb:67:in `reverse_each'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/config_loader_resolver.rb:67:in `block in resolve_inheritance_from_gems'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/config_loader_resolver.rb:61:in `each_pair'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/config_loader_resolver.rb:61:in `resolve_inheritance_from_gems'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/config_loader.rb:50:in `load_file'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/config_loader.rb:103:in `configuration_from_file'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/config_store.rb:68:in `for_dir'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/config_store.rb:58:in `for'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/target_finder.rb:161:in `ruby_interpreters'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/target_finder.rb:153:in `ruby_executable?'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/target_finder.rb:169:in `ruby_file?'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/target_finder.rb:73:in `to_inspect?'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/target_finder.rb:64:in `block in target_files_in_dir'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/target_finder.rb:64:in `select'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/target_finder.rb:64:in `target_files_in_dir'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/target_finder.rb:32:in `find'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/runner.rb:77:in `find_target_files'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/runner.rb:42:in `run'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/cli/command.rb:11:in `run'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/cli/environment.rb:18:in `run'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/cli.rb:71:in `run_command'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/cli.rb:78:in `execute_runners'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/cli.rb:47:in `run'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/exe/rubocop:12:in `block in <top (required)>'
/opt/hostedtoolcache/Ruby/3.0.0/x64/lib/ruby/3.0.0/benchmark.rb:308:in `realtime'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/exe/rubocop:12:in `<top (required)>'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/bin/rubocop:23:in `load'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/bin/rubocop:23:in `<top (required)>'
/opt/hostedtoolcache/Ruby/3.0.0/x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.3/lib/bundler/cli/exec.rb:63:in `load'
/opt/hostedtoolcache/Ruby/3.0.0/x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.3/lib/bundler/cli/exec.rb:63:in `kernel_load'
/opt/hostedtoolcache/Ruby/3.0.0/x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.3/lib/bundler/cli/exec.rb:28:in `run'
/opt/hostedtoolcache/Ruby/3.0.0/x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.3/lib/bundler/cli.rb:497:in `exec'
/opt/hostedtoolcache/Ruby/3.0.0/x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.3/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/opt/hostedtoolcache/Ruby/3.0.0/x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.3/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/opt/hostedtoolcache/Ruby/3.0.0/x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.3/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/opt/hostedtoolcache/Ruby/3.0.0/x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.3/lib/bundler/cli.rb:30:in `dispatch'
/opt/hostedtoolcache/Ruby/3.0.0/x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.3/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/opt/hostedtoolcache/Ruby/3.0.0/x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.3/lib/bundler/cli.rb:24:in `start'
/opt/hostedtoolcache/Ruby/3.0.0/x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.3/exe/bundle:49:in `block in <top (required)>'
/opt/hostedtoolcache/Ruby/3.0.0/x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.3/lib/bundler/friendly_errors.rb:130:in `with_friendly_errors'
/opt/hostedtoolcache/Ruby/3.0.0/x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.3/exe/bundle:37:in `<top (required)>'
/opt/hostedtoolcache/Ruby/3.0.0/x64/bin/bundle:23:in `load'
/opt/hostedtoolcache/Ruby/3.0.0/x64/bin/bundle:23:in `<main>'
Error: Process completed with exit code 2.
CodePudding user response:
It looks like your RuboCop is finding a configuration file that is part of your dependencies. Normally anything in vendor/
is ignored, but it seems your configuration is overriding that. It should be possible to fix it with something like:
AllCops:
Exclude:
- 'vendor/'