Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
- Reuse source-entry file status instead of repeating separate directory and file probes.
- Validate version/changelog/lock consistency in CI and require prepared release metadata before
RubyGems publication.
- Enforce the unchanged coverage thresholds on runtime library source only, with a real-report
regression check that excludes loaded specs, benchmarks, and scripts from the denominator.

- Apply bounded project-root `.archignore` exclusions consistently to dependency graphs and metrics,
with cache invalidation, cross-platform glob handling, and configuration safety checks.
Expand Down
7 changes: 6 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ bundle exec rake docs
gem build archunit.gemspec --strict
~~~

The coverage suite enforces at least 98% line and 90% branch coverage. The documentation task builds
The coverage suite enforces at least 98% line and 90% branch coverage on every `lib/**/*.rb` runtime
file, including unloaded files. Specs, benchmarks, and development scripts do not contribute to
the enforced denominator. A subprocess regression test verifies the actual filtered report and
thresholds without merging its partial probe execution into the full suite. Native symlink tests
may be skipped on Windows accounts without link privileges; Linux CI exercises those scenarios.
The documentation task builds
the complete site, checks the public API guide, rejects unrendered Markdown, and validates internal
links.

Expand Down
37 changes: 37 additions & 0 deletions spec/ci/coverage_scope_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# frozen_string_literal: true

require 'json'
require 'open3'
require 'rbconfig'

RSpec.describe 'the enforced coverage scope' do
it 'includes every runtime file, excludes loaded tooling, and preserves coverage thresholds' do
root = File.expand_path('../..', __dir__)
# Inspect the real settings in a separate process without merging its partial execution into
# the parent suite's coverage result. Only the full parent run enforces the percentage gate.
probe = <<~RUBY
require 'json'
require 'rspec/core'
require_relative 'spec/spec_helper'
SimpleCov.use_merging false
SimpleCov.at_exit {}
require_relative 'benchmark/extraction'
settings = SimpleCov.minimum_coverage
files = SimpleCov.result.files.map(&:filename)
puts JSON.generate(files: files, minimums: settings, loaded: $LOADED_FEATURES)
RUBY
stdout, stderr, status = Open3.capture3(
{ 'COVERAGE' => 'true' }, RbConfig.ruby, '-Ilib', '-e', probe, chdir: root
)
expect(status.success?).to be(true), stderr
result = JSON.parse(stdout)
expected = Dir.glob(File.join(root, 'lib/**/*.rb')).map { |path| File.expand_path(path) }
normalize = ->(paths) { paths.map { |path| path.tr('\\', '/') }.sort }
expect(normalize.call(result.fetch('files'))).to eq(normalize.call(expected))
loaded_tools = %w[spec/spec_helper.rb benchmark/extraction.rb].map do |path|
File.join(root, path).tr('\\', '/')
end
expect(normalize.call(result.fetch('loaded'))).to include(*loaded_tools)
expect(result.fetch('minimums')).to eq('line' => 98, 'branch' => 90)
end
end
3 changes: 3 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
if ENV['COVERAGE'] == 'true'
require 'simplecov'

library_prefix = "#{File.expand_path('../lib', __dir__).tr('\\', '/')}/"
SimpleCov.start do
root File.expand_path('..', __dir__)
enable_coverage :branch
track_files 'lib/**/*.rb'
add_filter { |source| !source.filename.tr('\\', '/').start_with?(library_prefix) }
minimum_coverage line: 98, branch: 90
end
end
Expand Down
Loading