Mid-day shots to boost your energy.
So I wrote about the error I got from running Rubocop in Github Workflow, and I was determined to find out the root of the problem.
So I wrote about the error I got from running Rubocop in Github Workflow, and I was determined to find out the root of the problem.
With some digging around the documentation and following a thread of discussions, I figured some what the root of the problem and solved it. So a few things happened.
I quote from the documentation:
Remember that your configuration files override RuboCops’s defaults. …omitted… This behavior of Include (overriding default.yml) was introduced in 0.56.0 via #5882. This change allows people to include/exclude precisely what they need to, without the defaults getting in the way.
It is odd, that even though I had explicitly defined Include
option for only lib/**/*.rb
and spec/**/*.rb
,
Rubocop still attempted to look outside of these folders.
So let’s look at the Exclude
option in my own .rubocop.yml
. Here, I explicitly only specified files under
spec/**/*.rb
that I wanted to exclude. I guess here’s where things went wrong.
By default, Rubocop already excludes vendor/**/*
, but as per the documentation above, when the user defines the
Exclude
option, it will completely override all defaults from Rubocop. In a way, it will “undo” the default
exclusion of vendor/**/*
, so even though my Include
option did not specify vendor/**/*
, it will still attempt to
search inside the directory.
In order to still use Rubocop’s defaults, we can go the brute-force way of copying all the Include
/Exclude
options
from Rubocop’s config/default.yml
. But that’s not very friendly, so the other way is to inherit from the defaults
and add additional Include
/Exclude
options.
Luckily I was not the first to encounter such an issue, so I just referenced what other people did and modified accordingly. And here’s the fix for it.
Now the build passes on Github Workflow, and I can go sit back and relax and enjoy another shot of expresso.
Today, I was trying to setup the Github Workflow for Coffeebrew Jekyll Archives plugin to run test cases and lint the code.
Today, I was trying to setup the Github Workflow for Coffeebrew Jekyll Archives plugin to run test cases and lint the code.
Here’s the initial setup (excerpts):
The script/cibuild
script basically just does 3 things (excerpts):
Then I kept running into the error:
In my mind I was like: “Why on earth did rubocop-minitest
get into my project?”. I tried a few Google searches, they
mostly just mention something along the line of “remember to require: rubocop-minitest
in your .rubocop.yml
”.
But why? I didn’t even use minitest
in my project!
Then with some luck, I stumbled upon this
Stack Overflow question. It’s not exactly the same problem, but the response seems promising. So I followed the
advice and updated my .rubocop.yml
to exclude vendor/**/*
.
Lo and behold, my workflow run finally succeeded. Here’s the fix.
This will not be the end, I will need to figure out why did Rubocop also try to lint the dependencies when I already
specified the Include
option to:
This will be another shot/article that I write when I figure it out. Hope this shot gives you a boost for the day. Stay tuned for more!