Skip to content

fix(action): add optional support for removed files in changed coverage#286

Open
jeduardoc wants to merge 2 commits intoMadrapps:mainfrom
jeduardoc:fix/ignore-removed-files-in-changed-coverage
Open

fix(action): add optional support for removed files in changed coverage#286
jeduardoc wants to merge 2 commits intoMadrapps:mainfrom
jeduardoc:fix/ignore-removed-files-in-changed-coverage

Conversation

@jeduardoc
Copy link
Copy Markdown

Summary

This PR adds an opt-in way to ignore removed files from changed coverage calculations without changing the current default behavior.

The goal is to address a real integration issue caused by removed files returned by the GitHub compare API while preserving backward compatibility for repositories already relying on the current output semantics.

Background

While investigating a failing downstream workflow that consumes madrapps/jacoco-report@v1.7.2, we found a scenario where the compare API included files with status: removed in the changed file list.

Those files do not exist in the JaCoCo XML report, but they still flow through the changed-files processing path. This can distort the changed coverage result used by downstream workflows.

At the same time, changing the existing default behavior globally would be risky because repositories may already depend on the current output contract.

Root Cause

The action builds its changed-file list directly from the GitHub compare API response and, today, does not provide a way to exclude removed files.

When removed files appear in the diff:

  • they may participate in the changed-file matching flow even though they cannot exist in the report XML
  • downstream consumers cannot opt into safer behavior without patching their own workflows

What changed

Functional change

A new optional input was added:

  • ignore-removed-files (default: false)

When enabled, the action excludes compare API entries where status === 'removed' before building the internal changed-file list.

Compatibility

This implementation intentionally keeps the current default behavior unchanged:

  • existing users do not need to change anything
  • current tests and existing output expectations remain valid by default
  • repositories affected by removed files can opt in explicitly

Tests

  • preserved the previous assertions for the default behavior
  • added regression coverage proving that removed files are still included when the option is disabled
  • added regression coverage proving that removed files are excluded when the option is enabled

Documentation

  • documented the new ignore-removed-files input in README.md
  • documented the new input in action.yml
  • kept the existing coverage-changed-files output description unchanged

Why this approach

This is the narrowest fix with the lowest compatibility risk:

  • it solves the removed-files scenario for affected repositories
  • it avoids silently changing the output contract for everyone else
  • it gives maintainers a clear migration path through an explicit opt-in input

Validation

Executed locally:

  • npm test -- --runInBand __tests__/action_single.test.ts __tests__/action_multiple.test.ts __tests__/action_aggregate.test.ts __tests__/action_empty_aggregate.test.ts __tests__/action_empty_multiple.test.ts __tests__/action_empty_report.test.ts
  • npm run build

Commits

  • c977eee fix(action): add optional support for removed files in changed coverage
  • 87f1215 docs(readme): document the ignore-removed-files input

References

Related issues in this repository:

Additional context:

This PR focuses specifically on making removed-file handling available as an explicit compatibility-safe option.

Introduce an opt-in input to ignore files marked as removed by the GitHub compare API when building changed-file coverage data.

Keep the default behavior unchanged, add regression tests for both modes, and refresh the generated action artifacts.
Describe the new optional input in the README and keep the existing coverage output description unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant