Closed Alagaesia93 closed 6 months ago
Hi @Alagaesia93 Thank for reporting this.
What Knapsack Pro command do you call? Do you pass any custom options?
Can you share the full txt output from the CI node? You can share it with support at https://knapsackpro.com/contact for confidentiality.
Have you tried upgrading the dotenv gem and rspec-core to the latest version?
Do you have any specific dotenv configuration?
Do you use config.dotenv.autorestore = true
(it's a default)?
Thank you @ArturT for jumping in so quickly!
ci.yml
rspec:
env:
RAILS_ENV: test
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
runs-on: ubuntu-22.04
timeout-minutes: 20
needs: [bundle]
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: ${{ env.PGUSER }}
POSTGRES_PASSWORD: ${{ env.PGPASSWORD }}
POSTGRES_DB: test_sky_pilot
ports:
- 5432/tcp
redis:
image: redis
ports:
- 6379/tcp
strategy:
fail-fast: false
matrix:
# Set N number of parallel jobs you want to run tests on.
# Use higher number if you have slow tests to split them on more parallel jobs.
# Remember to update ci_node_index below to 0..N-1
ci_node_total: [3]
# set N-1 indexes for parallel jobs
# When you run 2 parallel jobs then first job will have index 0, the second job will have index 1 etc
ci_node_index: [0, 1, 2]
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Build DB
env:
PGPORT: ${{ job.services.postgres.ports[5432] }} # get randomly assigned published port
run: bin/rails db:schema:load
- name: Run Rspec Tests
env:
PGPORT: ${{ job.services.postgres.ports[5432] }} # get randomly assigned published port
KNAPSACK_PRO_CI_NODE_TOTAL: ${{ matrix.ci_node_total }}
KNAPSACK_PRO_CI_NODE_INDEX: ${{ matrix.ci_node_index }}
KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC: ${{ secrets.KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC }}
KNAPSACK_PRO_FIXED_QUEUE_SPLIT: true
REDIS_URL: redis://localhost:${{ job.services.redis.ports[6379] }}/1
run: bin/rake knapsack_pro:queue:rspec
not sure what else to add from the CI node, we have hundreds of thousands of tests so it's a gigantic file with the same error repeated for each test :)
I have dotenv (not dotenv-rails) 3.0.2, released few days ago. I see that there is 3.0.3 with some fixes, I'll run CI again rspec-rails latest version, rspec-core just 3.12.2 instead of 3.12.3
No specific dotenv config, yes autorestore because it's default
The interesting part is knapsack 6.x works perfectly, knapsack 7.0 breaks everything.
EDIT: just tried with dotenv 3.0.3, same error. Please note that bundle exec rspec works perfectly
Could you update rspec-core to 3.13?
Please replace:
run: bin/rake knapsack_pro:queue:rspec
to
bundle exec rake knapsack_pro:queue:rspec
Does it help?
You can also try this:
bundle exec rake knapsack_pro:queue:rspec_go
The interesting part is knapsack 6.x works perfectly, knapsack 7.0 breaks everything.
We did a big refactor for RSpec in Queue Mode. I see the error is coming from the following line. We directly call the RSpec example_group.run(reporter)
internal method.
# <filtered>/vendor/bundle/ruby/3.3.0/gems/knapsack_pro-7.0.0/lib/knapsack_pro/extensions/rspec_extension.rb:98:in `block (4 levels) in knapsack__run_specs'
I am seeing the same behavior with v7, FWIW. We're using rspec-core 3.13, dotenv 3.0.3, and knapsack-pro 7.0.0. All of our specs fail with the following error:
2) Spree::Order#phone when ship address is present returns the ship address phone
Failure/Error: example.run
NoMethodError:
undefined method `keys' for nil
# /usr/local/bundle/gems/dotenv-3.0.3/lib/dotenv/diff.rb:25:in `added'
# /usr/local/bundle/gems/dotenv-3.0.3/lib/dotenv/diff.rb:47:in `any?'
# /usr/local/bundle/gems/dotenv-3.0.3/lib/dotenv.rb:78:in `restore'
# /usr/local/bundle/gems/dotenv-3.0.3/lib/dotenv/autorestore.rb:9:in `block (2 levels) in <top (required)>'
# ./spec/support/database_cleaner.rb:14:in `block (2 levels) in <top (required)>'
# /usr/local/bundle/gems/knapsack_pro-7.0.0/lib/knapsack_pro/adapters/rspec_adapter.rb:103:in `block (2 levels) in ensure_no_focus!'
# /usr/local/bundle/gems/knapsack_pro-7.0.0/lib/knapsack_pro/extensions/rspec_extension.rb:98:in `block (4 levels) in knapsack__run_specs'
# /usr/local/bundle/gems/knapsack_pro-7.0.0/lib/knapsack_pro/extensions/rspec_extension.rb:96:in `map'
# /usr/local/bundle/gems/knapsack_pro-7.0.0/lib/knapsack_pro/extensions/rspec_extension.rb:96:in `block (3 levels) in knapsack__run_specs'
# /usr/local/bundle/gems/knapsack_pro-7.0.0/lib/knapsack_pro/runners/queue/rspec_runner.rb:82:in `block in with_batch'
# /usr/local/bundle/gems/knapsack_pro-7.0.0/lib/knapsack_pro/runners/queue/rspec_runner.rb:70:in `with_batch'
# /usr/local/bundle/gems/knapsack_pro-7.0.0/lib/knapsack_pro/extensions/rspec_extension.rb:93:in `block (2 levels) in knapsack__run_specs'
# /usr/local/bundle/gems/knapsack_pro-7.0.0/lib/knapsack_pro/extensions/rspec_extension.rb:92:in `block in knapsack__run_specs'
# /usr/local/bundle/gems/knapsack_pro-7.0.0/lib/knapsack_pro/extensions/rspec_extension.rb:91:in `knapsack__run_specs'
# /usr/local/bundle/gems/knapsack_pro-7.0.0/lib/knapsack_pro/runners/queue/rspec_runner.rb:50:in `run'
# /usr/local/bundle/gems/knapsack_pro-7.0.0/lib/knapsack_pro/runners/queue/rspec_runner.rb:20:in `run'
# /usr/local/bundle/gems/knapsack_pro-7.0.0/lib/tasks/queue/rspec.rake:19:in `block (3 levels) in <main>'
We're running our tests as follows: bundle exec rake "knapsack_pro:queue:rspec[--format Fuubar --format RspecJunitFormatter --out ${REPORT_DIR}/junit-report-${TEST_NODE_INDEX}.xml]"
Thank you, @tmtrademarked, for the details.
We will get back to you. Please share any further information you find about the root issue.
--
I have created an internal ticket for the issue.
I ran into the same thing. Similar gems to what @tmtrademarked mentioned above. Though, we do have this bit of code in our spec_helper:
config.around do |example|
# Some setup
example.run
ensure
# Some cleanup
end
We get the failure at example.run
. Just mentioning it in case it helps with the debugging!
rspec-core updated ✅ ci.yml bundle exec replaced ✅
error gone ❌ Sorry, still having the same issue!
Thanks for the details. I'll get back to you.
For more context, I also tried with dotenv 3.1.0 - same results, unfortunately.
Hi @Alagaesia93 @tmtrademarked @irphilli I'm Mat and I work with Artur at Knapsack.
Thanks for taking the time to report this and for sending us all the info.
I've identified the issue and I'm currently working on a fix.
In the meantime, could you please try running the knapsack_pro
RSpec command on your CI with an additional argument, i.e. change
bundle exec rake knapsack_pro:queue:rspec
to
bundle exec rake "knapsack_pro:queue:rspec[--require rails_helper]"
See if this helps and let me know the result, please.
@Pacyfik - thanks! From testing on our CI, it seems like adding --require rails_helper
makes 7.0 work for us.
@Pacyfik - thanks! From testing on our CI, it seems like adding
--require rails_helper
makes 7.0 work for us.
That's great to hear @tmtrademarked Thanks for checking it out 🙌 I'll let you know when the fix is out so you can update knapsack_pro and remove the temporary fix.
... In the meantime, could you please try running the
knapsack_pro
RSpec command on your CI with an additional argument, i.e. changebundle exec rake knapsack_pro:queue:rspec
tobundle exec rake "knapsack_pro:queue:rspec[--require rails_helper]"
See if this helps and let me know the result, please.
@Pacyfik unfortunately, that didn't help us.
Hey @Alagaesia93 @tmtrademarked @irphilli We've just published version 7.0.1 of the gem. Could you please update and let me know if your issue still persists? If you used the workaround I mentioned in my previous comment, you can revert that. Here's the changelog if you're interested.
Hi @hoshy I'm sorry to hear that. I'd appreciate it if you could also update your gem to 7.0.1 and check if that helps. If not, let me know and we'll investigate further and see what we can do about it.
@Pacyfik The workaround (and subsequently, 7.0.1) solved the issue for me. Thank you!
Hi @Pacyfik! Sorry for delay, I was off
With 7.0.1 it doesn't work for me, but it works if I do
bundle exec rake "knapsack_pro:queue:rspec[--require spec_helper]"
The app I'm managing is quite old so we have that file, not sure if you want to add that as an option. I'm also fine with keeping the bundle exec rake "knapsack_pro:queue:rspec[--require spec_helper]", maybe add to readme?
Hey @Alagaesia93 Thanks for letting me know.
I'm happy you managed to find a solution to your issue. If you can continue using it for now, that would be great.
If you can spare a few minutes, I'd be interested to know a few specifics about your app, if you can disclose them of course.
Based on the ci.yml
contents you shared I assume it's a Rails application.
Could you e.g. tell me whether you have an .rspec
file in your root directory (if you do, does it have a --require spec_helper
line in it?), do you have a spec/rails_helper.rb
file, do you require spec_helper
in each of your spec files, do you use Rails engines?
I'm wondering how your RSpec is configured and how it runs without knapsack, so e.g. locally in dev env.
I'm hoping this information might help us inform our design choices and defaults for knapsack_pro.
Hi @hoshy I'm sorry to hear that. I'd appreciate it if you could also update your gem to 7.0.1 and check if that helps. If not, let me know and we'll investigate further and see what we can do about it.
Hi @Pacyfik it's working on our side! Problem was that we haven't excluded some tags which causes the failures. Adding --tag ~someTag
to .rspec
solved the issues
Based on the
ci.yml
contents you shared I assume it's a Rails application
yes
Could you e.g. tell me whether you have an
.rspec
file in your root directory (if you do, does it have a--require spec_helper
line in it?)
I don't have it
do you have a
spec/rails_helper.rb
file
nope
do you require
spec_helper
in each of your spec files
yes
do you use Rails engines?
not sure what you mean here
I'm wondering how your RSpec is configured and how it runs without knapsack, so e.g. locally in dev env. I'm hoping this information might help us inform our design choices and defaults for knapsack_pro.
in local, bundle exec rspec
, easy as that
I hope it helps!
Thanks @Alagaesia93 It seems your app has a slightly less common RSpec setup which might be explained by the age of your project. At the moment, knapsack_pro has all the current RSpec defaults covered. We will have to consider what changes to introduce to cover a wider range of custom RSpec configurations.
For now, seeing as all the people who reported the original issue with their apps, have been able to fix it, I would consider the issue resolved. I'm always happy to continue the conversation if needed or offer any help.
Hello!
After bumping version to 7.0 my whole RSpec CI fails with this error
NoMethodError: undefined method 'keys' for nil
It must be something connected with dotenv and some env variables, but it started failing only after 7.0 version. I tried to check online, but no luck.
If you need anything else, happy to help!
Full error stack
``` NoMethodError: undefined method `keys' for nil #