|
| 1 | +<!-- header:start --> |
| 2 | + |
| 3 | +#  GitHub Action: Rewrite Report Paths |
| 4 | + |
| 5 | +<div align="center"> |
| 6 | + <img src="https://opengraph.githubassets.com/50237226ce5d3230f19bbf31d04efd98f21cb2150e9ae4acd09a498440ecde82/hoverkraft-tech/ci-github-nodejs" width="60px" align="center" alt="Rewrite Report Paths" /> |
| 7 | +</div> |
| 8 | + |
| 9 | +--- |
| 10 | + |
| 11 | +<!-- header:end --> |
| 12 | +<!-- badges:start --> |
| 13 | + |
| 14 | +[](https://github.com/marketplace/actions/rewrite-report-paths) |
| 15 | +[](https://github.com/hoverkraft-tech/ci-github-nodejs/releases) |
| 16 | +[](http://choosealicense.com/licenses/mit/) |
| 17 | +[](https://img.shields.io/github/stars/hoverkraft-tech/ci-github-nodejs?style=social) |
| 18 | +[](https://github.com/hoverkraft-tech/ci-github-nodejs/blob/main/CONTRIBUTING.md) |
| 19 | + |
| 20 | +<!-- badges:end --> |
| 21 | +<!-- overview:start --> |
| 22 | + |
| 23 | +## Overview |
| 24 | + |
| 25 | +Rewrites file paths in report files to match repository paths when running in containers. |
| 26 | + |
| 27 | +When running tests or linting in Docker containers, the file paths in generated reports (coverage, lint results, etc.) often reference the container's internal paths (e.g., `/app/src/file.js`). This action rewrites those paths to match the actual repository structure, ensuring that GitHub annotations and coverage reports correctly reference the source files. |
| 28 | + |
| 29 | +<!-- overview:end --> |
| 30 | +<!-- usage:start --> |
| 31 | + |
| 32 | +## Usage |
| 33 | + |
| 34 | +```yaml |
| 35 | +- uses: hoverkraft-tech/ci-github-nodejs/actions/rewrite-report-paths@main |
| 36 | + with: |
| 37 | + # Path or glob pattern for report files to process. |
| 38 | + # Supports multiple files separated by newlines. |
| 39 | + # Common patterns: coverage/**, reports/**, **/*.xml, **/*.json |
| 40 | + # |
| 41 | + # Required: true |
| 42 | + report-files: | |
| 43 | + coverage/cobertura-coverage.xml |
| 44 | + reports/eslint.json |
| 45 | +
|
| 46 | + # Source root path in the container that should be replaced. |
| 47 | + # If not specified, will attempt to auto-detect from file paths. |
| 48 | + # Common values: /app, /workspace, /usr/src/app |
| 49 | + # |
| 50 | + # Default: "" (auto-detect) |
| 51 | + source-root: "/app" |
| 52 | + |
| 53 | + # Target root path in the repository. |
| 54 | + # Typically this is the GITHUB_WORKSPACE or a subdirectory. |
| 55 | + # |
| 56 | + # Default: GITHUB_WORKSPACE |
| 57 | + target-root: "" |
| 58 | + |
| 59 | + # Working directory where report files are located. |
| 60 | + # Can be absolute or relative to the repository root. |
| 61 | + # |
| 62 | + # Default: `.` |
| 63 | + working-directory: . |
| 64 | +``` |
| 65 | +
|
| 66 | +<!-- usage:end --> |
| 67 | +<!-- inputs:start --> |
| 68 | +
|
| 69 | +## Inputs |
| 70 | +
|
| 71 | +| **Input** | **Description** | **Required** | **Default** | |
| 72 | +| ----------------------- | ---------------------------------------------------------------- | ------------ | ----------- | |
| 73 | +| **`report-files`** | Path or glob pattern for report files to process. | **true** | - | |
| 74 | +| | Supports multiple files separated by newlines. | | | |
| 75 | +| | Common patterns: coverage/\*\*, reports/\*\*, \*\*/\*.xml, \*\*/\*.json | | | |
| 76 | +| **`source-root`** | Source root path in the container that should be replaced. | **false** | - | |
| 77 | +| | If not specified, will attempt to auto-detect from file paths. | | | |
| 78 | +| **`target-root`** | Target root path in the repository. | **false** | - | |
| 79 | +| | Typically this is the GITHUB_WORKSPACE or a subdirectory. | | | |
| 80 | +| **`working-directory`** | Working directory where report files are located. | **false** | `.` | |
| 81 | +| | Can be absolute or relative to the repository root. | | | |
| 82 | + |
| 83 | +<!-- inputs:end --> |
| 84 | +<!-- secrets:start --> |
| 85 | +<!-- secrets:end --> |
| 86 | +<!-- outputs:start --> |
| 87 | + |
| 88 | +## Outputs |
| 89 | + |
| 90 | +| **Output** | **Description** | |
| 91 | +| --------------------- | ------------------------------------------------- | |
| 92 | +| **`files-processed`** | Number of report files that were processed | |
| 93 | +| **`paths-replaced`** | Total number of paths that were rewritten | |
| 94 | + |
| 95 | +<!-- outputs:end --> |
| 96 | +<!-- examples:start --> |
| 97 | + |
| 98 | +## Examples |
| 99 | + |
| 100 | +### Basic Usage with Auto-Detection |
| 101 | + |
| 102 | +```yaml |
| 103 | +- name: Rewrite coverage paths |
| 104 | + uses: hoverkraft-tech/ci-github-nodejs/actions/rewrite-report-paths@main |
| 105 | + with: |
| 106 | + report-files: | |
| 107 | + coverage/cobertura-coverage.xml |
| 108 | + coverage/lcov.info |
| 109 | +``` |
| 110 | + |
| 111 | +### Explicit Source Root |
| 112 | + |
| 113 | +```yaml |
| 114 | +- name: Rewrite report paths |
| 115 | + uses: hoverkraft-tech/ci-github-nodejs/actions/rewrite-report-paths@main |
| 116 | + with: |
| 117 | + report-files: | |
| 118 | + coverage/**/*.xml |
| 119 | + reports/**/*.json |
| 120 | + source-root: "/app" |
| 121 | + target-root: ${{ github.workspace }} |
| 122 | +``` |
| 123 | + |
| 124 | +### Multiple Report Types |
| 125 | + |
| 126 | +```yaml |
| 127 | +- name: Rewrite all report paths |
| 128 | + uses: hoverkraft-tech/ci-github-nodejs/actions/rewrite-report-paths@main |
| 129 | + with: |
| 130 | + report-files: | |
| 131 | + coverage/cobertura-coverage.xml |
| 132 | + reports/eslint.json |
| 133 | + test-results/junit.xml |
| 134 | + source-root: "/workspace" |
| 135 | +``` |
| 136 | + |
| 137 | +<!-- examples:end --> |
| 138 | + |
| 139 | +<!-- |
| 140 | +// jscpd:ignore-start |
| 141 | +--> |
| 142 | + |
| 143 | +<!-- contributing:start --> |
| 144 | + |
| 145 | +## Contributing |
| 146 | + |
| 147 | +Contributions are welcome! Please see the [contributing guidelines](https://github.com/hoverkraft-tech/ci-github-nodejs/blob/main/CONTRIBUTING.md) for more details. |
| 148 | + |
| 149 | +<!-- contributing:end --> |
| 150 | +<!-- security:start --> |
| 151 | +<!-- security:end --> |
| 152 | +<!-- license:start --> |
| 153 | + |
| 154 | +## License |
| 155 | + |
| 156 | +This project is licensed under the MIT License. |
| 157 | + |
| 158 | +SPDX-License-Identifier: MIT |
| 159 | + |
| 160 | +Copyright © 2025 hoverkraft |
| 161 | + |
| 162 | +For more details, see the [license](http://choosealicense.com/licenses/mit/). |
| 163 | + |
| 164 | +<!-- license:end --> |
| 165 | +<!-- generated:start --> |
| 166 | + |
| 167 | +--- |
| 168 | + |
| 169 | +This documentation was automatically generated by [CI Dokumentor](https://github.com/hoverkraft-tech/ci-dokumentor). |
| 170 | + |
| 171 | +<!-- generated:end --> |
| 172 | + |
| 173 | +<!-- |
| 174 | +// jscpd:ignore-end |
| 175 | +--> |
0 commit comments