Closed Numie closed 2 years ago
Hi there! I'm so glad that you're finding the gem useful, and thanks so much for opening this issue.
I went ahead and spun up a brand new Rails v6.0.4.8 project with Ruby 2.7.6 and tried the GA workflow that you have with one new controller action. It did error out, but not in the way you described, as can be seen in this screenshot:
This particular error was from not having Yarn packages installed, so I used the following workflow config and gave it a re-run:
name: Chusaku
on: pull_request
jobs:
chusaku:
name: Chusaku
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.0.2
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- uses: actions/setup-node@v3
- name: Run Yarn
run: yarn install
- name: Run Chusaku
run: bundle exec chusaku --dry-run --exit-with-error-on-annotation
This time, it did work as expected.
Your local output and workflow output definitely suggest that you checked in the expected file changes, but just to make sure, it may be worth double-checking the state of your controller(s) and routes on the PR that you're seeing this issue on.
Thanks so much for looking into this so quickly. I think I've confirmed that the controller is currently un-annotated in CI:
For reference, here is the same controller after running chusaku
locally:
Based on my reading of the repo, it seems like the only way to return the Nothing to annotate.
message is if the @changed_files
var is empty. I think the screenshots show the empty @changed_files
is not because the files are already annotated. Maybe the controllers aren't being picked up inside the workflow somehow? I'd be grateful for any other insight you have.
Got it, that's really helpful context, thanks for that.
Would love to see if we can produce a minimum set of code to replicate this issue. The fact that it works locally but not on GitHub Actions is a big hint, but it's still hard to discern the exact bug.
If you don't mind, would you be able to see if you could replicate this issue on a fresh Rails repo? I'll see if I can replicate on the fresh repo I set up in the meantime.
Update here: After some debugging, the Nothing to annotate.
message is due to Chusaku::Routes.call
returning an empty hash in the Github workflow, and that is caused by Rails.application.routes.routes
being empty inside the workflow. I'm still unclear why things worked in your workflow but continue to fail in mine, but I will continue to investigate.
Adding bundle exec rails routes
prior to running chusaku in the workflow resolves the problem. I think we can probably close this issue. Thanks again for the great work on the gem.
✨ I'm glad you got it working! Really bizarre that running the command first fixes the issue for you. If this comes up again please let me know and I'll dig more into it!
Absolutely loving this gem! In order to use in production, we want to implement a Github Actions check to validate that route annotations are up to date. When attempting to implement the workflow, I ran
chusaku
in the root directory but reverted the changes in one file to test the workflow.Expected output:
Output when running locally:
Output in Github Actions Workflow:
Github Action Workflow:
Running Ruby 2.7.6 and Rails 6.0.4.8. Got the same output in the Github Actions workflow when omitting the
--dry-run
flag for what it's worth.