rails_tia 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +180 -0
- data/docs/configuration.md +109 -0
- data/docs/github-actions.md +147 -0
- data/exe/rails-tia +5 -0
- data/ext/rails_tia/allocated_classes.c +111 -0
- data/ext/rails_tia/extconf.rb +7 -0
- data/lib/rails_tia/action_view_support.rb +67 -0
- data/lib/rails_tia/audit.rb +42 -0
- data/lib/rails_tia/boot.rb +12 -0
- data/lib/rails_tia/ci/base.rb +38 -0
- data/lib/rails_tia/ci/git.rb +49 -0
- data/lib/rails_tia/ci/github_actions.rb +237 -0
- data/lib/rails_tia/ci/gitlab.rb +199 -0
- data/lib/rails_tia/ci.rb +36 -0
- data/lib/rails_tia/cli.rb +328 -0
- data/lib/rails_tia/configuration.rb +169 -0
- data/lib/rails_tia/constant_reads.rb +84 -0
- data/lib/rails_tia/context.rb +17 -0
- data/lib/rails_tia/coverage_collector.rb +198 -0
- data/lib/rails_tia/described_class_support.rb +75 -0
- data/lib/rails_tia/fallback.rb +79 -0
- data/lib/rails_tia/formatter.rb +88 -0
- data/lib/rails_tia/http.rb +89 -0
- data/lib/rails_tia/junit_report.rb +116 -0
- data/lib/rails_tia/map.rb +178 -0
- data/lib/rails_tia/metrics.rb +71 -0
- data/lib/rails_tia/minitest.rb +243 -0
- data/lib/rails_tia/native_extension.rb +6 -0
- data/lib/rails_tia/object_allocations.rb +23 -0
- data/lib/rails_tia/predictor.rb +61 -0
- data/lib/rails_tia/rails_support.rb +86 -0
- data/lib/rails_tia/run_report.rb +116 -0
- data/lib/rails_tia/static_mapping.rb +85 -0
- data/lib/rails_tia/templates/minitest.yml +39 -0
- data/lib/rails_tia/templates/rspec.yml +45 -0
- data/lib/rails_tia/version.rb +3 -0
- data/lib/rails_tia.rb +27 -0
- data/skills/rails-tia/SKILL.md +49 -0
- metadata +145 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
require 'digest'
|
|
2
|
+
require 'fileutils'
|
|
3
|
+
require 'json'
|
|
4
|
+
require 'securerandom'
|
|
5
|
+
require 'tempfile'
|
|
6
|
+
require 'time'
|
|
7
|
+
require 'zlib'
|
|
8
|
+
|
|
9
|
+
module RailsTia
|
|
10
|
+
class RunReport
|
|
11
|
+
SCHEMA_VERSION = 1
|
|
12
|
+
class Error < StandardError; end
|
|
13
|
+
|
|
14
|
+
def self.for(type, config)
|
|
15
|
+
path = ENV['RAILS_TIA_REPORT_DIR']
|
|
16
|
+
new(type, config.absolute(path)) unless path.to_s.empty?
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.load_selection(path)
|
|
20
|
+
data = JSON.parse(File.read(path))
|
|
21
|
+
valid = data.is_a?(Hash) && data['schema_version'] == SCHEMA_VERSION && data['type'] == 'select' &&
|
|
22
|
+
data['report_id'].is_a?(String) && !data['report_id'].empty? &&
|
|
23
|
+
[true, false].include?(data['full_run']) &&
|
|
24
|
+
data['selected_specs'].is_a?(Array) && data['selected_specs'].all?(String)
|
|
25
|
+
raise Error, "Invalid selection report: #{path}" unless valid
|
|
26
|
+
|
|
27
|
+
data
|
|
28
|
+
rescue JSON::ParserError => e
|
|
29
|
+
raise Error, "Invalid selection report: #{path}: #{e.message}"
|
|
30
|
+
rescue SystemCallError, IOError => e
|
|
31
|
+
raise Error, "Cannot read selection report #{path}: #{e.message}"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def initialize(type, directory)
|
|
35
|
+
@type = type
|
|
36
|
+
@directory = directory
|
|
37
|
+
@timings = Hash.new(0.0)
|
|
38
|
+
@id = SecureRandom.uuid
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
attr_reader :timings
|
|
42
|
+
|
|
43
|
+
def measure(key)
|
|
44
|
+
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
45
|
+
result = yield
|
|
46
|
+
@timings[key] += Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
|
|
47
|
+
result
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def merge_map(fragments, path)
|
|
51
|
+
fragment_ids = []
|
|
52
|
+
map = measure(:merge) do
|
|
53
|
+
Map.merge_files(fragments) { |json| fragment_ids << Digest::SHA256.hexdigest(json) }
|
|
54
|
+
end
|
|
55
|
+
json = nil
|
|
56
|
+
measure(:write_map) { map.dump(path) { |serialized| json = serialized } }
|
|
57
|
+
write do
|
|
58
|
+
counts = map.sources.to_h { |source| [source, map.specs_for(source).size] }
|
|
59
|
+
{
|
|
60
|
+
map_id: measure(:archive_map) { archive_map(json) }, map_commit_sha: map.commit_sha,
|
|
61
|
+
generated_at: map.generated_at&.utc&.iso8601,
|
|
62
|
+
fragment_ids: fragment_ids, fragment_count: fragments.size, spec_count: map.specs.size,
|
|
63
|
+
source_count: counts.size, edge_count: counts.values.sum,
|
|
64
|
+
top_sources: counts.sort_by { |source, count| [-count, source] }.first(10).to_h,
|
|
65
|
+
}
|
|
66
|
+
end
|
|
67
|
+
map
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def write
|
|
71
|
+
path = File.join(@directory, "#{@type}-#{@id}.json")
|
|
72
|
+
data = {
|
|
73
|
+
schema_version: SCHEMA_VERSION, type: @type, report_id: @id, recorded_at: Time.now.utc.iso8601(6),
|
|
74
|
+
rails_tia_version: VERSION, commit_sha: RailsTia.commit_sha,
|
|
75
|
+
repository: ENV['GITHUB_REPOSITORY'] || ENV['CI_PROJECT_PATH'],
|
|
76
|
+
run_id: ENV['GITHUB_RUN_ID'] || ENV['CI_PIPELINE_ID'], attempt: ENV['GITHUB_RUN_ATTEMPT'],
|
|
77
|
+
job: ENV['GITHUB_JOB'] || ENV['CI_JOB_NAME'], job_id: ENV['CI_JOB_ID'],
|
|
78
|
+
node: ENV['CI_NODE_INDEX'], worker: ENV['TEST_ENV_NUMBER'], pid: Process.pid,
|
|
79
|
+
}.merge(yield)
|
|
80
|
+
data[:timings_seconds] = @timings unless @timings.empty?
|
|
81
|
+
publish(path) { |file| file.write(JSON.generate(data)) }
|
|
82
|
+
path
|
|
83
|
+
rescue SystemCallError, IOError, Zlib::Error, JSON::GeneratorError, EncodingError => e
|
|
84
|
+
warn "[rails_tia] Cannot save run report #{path}: #{e.message}"
|
|
85
|
+
nil
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
private
|
|
89
|
+
|
|
90
|
+
def archive_map(json)
|
|
91
|
+
id = Digest::SHA256.hexdigest(json)
|
|
92
|
+
path = File.join(@directory, 'maps', "#{id}.json.gz")
|
|
93
|
+
unless File.exist?(path)
|
|
94
|
+
publish(path) do |file|
|
|
95
|
+
gzip = Zlib::GzipWriter.new(file)
|
|
96
|
+
gzip.mtime = 0
|
|
97
|
+
gzip.write(json)
|
|
98
|
+
gzip.finish
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
id
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def publish(path)
|
|
105
|
+
dir = File.dirname(path)
|
|
106
|
+
FileUtils.mkdir_p(dir)
|
|
107
|
+
Tempfile.create('.rails-tia-', dir) do |file|
|
|
108
|
+
file.binmode
|
|
109
|
+
yield file
|
|
110
|
+
file.chmod(0o644 & ~File.umask)
|
|
111
|
+
file.close
|
|
112
|
+
File.rename(file.path, path)
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
module RailsTia
|
|
2
|
+
# Map source files to specs using naming conventions.
|
|
3
|
+
#
|
|
4
|
+
# Supplement coverage dependencies in three cases:
|
|
5
|
+
# - Newly added files absent from the map.
|
|
6
|
+
# - Files without executable method bodies, including those missed by ActiveRecord notifications.
|
|
7
|
+
# - Templates such as HAML that do not appear in coverage.
|
|
8
|
+
#
|
|
9
|
+
# Rules map a source regex to path templates or fixed globs. Captures replace %s in templates.
|
|
10
|
+
# Discard nonexistent targets, naturally excluding mismatches caused by typos or singular/plural naming.
|
|
11
|
+
class StaticMapping
|
|
12
|
+
class InvalidGlob < StandardError; end
|
|
13
|
+
|
|
14
|
+
Rule = Struct.new(:pattern, :templates, :globs, keyword_init: true)
|
|
15
|
+
|
|
16
|
+
def initialize(rules, root: Dir.pwd)
|
|
17
|
+
@root = root
|
|
18
|
+
@rules = Array(rules).map do |rule|
|
|
19
|
+
raise KeyError, 'static_mapping requires test or test_glob' unless rule.key?('test') || rule.key?('test_glob')
|
|
20
|
+
|
|
21
|
+
globs = Array(rule['test_glob'])
|
|
22
|
+
globs.each { |glob| validate_relative_glob!(glob) }
|
|
23
|
+
Rule.new(
|
|
24
|
+
pattern: Regexp.new("\\A(?:#{Array(rule.fetch('source')).join('|')})\\z"),
|
|
25
|
+
templates: Array(rule['test']),
|
|
26
|
+
globs: globs,
|
|
27
|
+
)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def call(paths)
|
|
32
|
+
glob_cache = {}
|
|
33
|
+
candidates = paths.flat_map { |path| candidates_for(path, glob_cache: glob_cache) }
|
|
34
|
+
candidates.uniq.select { |spec| File.exist?(File.join(@root, spec)) }
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def specs_for(path)
|
|
38
|
+
call([path])
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def candidates_for(path, glob_cache: {})
|
|
42
|
+
@rules.flat_map do |rule|
|
|
43
|
+
match = rule.pattern.match(path)
|
|
44
|
+
next [] if match.nil?
|
|
45
|
+
|
|
46
|
+
paths = rule.templates.filter_map { |template| format_template(template, match.captures) }
|
|
47
|
+
rule.globs.each do |glob|
|
|
48
|
+
glob_cache[glob] ||= glob_specs(glob)
|
|
49
|
+
paths.concat(glob_cache[glob])
|
|
50
|
+
end
|
|
51
|
+
paths
|
|
52
|
+
end.uniq
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
private
|
|
56
|
+
|
|
57
|
+
def validate_relative_glob!(glob)
|
|
58
|
+
return if glob.is_a?(String) && !File.absolute_path?(glob) && !glob.split('/').include?('..')
|
|
59
|
+
|
|
60
|
+
raise InvalidGlob, "test_glob must be relative to the project root without '..' components: #{glob.inspect}"
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def glob_specs(glob)
|
|
64
|
+
root = File.realpath(@root)
|
|
65
|
+
prefix = File.join(root, '')
|
|
66
|
+
Dir.glob(glob, base: root).select do |spec|
|
|
67
|
+
# Brace alternatives can expand into parent or absolute paths.
|
|
68
|
+
validate_relative_glob!(spec)
|
|
69
|
+
path = File.join(root, spec)
|
|
70
|
+
File.file?(path) && File.realpath(path).start_with?(prefix)
|
|
71
|
+
rescue Errno::ENOENT, Errno::ENOTDIR
|
|
72
|
+
false
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Ignore a rule if its number of %s placeholders does not match the capture count.
|
|
77
|
+
# A typo in one rule should not prevent the rest of the prediction from completing.
|
|
78
|
+
def format_template(template, captures)
|
|
79
|
+
format(template, *captures)
|
|
80
|
+
rescue ArgumentError, TypeError
|
|
81
|
+
warn "[rails_tia] static_mapping template placeholders do not match capture groups: #{template.inspect} <- #{captures.inspect}"
|
|
82
|
+
nil
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
spec_glob: 'test/**/*_test.rb'
|
|
2
|
+
full_run_token: 'test/'
|
|
3
|
+
|
|
4
|
+
full_run:
|
|
5
|
+
paths:
|
|
6
|
+
# Generated configuration path
|
|
7
|
+
- .ruby-version
|
|
8
|
+
- Gemfile
|
|
9
|
+
- Gemfile.lock
|
|
10
|
+
- config/**/*
|
|
11
|
+
- db/**/*
|
|
12
|
+
- app/views/layouts/**/*
|
|
13
|
+
- app/views/shared/**/*
|
|
14
|
+
- test/test_helper.rb
|
|
15
|
+
- test/test_helpers/**/*
|
|
16
|
+
- test/application_system_test_case.rb
|
|
17
|
+
- test/support/**/*
|
|
18
|
+
- test/factories.rb
|
|
19
|
+
- test/factories/**/*
|
|
20
|
+
- test/fixtures/**/*
|
|
21
|
+
- .github/workflows/**/*
|
|
22
|
+
- .gitlab-ci.yml
|
|
23
|
+
|
|
24
|
+
static_mapping:
|
|
25
|
+
- source: 'app/(.+)\.rb'
|
|
26
|
+
test: 'test/%s_test.rb'
|
|
27
|
+
- source: 'lib/(.+)\.rb'
|
|
28
|
+
test: 'test/lib/%s_test.rb'
|
|
29
|
+
- source: 'app/controllers/(.+)_controller\.rb'
|
|
30
|
+
test: 'test/integration/%s_test.rb'
|
|
31
|
+
- source: 'app/views/(.+)/[^/]+'
|
|
32
|
+
test:
|
|
33
|
+
- 'test/controllers/%s_controller_test.rb'
|
|
34
|
+
- 'test/integration/%s_test.rb'
|
|
35
|
+
- source:
|
|
36
|
+
- 'app/(?:javascript|assets)/.+'
|
|
37
|
+
- 'vendor/javascript/.+'
|
|
38
|
+
- 'package\.json|package-lock\.json|yarn\.lock|pnpm-lock\.yaml|bun\.lockb?'
|
|
39
|
+
test_glob: 'test/system/**/*_test.rb'
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
full_run:
|
|
2
|
+
paths:
|
|
3
|
+
# Generated configuration path
|
|
4
|
+
- .rspec
|
|
5
|
+
- .ruby-version
|
|
6
|
+
- Gemfile
|
|
7
|
+
- Gemfile.lock
|
|
8
|
+
- config/**/*
|
|
9
|
+
- db/**/*
|
|
10
|
+
# New shared templates have no recorded consumers or matching request spec.
|
|
11
|
+
- app/views/layouts/**/*
|
|
12
|
+
- app/views/shared/**/*
|
|
13
|
+
- spec/spec_helper.rb
|
|
14
|
+
- spec/rails_helper.rb
|
|
15
|
+
- spec/support/**/*
|
|
16
|
+
- spec/factories.rb
|
|
17
|
+
- spec/factories/**/*
|
|
18
|
+
- spec/fixtures/**/*
|
|
19
|
+
- .github/workflows/**/*
|
|
20
|
+
- .gitlab-ci.yml
|
|
21
|
+
|
|
22
|
+
# Naming conventions also cover new files that have no recorded dependencies yet.
|
|
23
|
+
static_mapping:
|
|
24
|
+
- source: 'app/(.+)\.rb'
|
|
25
|
+
test: 'spec/%s_spec.rb'
|
|
26
|
+
- source: 'lib/(.+)\.rb'
|
|
27
|
+
test: 'spec/lib/%s_spec.rb'
|
|
28
|
+
- source: 'app/controllers/(.+)_controller\.rb'
|
|
29
|
+
test:
|
|
30
|
+
- 'spec/requests/%s_spec.rb'
|
|
31
|
+
- 'spec/requests/%s_request_spec.rb'
|
|
32
|
+
- source: 'app/views/(.+)/[^/]+'
|
|
33
|
+
test:
|
|
34
|
+
- 'spec/requests/%s_spec.rb'
|
|
35
|
+
- 'spec/requests/%s_request_spec.rb'
|
|
36
|
+
- source: 'app/views/(.+)'
|
|
37
|
+
test: 'spec/views/%s_spec.rb'
|
|
38
|
+
# Browser-side dependencies are invisible to Ruby coverage.
|
|
39
|
+
- source:
|
|
40
|
+
- 'app/(?:javascript|assets)/.+'
|
|
41
|
+
- 'vendor/javascript/.+'
|
|
42
|
+
- 'package\.json|package-lock\.json|yarn\.lock|pnpm-lock\.yaml|bun\.lockb?'
|
|
43
|
+
test_glob:
|
|
44
|
+
- 'spec/system/**/*_spec.rb'
|
|
45
|
+
- 'spec/features/**/*_spec.rb'
|
data/lib/rails_tia.rb
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require 'rails_tia/version'
|
|
2
|
+
require 'rails_tia/configuration'
|
|
3
|
+
require 'rails_tia/context'
|
|
4
|
+
require 'rails_tia/map'
|
|
5
|
+
require 'rails_tia/static_mapping'
|
|
6
|
+
require 'rails_tia/fallback'
|
|
7
|
+
require 'rails_tia/predictor'
|
|
8
|
+
|
|
9
|
+
# Do not load these entry points here: the formatter requires rspec-core to be loaded,
|
|
10
|
+
# while boot must start Coverage as early as possible.
|
|
11
|
+
module RailsTia
|
|
12
|
+
class Error < StandardError; end
|
|
13
|
+
|
|
14
|
+
class << self
|
|
15
|
+
attr_writer :config
|
|
16
|
+
|
|
17
|
+
def config
|
|
18
|
+
@config ||= Configuration.load(ENV['RAILS_TIA_CONFIG'])
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Record the commit used to generate the map for freshness checks
|
|
22
|
+
# and for investigating missed predictions.
|
|
23
|
+
def commit_sha
|
|
24
|
+
ENV['CI_COMMIT_SHA'] || ENV['GITHUB_SHA']
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rails-tia
|
|
3
|
+
description: Use rails_tia in a Rails application to select or run RSpec or Minitest tests affected by a change, set up dependency map collection in CI, or diagnose an unexpected test selection.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Use rails_tia in a Rails application
|
|
7
|
+
|
|
8
|
+
Work from the application root. Check its test command, `.rails_tia.yml`, and existing CI jobs for the runner, map location, and full-run token. Find the installed gem directory with `bundle info rails_tia --path`. Its `README.md` contains runner commands and `docs/configuration.md` describes settings for that version.
|
|
9
|
+
|
|
10
|
+
## Select tests for a change
|
|
11
|
+
|
|
12
|
+
Run `bundle exec rails-tia select` with the input that matches the user's change.
|
|
13
|
+
|
|
14
|
+
- For a pull or merge request in configured CI, use the existing map fetch step before selection. The adapter supplies changed files and event metadata, including labels.
|
|
15
|
+
- For committed branch changes with the Git adapter, set `RAILS_TIA_DIFF_BASE` to the target ref (default `origin/master`). The comparison is `base...HEAD` and requires the merge base locally. Git reads a local map and cannot fetch one.
|
|
16
|
+
- For working-tree edits or a specified set of files, pass a newline-delimited list of project-relative paths to `bundle exec rails-tia select --changed-files-from FILE` (or `-` for stdin). For uncommitted work, include staged, unstaged, and relevant untracked files. Include deleted paths and both sides of renames. Explicit input bypasses the adapter, including label and commit-message overrides.
|
|
17
|
+
|
|
18
|
+
Keep stdout separate from stderr. Check the exit status before interpreting stdout. If selection or a required fetch fails, surface the error and stop. On success, interpret stdout as follows.
|
|
19
|
+
|
|
20
|
+
| Stdout | When asked to run tests |
|
|
21
|
+
| --- | --- |
|
|
22
|
+
| Empty | Skip the runner and report that no tests were selected. |
|
|
23
|
+
| A single configured `full_run_token` | Run the application's full suite. The RSpec preset emits `spec` and the Minitest preset emits `test/`. |
|
|
24
|
+
| Test paths | Pass each line as one argument to the runner, preserving spaces. Use `bundle exec rspec` or `bundle exec ruby bin/rails test` with those arguments. |
|
|
25
|
+
|
|
26
|
+
When asked which tests are affected, report the selection and any full-run reason from stderr.
|
|
27
|
+
|
|
28
|
+
## Set up map collection
|
|
29
|
+
|
|
30
|
+
For initial setup, add `rails_tia` to the test bundle, run `bundle install`, and generate a config with `bundle exec rails-tia init --runner rspec` or `--runner minitest`. Adapt existing configurations in place.
|
|
31
|
+
|
|
32
|
+
Collect from a full suite on the target branch, starting with an empty fragment directory. Load the collector before Rails and Bootsnap.
|
|
33
|
+
|
|
34
|
+
- RSpec: `bundle exec ruby -rrails_tia/boot -S rspec --require rails_tia/formatter --format RailsTia::Formatter`. If the project uses SimpleCov, start it with ordinary line coverage before loading `rails_tia/boot`.
|
|
35
|
+
- Minitest: `bundle exec ruby -rrails_tia/minitest bin/rails test test/`. Use one worker for thread-parallel suites. Disable SimpleCov during Minitest collection.
|
|
36
|
+
|
|
37
|
+
After all workers succeed, gather a distinct fragment from every node and process.
|
|
38
|
+
|
|
39
|
+
- **GitHub Actions.** Verify the complete set of fragments, run `bundle exec rails-tia map merge`, and publish the merged map. Set `ci.adapter` to `github_actions` and `ci.github_actions.map_workflow` to the producing workflow's filename or ID. Set `map_event` and `map_artifact_name` under `ci.github_actions` when they differ from `push` and `rails-tia-map`. The PR fetch step needs `GITHUB_TOKEN` with `actions: read`. Use checkout depth 2 for the PR merge commit or 0 for the PR head. The installed gem's `docs/github-actions.md` has a complete workflow.
|
|
40
|
+
- **GitLab.** Publish each job's fragments and configure the map ref, pipeline source, job name, and artifact path. Provide `RAILS_TIA_GITLAB_TOKEN` with `read_api` access in the MR job.
|
|
41
|
+
- **Local Git.** Merge the fragments and keep the map at `map.path`.
|
|
42
|
+
|
|
43
|
+
With the GitHub Actions or GitLab adapter, run `bundle exec rails-tia map fetch` before selection in the PR or MR job.
|
|
44
|
+
|
|
45
|
+
## Explain a selection
|
|
46
|
+
|
|
47
|
+
Use the selection summary on stderr and `bundle exec rails-tia doctor` to check discovery, configuration, map freshness, and the adapter. A missing or stale map requests a full run. On GitHub Actions, check that a successful map workflow produced an artifact for the exact commit used as the PR diff baseline. For a surprising subset, check the recorded dependencies, matching `static_mapping` rules, and changed test files. Use naming rules for new files with predictable tests and `full_run.paths` for changes with suite-wide effects.
|
|
48
|
+
|
|
49
|
+
To investigate missed failures, save the selection and compare it with JUnit XML from a **full suite on the same commit**. Run `bundle exec rails-tia audit --predicted specs.txt --junit DIR`. Gather XML from every shard, including failures, into a fresh directory. Use a repeated `--expect-junit FILE` for known shard outputs. A failing testcase needs a project-relative `file` attribute.
|
metadata
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: rails_tia
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Shinichi Maeshima
|
|
8
|
+
bindir: exe
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: rubydex
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - "~>"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: 0.4.4
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - "~>"
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: 0.4.4
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: prism
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '1.0'
|
|
33
|
+
- - "<"
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: '3'
|
|
36
|
+
type: :runtime
|
|
37
|
+
prerelease: false
|
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
39
|
+
requirements:
|
|
40
|
+
- - ">="
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: '1.0'
|
|
43
|
+
- - "<"
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: '3'
|
|
46
|
+
- !ruby/object:Gem::Dependency
|
|
47
|
+
name: rubyzip
|
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
|
49
|
+
requirements:
|
|
50
|
+
- - "~>"
|
|
51
|
+
- !ruby/object:Gem::Version
|
|
52
|
+
version: '3.0'
|
|
53
|
+
type: :runtime
|
|
54
|
+
prerelease: false
|
|
55
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
56
|
+
requirements:
|
|
57
|
+
- - "~>"
|
|
58
|
+
- !ruby/object:Gem::Version
|
|
59
|
+
version: '3.0'
|
|
60
|
+
- !ruby/object:Gem::Dependency
|
|
61
|
+
name: rexml
|
|
62
|
+
requirement: !ruby/object:Gem::Requirement
|
|
63
|
+
requirements:
|
|
64
|
+
- - "~>"
|
|
65
|
+
- !ruby/object:Gem::Version
|
|
66
|
+
version: '3.2'
|
|
67
|
+
type: :runtime
|
|
68
|
+
prerelease: false
|
|
69
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
70
|
+
requirements:
|
|
71
|
+
- - "~>"
|
|
72
|
+
- !ruby/object:Gem::Version
|
|
73
|
+
version: '3.2'
|
|
74
|
+
description: |
|
|
75
|
+
Build a dependency map from RSpec or Minitest coverage and select the test files
|
|
76
|
+
affected by changed files.
|
|
77
|
+
email: netwillnet@gmail.com
|
|
78
|
+
executables:
|
|
79
|
+
- rails-tia
|
|
80
|
+
extensions:
|
|
81
|
+
- ext/rails_tia/extconf.rb
|
|
82
|
+
extra_rdoc_files: []
|
|
83
|
+
files:
|
|
84
|
+
- LICENSE.txt
|
|
85
|
+
- README.md
|
|
86
|
+
- docs/configuration.md
|
|
87
|
+
- docs/github-actions.md
|
|
88
|
+
- exe/rails-tia
|
|
89
|
+
- ext/rails_tia/allocated_classes.c
|
|
90
|
+
- ext/rails_tia/extconf.rb
|
|
91
|
+
- lib/rails_tia.rb
|
|
92
|
+
- lib/rails_tia/action_view_support.rb
|
|
93
|
+
- lib/rails_tia/audit.rb
|
|
94
|
+
- lib/rails_tia/boot.rb
|
|
95
|
+
- lib/rails_tia/ci.rb
|
|
96
|
+
- lib/rails_tia/ci/base.rb
|
|
97
|
+
- lib/rails_tia/ci/git.rb
|
|
98
|
+
- lib/rails_tia/ci/github_actions.rb
|
|
99
|
+
- lib/rails_tia/ci/gitlab.rb
|
|
100
|
+
- lib/rails_tia/cli.rb
|
|
101
|
+
- lib/rails_tia/configuration.rb
|
|
102
|
+
- lib/rails_tia/constant_reads.rb
|
|
103
|
+
- lib/rails_tia/context.rb
|
|
104
|
+
- lib/rails_tia/coverage_collector.rb
|
|
105
|
+
- lib/rails_tia/described_class_support.rb
|
|
106
|
+
- lib/rails_tia/fallback.rb
|
|
107
|
+
- lib/rails_tia/formatter.rb
|
|
108
|
+
- lib/rails_tia/http.rb
|
|
109
|
+
- lib/rails_tia/junit_report.rb
|
|
110
|
+
- lib/rails_tia/map.rb
|
|
111
|
+
- lib/rails_tia/metrics.rb
|
|
112
|
+
- lib/rails_tia/minitest.rb
|
|
113
|
+
- lib/rails_tia/native_extension.rb
|
|
114
|
+
- lib/rails_tia/object_allocations.rb
|
|
115
|
+
- lib/rails_tia/predictor.rb
|
|
116
|
+
- lib/rails_tia/rails_support.rb
|
|
117
|
+
- lib/rails_tia/run_report.rb
|
|
118
|
+
- lib/rails_tia/static_mapping.rb
|
|
119
|
+
- lib/rails_tia/templates/minitest.yml
|
|
120
|
+
- lib/rails_tia/templates/rspec.yml
|
|
121
|
+
- lib/rails_tia/version.rb
|
|
122
|
+
- skills/rails-tia/SKILL.md
|
|
123
|
+
homepage: https://github.com/willnet/rails_tia
|
|
124
|
+
licenses:
|
|
125
|
+
- MIT
|
|
126
|
+
metadata:
|
|
127
|
+
rubygems_mfa_required: 'true'
|
|
128
|
+
rdoc_options: []
|
|
129
|
+
require_paths:
|
|
130
|
+
- lib
|
|
131
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
132
|
+
requirements:
|
|
133
|
+
- - ">="
|
|
134
|
+
- !ruby/object:Gem::Version
|
|
135
|
+
version: 3.3.0
|
|
136
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
|
+
requirements:
|
|
138
|
+
- - ">="
|
|
139
|
+
- !ruby/object:Gem::Version
|
|
140
|
+
version: '0'
|
|
141
|
+
requirements: []
|
|
142
|
+
rubygems_version: 4.0.20
|
|
143
|
+
specification_version: 4
|
|
144
|
+
summary: Test Impact Analysis for Rails applications
|
|
145
|
+
test_files: []
|