diff --git a/README.md b/README.md index 34df3df5..32e1d71b 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ For more information on these inputs, see the [Workflow syntax for GitHub Action - `artifact-name`: The GitHub artifact name of the generated HTML report. For example, `code-coverage-report`. _Note:_ When downloading, it will be extracted in an `html` directory - `minimum-coverage`: The minimum coverage to pass the check. Optional. Default: `0` (always passes) - `github-token`: Set the `${{ secrets.GITHUB_TOKEN }}` token to have the action comment the coverage summary in the pull request. This token is provided by Actions, you do not need to create your own token. Optional. Default: `` +- `project-dir`: [Optional] The custom directory. Use only if your project folder is not in the root folder (e.g. in case your repo contains multiple projects) ### Outputs None. @@ -42,6 +43,8 @@ jobs: - name: Report code coverage uses: zgosalvez/github-actions-report-lcov@v1 with: + # Optional: use only if your project not located on root. + # project-dir: apps/my-first-app coverage-files: coverage/lcov.*.info minimum-coverage: 90 artifact-name: code-coverage-report diff --git a/action.yml b/action.yml index 38c840a7..a8e3a5c6 100644 --- a/action.yml +++ b/action.yml @@ -4,6 +4,9 @@ name: 'Report LCOV' description: 'Report the code coverage from LCOV files' author: 'Zennon Gosalvez' inputs: + project-dir: + description: 'The custom directory. Use only if your project folder is not in the root folder (e.g. in case your repo contains multiple projects)' + required: false coverage-files: description: 'The coverage files to scan. For example, `coverage/lcov.*.info`' required: true diff --git a/src/main.js b/src/main.js index 09963239..7115f3fd 100644 --- a/src/main.js +++ b/src/main.js @@ -16,7 +16,9 @@ async function run() { const globber = await glob.create(coverageFilesPattern); const coverageFiles = await globber.glob(); - await genhtml(coverageFiles, tmpPath); + const projectDir = core.getInput('project-dir') || ''; + + await genhtml(coverageFiles, path.resolve(tmpPath, projectDir)); const coverageFile = await mergeCoverages(coverageFiles, tmpPath); const totalCoverage = lcovTotal(coverageFile);