rspec_profiling-0.0.9/0000755000004100000410000000000014620237543014743 5ustar www-datawww-datarspec_profiling-0.0.9/.gitignore0000644000004100000410000000027414620237543016736 0ustar www-datawww-data*.gem *.rbc .bundle .config .env .ruby-gemset .yardoc Gemfile.lock InstalledFiles _yardoc coverage doc/ lib/bundler/man pkg rdoc rspec_profiling spec/reports test/tmp test/version_tmp tmp rspec_profiling-0.0.9/CONTRIBUTING.md0000644000004100000410000000366614620237543017207 0ustar www-datawww-data# Contributing to Procore Projects This document explains the common procedures expected by contributors while submitting code to Procore open source projects. ## Code of Conduct Please read and abide by the [Code of Conduct](CODE_OF_CONDUCT.md) ## General workflow Once a GitHub issue is accepted and assigned to you, please follow general workflow in order to submit your contribution: 1. Fork the target repository under your GitHub username. 2. Create a branch in your forked repository for the changes you are about to make. 3. Commit your changes in the branch you created in step 2. All commits need to be signed-off. Check the [legal](#legal) section bellow for more details. 4. Push your commits to your remote fork. 5. Create a Pull Request from your remote fork pointing to the HEAD branch (usually `main` branch) of the target repository. 6. Check the GitHub build and ensure that all checks are green. ## Legal Procore projects use Developer Certificate of Origin ([DCO](https://GitHub.com/apps/dco/)). Please sign-off your contributions by doing ONE of the following: * Use `git commit -s ...` with each commit to add the sign-off or * Manually add a `Signed-off-by: Your Name ` to each commit message. The email address must match your primary GitHub email. You do NOT need cryptographic (e.g. gpg) signing. * Use `git commit -s --amend ...` to add a sign-off to the latest commit, if you forgot. *Note*: Some projects will provide specific configuration to ensure all commits are signed-off. Please check the project's documentation for more details. ## Tests Make sure your changes are properly covered by automated tests. We aim to build an efficient test suite that is low cost to maintain and bring value to project. Prefer writing unit-tests over heavy end-to-end (e2e) tests. However, sometimes e2e tests are necessary. If you aren't sure, ask one of the maintainers about the requirements for your pull-request. rspec_profiling-0.0.9/SECURITY.md0000644000004100000410000000122414620237543016533 0ustar www-datawww-data# Security Policy ## Supported Versions Ruby versions that are currently being supported with security updates. | Version | Supported | | ------- | ------------------ | | <=2.6 | :x: | | 2.7 | :white_check_mark: | | 3.0 | :white_check_mark: | | 3.1 | :white_check_mark: | | 3.2 | :white_check_mark: | | 3.3 | :white_check_mark: | ## Reporting a Vulnerability Please click the `Report a vulnerability` button [here](https://github.com/procore-oss/rspec_profiling/security) to report a vulnerability. A maintainer will respond to you as soon as possible and discuss the process to get the vulnerability fixed. rspec_profiling-0.0.9/.github/0000755000004100000410000000000014620237543016303 5ustar www-datawww-datarspec_profiling-0.0.9/.github/PULL_REQUEST_TEMPLATE.md0000644000004100000410000000134014620237543022102 0ustar www-datawww-dataChecklist: * [ ] I have updated the necessary documentation * [ ] I have signed off all my commits as required by [DCO](https://github.com/procore-oss/rspec_profiling/blob/main/CONTRIBUTING.md) * [ ] My build is green rspec_profiling-0.0.9/.github/CODEOWNERS0000644000004100000410000000010114620237543017666 0ustar www-datawww-data* @procore-oss/procore-ospo @procore-oss/procore-rspec-profiling rspec_profiling-0.0.9/.github/workflows/0000755000004100000410000000000014620237543020340 5ustar www-datawww-datarspec_profiling-0.0.9/.github/workflows/stale.yaml0000644000004100000410000000272414620237543022341 0ustar www-datawww-data## Reference: https://github.com/actions/stale name: Mark stale issues and pull requests on: schedule: - cron: "30 1 * * *" permissions: contents: read jobs: stale: permissions: issues: write # for actions/stale to close stale issues pull-requests: write # for actions/stale to close stale PRs runs-on: ubuntu-latest steps: - uses: actions/stale@v9 with: repo-token: ${{ secrets.GITHUB_TOKEN }} # Number of days of inactivity before an issue becomes stale days-before-stale: 60 # Number of days of inactivity before a stale issue is closed days-before-close: 7 # Issues with these labels will never be considered stale exempt-issue-labels: "on-hold,pinned,security" exempt-pr-labels: "on-hold,pinned,security" # Comment to post when marking an issue as stale. stale-issue-message: > This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. stale-pr-message: > This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. # Label to use when marking an issue as stale stale-issue-label: 'no-issue-activity' stale-pr-label: 'no-pr-activity' rspec_profiling-0.0.9/.github/workflows/test.yaml0000644000004100000410000000356214620237543022211 0ustar www-datawww-dataname: Test on: push: branches: [main] pull_request: branches: [main] permissions: contents: read jobs: test: env: ENVIRONMENT: test PGDATABASE: rspec_profiling_test PGHOST: localhost PGPASSWORD: mypassword PGUSER: myuser SPEC_GEMFILE: spec/Gemfile strategy: matrix: ruby: ['2.7', '3.0', '3.1', '3.2', '3.3'] postgres: ['16-bookworm', '15-bookworm', '14-bookworm', '13-bookworm', '12-bookworm'] name: Ruby ${{ matrix.ruby }} - PostgreSQL ${{ matrix.postgres }} # https://docs.github.com/en/actions/learn-github-actions/expressions#example runs-on: ${{ matrix.ruby == '2.7' && 'ubuntu-20.04' || 'ubuntu-latest' }} services: postgres: image: postgres:${{ matrix.postgres }} env: POSTGRES_HOST: ${{ env.PGHOST }} POSTGRES_DB: ${{ env.PGDATABASE}} POSTGRES_HOST_AUTH_METHOD: trust POSTGRES_USER: ${{ env.PGUSER }} options: >- --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 ports: - 5432:5432 steps: - uses: actions/checkout@v4 - name: Set up Ruby ${{ matrix.ruby }} uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} bundler-cache: true - name: Installing dependencies run: bundle install --gemfile ${{ env.SPEC_GEMFILE }} && cd spec/dummy && bundle install - name: Setup Database in Dummy Rails App run: cd spec/dummy && bundle exec rake db:create db:migrate --trace RAILS_ENV=${{ env.ENVIRONMENT }} - name: Initialize rspec_profiling in Dummy Rails App run: cd spec/dummy && bundle exec rake rspec_profiling:install RAILS_ENV=${{ env.ENVIRONMENT }} - name: Run specs run: bundle exec --gemfile ${{ env.SPEC_GEMFILE }} rspec rspec_profiling-0.0.9/.github/workflows/auto-assign-author.yaml0000644000004100000410000000040714620237543024757 0ustar www-datawww-dataname: 'Auto Author Assign' on: pull_request_target: types: [opened, reopened] jobs: assign-author: runs-on: ubuntu-latest steps: - uses: toshimaru/auto-author-assign@v2.1.0 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" rspec_profiling-0.0.9/.github/workflows/release.yaml0000644000004100000410000000246114620237543022647 0ustar www-datawww-dataname: Release on: workflow_run: workflows: [Test] types: [completed] branches: [main] workflow_dispatch: # allow manual deployment through GitHub Action UI jobs: version-check: runs-on: ubuntu-latest if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }} outputs: changed: ${{ steps.check.outputs.any_changed }} steps: - uses: actions/checkout@v4 - name: Check if version has been updated id: check uses: tj-actions/changed-files@v42 with: files: lib/rspec_profiling/version.rb release: runs-on: ubuntu-latest needs: version-check if: ${{ github.event_name == 'workflow_dispatch' || needs.version-check.outputs.changed == 'true' }} steps: - uses: actions/checkout@v4 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: ruby-version: 3.2 bundler-cache: true - name: Installing dependencies run: bundle install - name: Build gem file run: bundle exec rake build - uses: fac/ruby-gem-setup-credentials-action@v2 with: user: "" key: rubygems token: ${{secrets.RUBY_GEMS_API_KEY}} - uses: fac/ruby-gem-push-action@v2 with: key: rubygems rspec_profiling-0.0.9/.github/workflows/codeql.yaml0000644000004100000410000000154614620237543022501 0ustar www-datawww-dataname: "Custom CodeQL" on: workflow_dispatch: push: branches: [ "main" ] pull_request: branches: [ "main" ] permissions: contents: read jobs: analyze: name: Analyze runs-on: Ubuntu-latest timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }} permissions: actions: read contents: read security-events: write strategy: fail-fast: false matrix: language: [ 'ruby' ] steps: - name: Checkout repository uses: actions/checkout@v4 - name: Initialize CodeQL uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} - name: Autobuild uses: github/codeql-action/autobuild@v3 - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3 with: category: "/language:${{matrix.language}}" rspec_profiling-0.0.9/.github/ISSUE_TEMPLATE/0000755000004100000410000000000014620237543020466 5ustar www-datawww-datarspec_profiling-0.0.9/.github/ISSUE_TEMPLATE/feature-request.yml0000644000004100000410000000241414620237543024333 0ustar www-datawww-dataname: 🚀🆕 Feature Request description: Suggest an idea or possible new feature for this project title: "[Feature Request] " labels: [feature, needs-triage] body: - type: checkboxes attributes: label: Is there an existing issue for this? description: Please search to see if an issue already exists for the bug you encountered. options: - label: I have searched the existing issues required: true - type: textarea attributes: label: Is your feature request related to a problem? Please describe description: A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] validations: required: true - type: textarea attributes: label: Describe the feature you'd like to see implemented description: A clear and concise description of what you want to happen validations: required: true - type: textarea attributes: label: Describe alternatives you've considered description: A clear and concise description of any alternative solutions or features you've considered validations: required: false - type: textarea attributes: label: Additional context description: Add any other context or additional information about the problem here validations: required: false ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������rspec_profiling-0.0.9/.github/ISSUE_TEMPLATE/docs.yml�����������������������������������������������0000644�0000041�0000041�00000001130�14620237543�022134� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������name: 📚 Documentation or README.md issue report description: File a bug/issue for docs or README.md title: "[bug] <title>" labels: [docs, needs-triage] body: - type: checkboxes attributes: label: Is there an existing issue for this? description: Please search to see if an issue already exists for the bug you encountered. options: - label: I have searched the existing issues required: true - type: textarea attributes: label: Docs/README.md Part to update description: A concise description of what you thing should be updated validations: required: true ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������rspec_profiling-0.0.9/.github/ISSUE_TEMPLATE/bug.yml������������������������������������������������0000644�0000041�0000041�00000003403�14620237543�021766� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������name: 🐞 Bug description: File a bug/issue title: "[bug] <title>" labels: [bug, needs-triage] body: - type: checkboxes attributes: label: Is there an existing issue for this? description: Please search to see if an issue already exists for the bug you encountered. options: - label: I have searched the existing issues required: true - type: checkboxes attributes: label: Is this a regression? description: Did this behavior work before? options: - label: Yes, this used to work before required: false - type: textarea attributes: label: Current Behavior description: A concise description of what you're experiencing. validations: required: false - type: textarea attributes: label: Expected Behavior description: A concise description of what you expected to happen. validations: required: false - type: textarea attributes: label: Steps To Reproduce description: Steps to reproduce the behavior. placeholder: | 1. 2. 3. 4. validations: required: true - type: textarea attributes: label: Environment description: | examples: - **OS**: OSX 13.3.1 - **Browser Name and Version**: Chrome Version 112.0.5615.49 (Official Build) (arm64) - **Ruby Version**: 3.0.0 value: | - OS: - Browser Name and version: - Ruby Version: render: markdown validations: required: true - type: textarea attributes: label: Anything else? description: | Links? References? Anything that will give us more context about the issue you are encountering! Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in. validations: required: false �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������rspec_profiling-0.0.9/.github/ISSUE_TEMPLATE/question-support.yml�����������������������������������0000644�0000041�0000041�00000001155�14620237543�024574� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������name: ❓ Question or Support Request description: Questions and requests for support title: "[Question/Support] <title>" labels: [question, support, needs-triage] body: - type: checkboxes attributes: label: Is there an existing issue for this? description: Please search to see if an issue already exists for the bug you encountered. options: - label: I have searched the existing issues required: true - type: textarea attributes: label: Describe your question or ask for support description: A concise description of what you would like support with validations: required: true �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������rspec_profiling-0.0.9/.github/ISSUE_TEMPLATE/config.yml���������������������������������������������0000644�0000041�0000041�00000000034�14620237543�022453� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������blank_issues_enabled: false ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������rspec_profiling-0.0.9/.github/dependabot.yaml�������������������������������������������������������0000644�0000041�0000041�00000000664�14620237543�021302� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������version: 2 updates: - package-ecosystem: "github-actions" directory: / schedule: interval: "weekly" timezone: "America/Los_Angeles" labels: - "dependabot" - "dependencies" - "github-actions" - package-ecosystem: "bundler" directory: / schedule: interval: "weekly" timezone: "America/Los_Angeles" labels: - "dependabot" - "dependencies" - "bundler" ����������������������������������������������������������������������������rspec_profiling-0.0.9/lib/��������������������������������������������������������������������������0000755�0000041�0000041�00000000000�14620237543�015511� 5����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������rspec_profiling-0.0.9/lib/tasks/��������������������������������������������������������������������0000755�0000041�0000041�00000000000�14620237543�016636� 5����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������rspec_profiling-0.0.9/lib/tasks/rspec_profiling.rake������������������������������������������������0000644�0000041�0000041�00000001015�14620237543�022664� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������require 'rake' namespace :rspec_profiling do desc "Install the collector" task install: :environment do collector.install end desc "Uninstall the collector" task uninstall: :environment do collector.uninstall end task console: :environment do require 'irb' require 'irb/completion' require 'rspec_profiling' require 'rspec_profiling/console' ARGV.clear IRB.start end task :reset do collector.reset end def collector RspecProfiling.config.collector end end �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������rspec_profiling-0.0.9/lib/rspec_profiling.rb��������������������������������������������������������0000644�0000041�0000041�00000001201�14620237543�021215� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������require "ostruct" require "rails" require "rspec_profiling/config" require "rspec_profiling/version" require "rspec_profiling/run" require "rspec_profiling/collectors/csv" require "rspec_profiling/vcs/git" require "rspec_profiling/vcs/svn" require "rspec_profiling/vcs/git_svn" begin require "rspec_profiling/collectors/sql" rescue LoadError #no op end begin require "rspec_profiling/collectors/psql" rescue LoadError #no op end module RspecProfiling class Railtie < Rails::Railtie railtie_name :rspec_profiling rake_tasks do load "tasks/rspec_profiling.rake" end end end RSpecProfiling = RspecProfiling �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������rspec_profiling-0.0.9/lib/rspec_profiling/����������������������������������������������������������0000755�0000041�0000041�00000000000�14620237543�020676� 5����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������rspec_profiling-0.0.9/lib/rspec_profiling/run.rb����������������������������������������������������0000644�0000041�0000041�00000005622�14620237543�022034� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������require "get_process_mem" require "rspec_profiling/example" require "rspec_profiling/vcs/git" require "rspec_profiling/vcs/svn" require "rspec_profiling/vcs/git_svn" require "rspec_profiling/collectors/csv" require "rspec_profiling/collectors/json" module RspecProfiling class Run def initialize(collector = RspecProfiling.config.collector.new, vcs = RspecProfiling.config.vcs.new, events = RspecProfiling.config.events) @collector = collector @vcs = vcs @events = events @seed = RSpec.configuration.seed end def start(*args) start_counting_queries start_counting_requests start_counting_events end def example_started(example) start_recording_memory example = example.example if example.respond_to?(:example) @current_example = Example.new(example) end def example_finished(*args) collector.insert({ branch: vcs.branch, commit_hash: vcs.sha, seed: @seed, date: vcs.time, file: @current_example.file, line_number: @current_example.line_number, description: @current_example.description, status: @current_example.status, exception: @current_example.exception, time: @current_example.time, owner_tag: @current_example.owner_tag, query_count: @current_example.query_count, query_time: @current_example.query_time, request_count: @current_example.request_count, request_time: @current_example.request_time, events: @events, event_counts: @current_example.event_counts, event_times: @current_example.event_times, event_events: @current_example.event_events, start_memory: @start_memory, end_memory: end_memory }) end alias :example_passed :example_finished alias :example_failed :example_finished private attr_reader :collector, :vcs, :events, :seed, :start_memory def end_memory GetProcessMem.new.mb end def start_recording_memory @start_memory = GetProcessMem.new.mb end def start_counting_queries ActiveSupport::Notifications.subscribe("sql.active_record") do |name, start, finish, id, query| @current_example.try(:log_query, query, start, finish) end end def start_counting_requests ActiveSupport::Notifications.subscribe("process_action.action_controller") do |name, start, finish, id, request| @current_example.try(:log_request, request, start, finish) end end def start_counting_events events.each do |event_name| ActiveSupport::Notifications.subscribe(event_name) do |name, start, finish, id, event| @current_example.try(:log_event, event_name, event, start, finish) end end end end end ��������������������������������������������������������������������������������������������������������������rspec_profiling-0.0.9/lib/rspec_profiling/config.rb�������������������������������������������������0000644�0000041�0000041�00000000537�14620237543�022475� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������module RspecProfiling def self.configure yield config end def self.config @config ||= OpenStruct.new({ collector: RspecProfiling::Collectors::CSV, vcs: RspecProfiling::VCS::Git, table_name: 'spec_profiling_results', events: [], magic_comment: 'team', additional_data: {} }) end end �����������������������������������������������������������������������������������������������������������������������������������������������������������������rspec_profiling-0.0.9/lib/rspec_profiling/rspec.rb��������������������������������������������������0000644�0000041�0000041�00000000506�14620237543�022340� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������require "rspec_profiling" RSpec.configure do |config| runner = RspecProfiling::Run.new(RspecProfiling.config.collector.new, RspecProfiling.config.vcs.new) config.reporter.register_listener( runner, :start, :example_started, :example_passed, :example_failed ) end ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������rspec_profiling-0.0.9/lib/rspec_profiling/vcs/������������������������������������������������������0000755�0000041�0000041�00000000000�14620237543�021471� 5����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������rspec_profiling-0.0.9/lib/rspec_profiling/vcs/git_svn.rb��������������������������������������������0000644�0000041�0000041�00000001422�14620237543�023466� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������require 'time' module RspecProfiling module VCS class GitSvn # returns nil if using `git svn` def version_control `[ -d .git/svn ] && [ x != x"$(ls -A .git/svn/)" ]` RspecProfiling::VCS::Svn unless $CHILD_STATUS.success? end def branch nil end def sha if version_control.nil? `git svn info | grep "Revision" | cut -f2 -d' '` else `svn info -r 'HEAD' | grep "Revision" | cut -f2 -d' '` end end def time if version_control.nil? Time.parse `git svn info | grep "Last Changed Date" | cut -f4,5,6 -d' '` else Time.parse `svn info -r 'HEAD' | grep "Last Changed Date" | cut -f4,5,6 -d' '` end end end end end ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������rspec_profiling-0.0.9/lib/rspec_profiling/vcs/git.rb������������������������������������������������0000644�0000041�0000041�00000000457�14620237543�022607� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������require 'time' module RspecProfiling module VCS class Git def branch `git rev-parse --abbrev-ref HEAD`.chomp end def sha `git rev-parse HEAD`.chomp end def time Time.parse `git show -s --format=%ci #{sha}`.chomp end end end end �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������rspec_profiling-0.0.9/lib/rspec_profiling/vcs/svn.rb������������������������������������������������0000644�0000041�0000041�00000000503�14620237543�022622� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������require 'time' module RspecProfiling module VCS class Svn def branch nil end def sha `svn info -r 'HEAD' | grep "Revision" | cut -f2 -d' '` end def time Time.parse `svn info -r 'HEAD' | grep "Last Changed Date" | cut -f4,5,6 -d' '` end end end end ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������rspec_profiling-0.0.9/lib/rspec_profiling/example.rb������������������������������������������������0000644�0000041�0000041�00000006555�14620237543�022671� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������require "benchmark" require "rspec_profiling/vcs/git" require "rspec_profiling/vcs/svn" require "rspec_profiling/vcs/git_svn" require "rspec_profiling/collectors/csv" require "rspec_profiling/collectors/json" module RspecProfiling class Example IGNORED_QUERIES_PATTERN = %r{( pg_table| pg_attribute| pg_namespace| show\stables| pragma| sqlite_master/rollback| ^TRUNCATE TABLE| ^ALTER TABLE| ^BEGIN| ^COMMIT| ^ROLLBACK| ^RELEASE| ^SAVEPOINT )}xi def initialize(example) @example = example @counts = Hash.new(0) @event_counts = Hash.new(0) @event_times = Hash.new(0) @event_events = Hash.new() end def file metadata[:file_path] end def line_number metadata[:line_number] end def description metadata[:full_description] end def status execution_result.status end def exception execution_result.exception end def time execution_result.run_time end def owner_tag ownership_for_file(metadata[:file_path]) end def query_count counts[:query_count] end def query_time counts[:query_time] end def request_count counts[:request_count] end def request_time counts[:request_time] end attr_reader :event_counts, :event_times, :event_events def log_query(query, start, finish) unless query[:sql] =~ IGNORED_QUERIES_PATTERN counts[:query_count] += 1 counts[:query_time] += (finish - start) end end def log_request(request, start, finish) counts[:request_count] += 1 counts[:request_time] += request[:view_runtime].to_f end def log_event(event_name, event, start, finish) event_counts[event_name] += 1 event_times[event_name] += (finish - start) event_events[event_name] ||= [] if verbose_record_event?(event_name) begin event_events[event_name] << event.as_json rescue => e # no op end end end private attr_reader :example, :counts def execution_result @execution_result ||= begin result = example.execution_result result = OpenStruct.new(result) if result.is_a?(Hash) result end end def metadata example.metadata end def verbose_record_event?(event_name) metadata[:record_events].to_a.include?(event_name) end def ownership_for_file(file_path) return nil if RspecProfiling.config.magic_comment.empty? ownership_regex = /(^#\s*#{RspecProfiling.config.magic_comment}:\s*)\K(?<#{RspecProfiling.config.magic_comment}>.*$)/.freeze comments = top_comments_from_file(file_path) matching_line = comments.detect { |line| line.match?(ownership_regex) } extract_ownership(matching_line, ownership_regex) if matching_line end def top_comments_from_file(file_path) with_file(file_path) do |f| f.take_while { |line| line.start_with?('#', "\n") } end end def with_file(file_path) if File.exist?(file_path) File.open(file_path) else puts "File not found: #{file_path}" [] end end def extract_ownership(matching_line, regex) matching_line.match(regex)[RspecProfiling.config.magic_comment.to_sym] end end end ���������������������������������������������������������������������������������������������������������������������������������������������������rspec_profiling-0.0.9/lib/rspec_profiling/version.rb������������������������������������������������0000644�0000041�0000041�00000000056�14620237543�022711� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������module RspecProfiling VERSION = "0.0.9" end ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������rspec_profiling-0.0.9/lib/rspec_profiling/console.rb������������������������������������������������0000644�0000041�0000041�00000000113�14620237543�022660� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������def results @results ||= RspecProfiling.config.collector.new.results end �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������rspec_profiling-0.0.9/lib/rspec_profiling/collectors/�����������������������������������������������0000755�0000041�0000041�00000000000�14620237543�023047� 5����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������rspec_profiling-0.0.9/lib/rspec_profiling/collectors/sql.rb�����������������������������������������0000644�0000041�0000041�00000004303�14620237543�024173� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������require "sqlite3" require "active_record" module RspecProfiling module Collectors class SQL def self.install new.install end def self.uninstall new.uninstall end def self.reset new.results.destroy_all end def initialize RspecProfiling.config.db_path ||= 'tmp/rspec_profiling' establish_connection end def install return if prepared? connection.create_table(table) do |t| t.string :branch, index: true t.string :commit_hash, index: true t.datetime :date, index: true t.text :file, index: true t.integer :line_number, index: true t.text :description t.decimal :time, index: true t.string :status, index: true t.text :exception t.integer :query_count, index: true t.decimal :query_time, index:true t.integer :request_count, index: true t.decimal :request_time, index: true t.timestamps null: true end end def uninstall connection.drop_table(table) end def insert(attributes) results.create!(attributes.except(:created_at, :events, :event_counts, :event_times, :event_events)) end def results @results ||= begin establish_connection Result.table_name = table Result.attr_protected if Result.respond_to?(:attr_protected) Result end end private def prepared? connection.table_exists?(table) end def connection @connection ||= results.connection end def establish_connection Result.establish_connection( :adapter => 'sqlite3', :database => database ) end def table RspecProfiling.config.table_name end def database RspecProfiling.config.db_path end class Result < ActiveRecord::Base def to_s [description, location].join(" - ") end private def location [file, line_number].join(":") end end end end end �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������rspec_profiling-0.0.9/lib/rspec_profiling/collectors/psql.rb����������������������������������������0000644�0000041�0000041�00000005047�14620237543�024361� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������require "pg" require "active_record" module RspecProfiling module Collectors class PSQL def self.install new.install end def self.uninstall new.uninstall end def self.reset new.results.destroy_all end def initialize RspecProfiling.config.db_path ||= 'rspec_profiling' establish_connection end def install return if prepared? connection.create_table(table) do |t| t.string :branch, index: true t.string :commit_hash, index: true t.datetime :date, index: true t.text :file, index: true t.integer :line_number, index: true t.text :description t.decimal :time, index: true t.string :status, index: true t.text :exception t.integer :query_count, index: true t.decimal :query_time, index:true t.integer :request_count, index: true t.decimal :request_time, index: true t.timestamps null: true end end def uninstall connection.drop_table(table) end def insert(attributes) results.create!(attributes.except(:created_at, :events, :event_counts, :event_times, :event_events)) end def results @results ||= begin establish_connection Result.table_name = table Result.attr_protected if Result.respond_to?(:attr_protected) Result end end private def prepared? if active_record5_or_up? connection.data_source_exists?(table) else connection.table_exists?(table) end end def active_record5_or_up? ActiveRecord::VERSION::STRING[0].to_i >= 5 end def connection @connection ||= results.connection end def establish_connection begin PG.connect(dbname: 'postgres').exec("CREATE DATABASE #{database}") rescue PG::DuplicateDatabase # no op end Result.establish_connection( :adapter => 'postgresql', :database => database ) end def table RspecProfiling.config.table_name end def database RspecProfiling.config.db_path end class Result < ActiveRecord::Base def to_s [description, location].join(" - ") end private def location [file, line_number].join(":") end end end end end �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������rspec_profiling-0.0.9/lib/rspec_profiling/collectors/json.rb����������������������������������������0000644�0000041�0000041�00000002663�14620237543�024354� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������module RspecProfiling module Collectors class JSON KEYS = %w{ branch commit_hash seed date file line_number owner_tag description status exception time query_count query_time request_count request_time start_memory end_memory } def self.install # no op end def self.uninstall # no op end def self.reset # no op end def initialize(config=RspecProfiling.config) config.output_file_path ||= 'tmp/spec_benchmarks.json' @config = config end def insert(attributes) output << merge_attributes_and_events(attributes) + "\n" end private attr_reader :config def output @output ||= ::File.open(path, "w") end def path config.output_file_path.call end def merge_attributes_and_events(attributes) config.events.flat_map do |event| attributes["#{event}_counts"] = attributes[:event_counts][event] attributes["#{event}_times"] = attributes[:event_times][event] attributes["#{event}_events"] = attributes[:event_events][event] end attributes.merge!(config.additional_data) attributes.except(:event_counts, :event_times, :event_events, :events).to_json end end end end �����������������������������������������������������������������������������rspec_profiling-0.0.9/lib/rspec_profiling/collectors/csv.rb�����������������������������������������0000644�0000041�0000041�00000002775�14620237543�024202� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������require "csv" module RspecProfiling module Collectors class CSV HEADERS = %w{ branch commit_hash seed date file line_number owner_tag description status exception time query_count query_time request_count request_time start_memory end_memory } def self.install # no op end def self.uninstall # no op end def self.reset # no op end def initialize(config=RspecProfiling.config) config.csv_path ||= 'tmp/spec_benchmarks.csv' @config = config end def insert(attributes) output << static_cells(attributes) + event_cells(attributes) end private attr_reader :config def output @output ||= ::CSV.open(path, "w").tap { |csv| csv << HEADERS + event_headers } end def path config.csv_path.call end def static_cells(attributes) HEADERS.map do |field| attributes.fetch(field.to_sym) end end def event_headers config.events.flat_map do |event| ["#{event}_count", "#{event}_time", "#{event}_events"] end end def event_cells(attributes) config.events.flat_map do |event| [attributes[:event_counts][event], attributes[:event_times][event], attributes[:event_events][event].to_json] end end end end end ���rspec_profiling-0.0.9/Rakefile����������������������������������������������������������������������0000644�0000041�0000041�00000000107�14620237543�016406� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������require "bundler/gem_tasks" import "./lib/tasks/rspec_profiling.rake" ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������rspec_profiling-0.0.9/CODE_OF_CONDUCT.md������������������������������������������������������������0000644�0000041�0000041�00000012324�14620237543�017544� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������# Code of Conduct ## Our Pledge We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. ## Our Standards Examples of behavior that contributes to a positive environment for our community include: * Demonstrating empathy and kindness toward other people * Being respectful of differing opinions, viewpoints, and experiences * Giving and gracefully accepting constructive feedback * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience * Focusing on what is best not just for us as individuals, but for the overall community Examples of unacceptable behavior include: * The use of sexualized language or imagery, and sexual attention or advances of any kind * Trolling, insulting or derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or email address, without their explicit permission * Spam or other deceptive practices that take advantage of the community * Other conduct which could reasonably be considered inappropriate in a professional setting ## Enforcement Responsibilities Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. ## Scope This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at <opensource@procore.com>. All complaints will be reviewed and investigated promptly and fairly by the Procore Open Source Program Office (OSPO) All community leaders are obligated to respect the privacy and security of the reporter of any incident. ## Enforcement Guidelines Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: ### 1. Correction **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. ### 2. Warning **Community Impact**: A violation through a single incident or series of actions. **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. ### 3. Temporary Ban **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. ### 4. Permanent Ban **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. **Consequence**: A permanent ban from any sort of public interaction within the community. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, available at <https://www.contributor-covenant.org/version/2/0/code_of_conduct.html>. Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity). [homepage]: https://www.contributor-covenant.org For answers to common questions about this code of conduct, see the FAQ at <https://www.contributor-covenant.org/faq>. Translations are available at <https://www.contributor-covenant.org/translations>. ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������rspec_profiling-0.0.9/LICENSE.md��������������������������������������������������������������������0000644�0000041�0000041�00000002134�14620237543�016347� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������Copyright (c) 2014-2024 Ben Eddy Copyright (c) 2024 Procore Technologies, Inc. MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������rspec_profiling-0.0.9/Gemfile�����������������������������������������������������������������������0000644�0000041�0000041�00000000144�14620237543�016235� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������source 'https://rubygems.org' # Specify your gem's dependencies in rspec_profiling.gemspec gemspec ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������rspec_profiling-0.0.9/docker-compose.yml������������������������������������������������������������0000644�0000041�0000041�00000000422�14620237543�020376� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������version: '3.9' services: postgres: image: postgres:16-alpine ports: - 5432:5432 volumes: - ~/apps/postgres:/var/lib/postgresql/data environment: - POSTGRES_HOST=localhost - POSTGRES_USER=myuser - POSTGRES_PASSWORD=mypassword ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������rspec_profiling-0.0.9/README.md���������������������������������������������������������������������0000644�0000041�0000041�00000014332�14620237543�016225� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������# RspecProfiling [![Test](https://github.com/procore-oss/rspec_profiling/actions/workflows/test.yaml/badge.svg?branch=main)](https://github.com/procore-oss/rspec_profiling/actions/workflows/test.yaml) [![Gem Version](https://badge.fury.io/rb/rspec_profiling.svg)](https://badge.fury.io/rb/rspec_profiling) [![Discord](https://img.shields.io/badge/Chat-EDEDED?logo=discord)](https://discord.gg/PbntEMmWws) Collects profiles of RSpec test suites, enabling you to identify specs with interesting attributes. For example, find the slowest specs, or the spec which issues the most queries. Collected attributes include: - git commit SHA (or SVN revision) and date - example file, line number and description - example status (i.e. passed or failed) - example exception (i.e. nil if passed, reason for failure otherwise) - example time - query count and time - request count and time ## Compatibility RspecProfiling should work with Rails >= 3.2 and RSpec >= 2.14. ## Installation Add this line to your application's Gemfile: ```ruby gem 'rspec_profiling' ``` And then execute: ```bash bundle ``` Require the gem to your `spec_helper.rb`. ```ruby require "rspec_profiling/rspec" ``` Lastly, run the installation rake tasks to initialize an empty database in which results will be collected. ```bash bundle exec rake rspec_profiling:install ``` If you are planning on using `sqlite` or `pg` ensure to add the dependency to your gemfile ```ruby gem 'sqlite', require: false gem 'pg', require: false ``` ## Usage ### Choose a version control system Results are collected based on the version control system employed e.g. revision or commit SHA for `svn` and `git` respectively. #### Git By default, RspecProfiling expects Git as the version control system. #### Subversion RspecProfiling can be configured to use `svn` in `config/initializers/rspec_profiling.rb`: ```Ruby RspecProfiling.configure do |config| config.vcs = RspecProfiling::VCS::Svn end ``` #### Git / Subversion For those with a mixed project, with some developers using `git svn` and others regular `svn`, use this configuration to detect which is being used locally and behave accordingly. ```Ruby RspecProfiling.configure do |config| config.vcs = RspecProfiling::VCS::GitSvn end ``` #### Custom Ownership Tracking If the repo you are running the profiler on has many teams working on it, you can use the `magic_comment` option to specify a comment at the top of files to scan for ownership tracking. In the example below, the profiler will look for `#team: <owner>` comments at the top of each file and add <owner> to the results. The default is `team` but can be configured to any comment you want. ```Ruby RspecProfiling.configure do |config| config.magic_comment = 'team' end ``` #### Custom Event Subscriptions ```Ruby RspecProfiling.configure do |config| config.events = %w[event1 event2] end ``` Note that custom events are only currently reported by the CSV collector. #### Custom Event Recording It is possible to record the event metadata for a spec. ```Ruby describe 'Records all active record queries', record_events: %w[sql.active_record] do it 'Records Rails deprecations', record_events: %w[deprecation.rails] do ... end it 'Records nothing' do ... end end ``` ### Choose a results collector Results are collected just by running the specs. #### SQLite3 Make sure you've run the installation rake task before attempting. You can configure `RspecProfiling` to collect results in a SQL database in `config/initializers/rspec_profiling.rb`: ```Ruby RspecProfiling.configure do |config| config.collector = RspecProfiling::Collectors::SQL end ``` You can review results by running the RspecProfiling console. The console has a preloaded `results` variable. ```bash bundle exec rake rspec_profiling:console > results.count => 1970 ``` You can find the spec that runs the most queries: ```ruby > results.order(:query_count).last.to_s => "Updating my account - ./spec/features/account_spec.rb:15" ``` Or find the spec that takes the most time: ```ruby > results.order(:time).last.to_s => "Updating my account - ./spec/features/account_spec.rb:15" ``` There are additional attributes available on the `Result` instances to enable debugging, such as `exception` and `status`. #### CSV By default, profiles are collected in an a CSV file. You can configure `RspecProfiling` to collect results in a CSV in `config/initializers/rspec_profiling.rb`: ```Ruby RspecProfiling.configure do |config| config.collector = RspecProfiling::Collectors::CSV end ``` By default, the CSV is output to `cat tmp/spec_benchmarks.csv`. Rerunning spec will overwrite the file. You can customize the CSV path to, for example, include the sample time. ```Ruby RspecProfiling.configure do |config| config.collector = RspecProfiling::Collectors::CSV config.csv_path = ->{ "tmp/spec_benchmark_#{Time.now.to_i}" } end ``` #### Postgresql You can configure `RspecProfiling` to collect results in a Postgres database in your `spec_helper.rb` file. ```Ruby RspecProfiling.configure do |config| config.collector = RspecProfiling::Collectors::PSQL config.db_path = 'profiling' end ``` ## Configuration Options Configuration is performed like this: ```Ruby RspecProfiling.configure do |config| config.<option> = <something> end ``` ### Options - `db_path` - the location of the SQLite database file - `table_name` - the database table name in which results are stored - `csv_path` - the directory in which CSV files are dumped - `collector` - collector to use - `magic_comment` - comment to scan top of files to enable ownership tracking (EX: `#team: tooling`) ### Usage in a script If you want to access the results from a Ruby script instead of the `rake rspec_profiling:console` shell command: ```ruby require 'rspec_profiling' require 'rspec_profiling/console' ``` Then `results` will be available as a variable to the script. ## Uninstalling To remove the results database, run `bundle exec rake rspec_profiling:uninstall`. ## Contributing Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us. ## Local Development Local tools needed: - docker - docker-compose - ruby To run the specs: ```bash make spec ``` ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������rspec_profiling-0.0.9/.ruby-version�����������������������������������������������������������������0000644�0000041�0000041�00000000011�14620237543�017400� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ruby-3.3 �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������rspec_profiling-0.0.9/EMERITUS.md�������������������������������������������������������������������0000644�0000041�0000041�00000000234�14620237543�016521� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������This repo is a fork of <https://github.com/foraker/rspec_profiling>. [Former contributors](https://github.com/foraker/rspec_profiling/graphs/contributors) ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������rspec_profiling-0.0.9/CHANGELOG.md������������������������������������������������������������������0000644�0000041�0000041�00000001055�14620237543�016555� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������## 0.0.9 * feat: Add support for ownership tagging via magic comment [#10] * chore: simplify release Github Action [#9] ## 0.0.8 * chore: add badges to README and add gemspec metadata [#6] * chore: setup local development [#3] * chore: upgrade ruby [#4] * chore: standardize repository for procore open-source[#2] ## 0.0.7 * Migrate to procore-oss/rspec_profiling repo [#1] ## 0.0.6 * Create indexes for DB collectors [#26] * Use ActiveRecord v5 data_source_exists? if in use [#25] * Strip newlines and other whitespace in Git output [#24] ## 0.0.5 �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������rspec_profiling-0.0.9/rspec_profiling.gemspec�������������������������������������������������������0000644�0000041�0000041�00000002522�14620237543�021476� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'rspec_profiling/version' Gem::Specification.new do |spec| spec.name = "rspec_profiling" spec.version = RspecProfiling::VERSION spec.authors = ["Procore Technologies, Inc."] spec.email = ["opensource@procore.com"] spec.description = %q{Profile RSpec test suites} spec.summary = %q{Profile RSpec test suites} spec.homepage = "https://github.com/procore-oss/rspec_profiling" spec.license = "MIT" spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] spec.add_dependency "activerecord" spec.add_dependency "get_process_mem" spec.add_dependency "rails" spec.add_development_dependency "bundler", "> 1.3" spec.add_development_dependency "pry" spec.add_development_dependency "rake" spec.add_development_dependency "rspec" spec.metadata['allowed_push_host'] = 'https://rubygems.org' spec.metadata['rubygems_mfa_required'] = 'true' spec.metadata['homepage_uri'] = spec.homepage spec.metadata['source_code_uri'] = spec.homepage end ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������rspec_profiling-0.0.9/Makefile����������������������������������������������������������������������0000644�0000041�0000041�00000003367�14620237543�016414� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -e says exit immediately when a command fails # -o sets pipefail, meaning if it exits with a failing command, the exit code should be of the failing command # -u fails a bash script immediately if a variable is unset ENVIRONMENT := test PGHOST := localhost PGPORT := 5432 PGUSER := myuser PGPASSWORD := mypassword SHELL = /bin/bash -eu -o pipefail define is_installed if ! command -v $(1) &> /dev/null; \ then \ echo "$(1) not installed, please install it. 'brew install $(1)'"; \ exit; \ fi; endef .PHONY : help help : # Display help @awk -F ':|##' \ '/^[^\t].+?:.*?##/ {\ printf "\033[36m%-30s\033[0m %s\n", $$1, $$NF \ }' $(MAKEFILE_LIST) .PHONY : ruby_installed ruby_installed: ## check if ruby is installed @$(call is_installed,ruby) .PHONY : bundle bundle: ruby_installed ## install gems @bundle install --gemfile spec/Gemfile && cd spec/dummy && bundle install .PHONY : setup_db setup_db: ruby_installed postgres ## setup database @echo "setting up database" @cd spec/dummy && bundle exec rake db:create db:migrate --trace RAILS_ENV=${ENVIRONMENT} .PHONY : initialize_profiling initialize_profiling: ruby_installed ## initialize rspec_profiling @echo "initializing rspec_profiling" @cd spec/dummy && bundle exec rake rspec_profiling:install RAILS_ENV=${ENVIRONMENT} .PHONY : spec spec : bundle setup_db initialize_profiling ## run specs @echo "running specs" @bundle exec --gemfile=spec/dummy/Gemfile rspec .PHONY : test test: spec ## run specs @echo "running specs" .PHONY : docker_installed docker_installed: ## check if docker and docker-compose are installed @$(call is_installed,docker) @$(call is_installed,docker-compose) .PHONY : postgres postgres: docker_installed ## start postgres in docker container @docker-compose up -d || true ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������