{"id":13878310,"url":"https://github.com/Bodacious/jiminy","last_synced_at":"2025-07-16T14:31:50.569Z","repository":{"id":38744084,"uuid":"463134406","full_name":"Bodacious/jiminy","owner":"Bodacious","description":"WIP: Detects N+1 queries in test suite and comments on Github PRs","archived":false,"fork":false,"pushed_at":"2023-05-05T13:00:33.000Z","size":261,"stargazers_count":14,"open_issues_count":4,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-03-15T05:22:06.206Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Bodacious.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-24T12:10:02.000Z","updated_at":"2024-08-06T08:46:53.962Z","dependencies_parsed_at":"2024-08-06T08:46:52.986Z","dependency_job_id":"8f26e83d-ed2a-4230-ab61-7e905435c901","html_url":"https://github.com/Bodacious/jiminy","commit_stats":{"total_commits":74,"total_committers":2,"mean_commits":37.0,"dds":"0.013513513513513487","last_synced_commit":"b95ed6225de3fdcf76d213d2e6ac09030251348b"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bodacious%2Fjiminy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bodacious%2Fjiminy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bodacious%2Fjiminy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bodacious%2Fjiminy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Bodacious","download_url":"https://codeload.github.com/Bodacious/jiminy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226138849,"owners_count":17579496,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-06T08:01:45.976Z","updated_at":"2024-11-24T07:30:56.949Z","avatar_url":"https://github.com/Bodacious.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# Jiminy\n\n## Your external conscience when creating pull requests\n\nJiminy wraps around your test suite and detects n+1 queries in your code.\n\nOnce your test suite has run, these can be reported in GitHub PR comments.\n\n## How it works\n\nUnder the hood, Jiminy uses [Prosopite](https://github.com/charkost/prosopite) to detect N+1 queries.\n\nWhen running RSpec tests, Jiminy extends Prosopite to log the n+1 instances it detects to a temp file (by default, `tmp/jiminy/results.yml`).\n\nVia a command-line interface, Jiminy will then report these n+1 queries by commenting in the related PR on GitHub.\n\n## How it looks\n\n![How a Jiminy comment looks in a PR](./example.png)\n\n## Assumptions\n\nJiminy is still pre-release. The current version assumes the following:\n\n- Your application is built in Ruby on Rails\n- You are using RSpec as your test suite\n- You are running your tests on CircleCI\n- Your code repository is on GitHub\n\n## Limitations\n\nSince Jiminy works (via Prosopite) by monitoring DB queries made by the application in test mode, it's possible that your code might introduce a new n+1 that isn't detected. This is more likely if your test setup doesn't create multiple records. For example:\n\n``` ruby\n# in your controller ...\ndef index\n  @users = User.all\n  @users.each do |user|\n    user.profile.name\n  end\nend\n\n# in your test ...\nbefore do\n  @user = User.create(profile: Profile.new(name: \"Profile name\"))\nend\n\nit \"loads the index\" do\n  get :index\n  expect(response).to be_ok\nend\n```\n\nThis controller code will likely result in n+1 records being loaded from the DB, but since only one record is created in the test setup this probably won't be detected.\n\nYou can improve results by adding additional records in some of your test setups to better emulate a real-life scenario.\n\n## Installation\n\n### Installing the gem\n\nAdd the following to your test and development groups:\n\n``` ruby\ngroup :development, :test do\n  gem \"jiminy\"\nend\n```\n\nThen run the following command:\n\n``` ruby\n$ bundle exec jiminy init\n```\n\n## Configuration\n\nThe init command will add this file to your repo. Change the settings here to configure Jiminy:\n\n``` ruby\n# config/jiminy.rb\nJiminy.configure do |config|\n  config.ci_workflow_name = \"build_and_test\"\n\n  config.project_username = \"bodacious\"\n\n  # NOTE: This is case sensitive on CircleCI\n  config.project_reponame = \"jiminy\"\n\n  config.circle_ci_api_token = ENV[\"CIRCLE_CI_API_TOKEN\"]\n\n  config.github_token = ENV[\"GITHUB_TOKEN\"]\n\n  # config.ignore_file_path =  File.join(\"./.jiminy_ignores.yml\")\n\n  # config.temp_file_location = File.join(\"./tmp/jiminy/results.yml\")\nend\n```\n\n_NOTE: This file must be named `config/jiminy.rb` or **the gem will not detect the configuration**._\n\n\n### Running the CLI\n\n``` bash\nbundle exec jiminy report --commit b4742289dDDD364fd983fd57787dda74134acbaf --dry-run --pr-number=2 --poll-interval=5 --timeout=20\n```\n\n### CirleCI Config\n\nMake sure your CircleCI configuration saves the artifacts created when running your test suite:\n\n```yaml\n# ...\n- store_artifacts:\n    path: ./tmp/jiminy\n# ...\n```\n\n### GitHub Actions\n\nCall the Jiminy CLI from a GitHub action:\n\n```yaml\n- name: Report N+1 issues\n  env:\n  CIRCLE_CI_API_TOKEN: ${{ secrets.CIRCLE_CI_API_TOKEN }}\n    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n    PR_NUMBER: ${{ github.event.number }}\n\n  run: |\n    bundle exec jiminy report --commit ${{ github.event.pull_request.head.sha }} --pr-number=$PR_NUMBER --poll-interval=15 --timeout=300\n```\n\n## Ignoring instances\n\nIf you're adding Jiminy to an existing app, you might want to silence some of the existing warnings and focus on preventing new n+1s being introduced.\n\nYou can do this by creating a file in your application's directory called `.jiminy_ignores.yml` and listing the files you wish to ignore:\n\n```yaml\n---\n- app/controllers/application_controller.rb\n- app/models/user.rb\n# - etc.\n```\n\n## How to run the test suite\n\nJiminy testing is still fairly sparse. To run the existing tests use:\n\n\n``` bash\n$ rspec spec\n```\n\nor\n\n``` bash\n$ rake\n```\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/bodacious/jiminy.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBodacious%2Fjiminy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBodacious%2Fjiminy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBodacious%2Fjiminy/lists"}