{"id":22433042,"url":"https://github.com/roerohan/vitest-github-action","last_synced_at":"2025-08-01T12:33:52.989Z","repository":{"id":65861659,"uuid":"601495809","full_name":"roerohan/vitest-github-action","owner":"roerohan","description":"GitHub actions error and coverage reporter for vitest.","archived":false,"fork":false,"pushed_at":"2024-02-17T09:02:06.000Z","size":39863,"stargazers_count":9,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-25T13:02:59.965Z","etag":null,"topics":["actions","coverage","coverage-report","error-reporting","hacktoberfest","istanbul","typescript","vitest"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/roerohan.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-14T07:28:07.000Z","updated_at":"2024-07-31T17:41:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"1de8276b-b0ad-4f75-b7c6-493b8c0ff5cc","html_url":"https://github.com/roerohan/vitest-github-action","commit_stats":{"total_commits":165,"total_committers":2,"mean_commits":82.5,"dds":0.2666666666666667,"last_synced_commit":"2ccaa65f44ff2c4e4ebd40a4fe22d9367bd85eb0"},"previous_names":[],"tags_count":60,"template":false,"template_full_name":"roerohan/Template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roerohan%2Fvitest-github-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roerohan%2Fvitest-github-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roerohan%2Fvitest-github-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roerohan%2Fvitest-github-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/roerohan","download_url":"https://codeload.github.com/roerohan/vitest-github-action/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228377561,"owners_count":17910449,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actions","coverage","coverage-report","error-reporting","hacktoberfest","istanbul","typescript","vitest"],"created_at":"2024-12-05T22:13:45.497Z","updated_at":"2024-12-05T22:13:46.143Z","avatar_url":"https://github.com/roerohan.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Issues][issues-shield]][issues-url]\n\n\u003c!-- PROJECT LOGO --\u003e\n\u003cbr /\u003e\n\u003cp align=\"center\"\u003e\n  \u003c!-- \u003ca href=\"https://github.com/roerohan/vitest-github-action\"\u003e\n    \u003cimg src=\"https://project-logo.png\" alt=\"Logo\" width=\"80\"\u003e\n  \u003c/a\u003e --\u003e\n\n  \u003ch3 align=\"center\"\u003evitest-github-action\u003c/h3\u003e\n\n  \u003cp align=\"center\"\u003e\n    GitHub actions error and coverage reporter for vitest.\n    \u003cbr /\u003e\n    \u003ca href=\"https://github.com/roerohan/vitest-github-action\"\u003e\u003cstrong\u003eExplore the docs »\u003c/strong\u003e\u003c/a\u003e\n    \u003cbr /\u003e\n    \u003cbr /\u003e\n    \u003ca href=\"https://github.com/roerohan/vitest-github-action\"\u003eView Demo\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/roerohan/vitest-github-action/issues\"\u003eReport Bug\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/roerohan/vitest-github-action/issues\"\u003eRequest Feature\u003c/a\u003e\n  \u003c/p\u003e\n\u003c/p\u003e\n\n\u003c!-- TABLE OF CONTENTS --\u003e\n\n## Table of Contents\n\n- [About the Project](#about-the-project)\n  - [Built With](#built-with)\n- [Getting Started](#getting-started)\n  - [Prerequisites](#prerequisites)\n  - [Installation](#installation)\n- [Usage](#usage)\n- [Roadmap](#roadmap)\n- [Contributing](#contributing)\n- [License](#license)\n- [Contributors](#contributors-)\n\n\u003c!-- ABOUT THE PROJECT --\u003e\n\n## About The Project\n\nGitHub actions error and coverage reporter for vitest.\n\n### Built With\n\n- [vitest](https://vitest.dev/)\n- [@actions/core](https://www.npmjs.com/package/@actions/core)\n- [@actions/github](https://www.npmjs.com/package/@actions/github)\n- [istanbuljs](https://istanbul.js.org/)\n\n\u003c!-- GETTING STARTED --\u003e\n\n## Getting Started\n\nTo get a local copy up and running follow these simple steps.\n\n### Prerequisites\n\n- npm\n\n```sh\nnpm install npm@latest -g\n```\n\n### Installation\n\n1. Clone the Repo\n\n```sh\ngit clone https://github.com/roerohan/vitest-github-action.git\n```\n\n2. Install NPM packages\n\n```sh\nnpm install\n```\n\n\u003c!-- USAGE EXAMPLES --\u003e\n\n## Usage\n\nYou can use `vitest-github-action` to report `vitest` errors (in the \"Files\" section of a Pull Request), and report the coverage of tests (as comments on a\nPull Request).\n\nThis repository provides 2 ways of performing the above actions:\n\n\n- A GitHub action that you can use directly from the marketplace to enable error and coverage reporting.\n- A `npm` module that exports the relevant classes so that you can use them in your `vitest` configuration.\n  \n\n### Github Action\n\nYou can directly use the GitHub action and pass configuration options to report errors and coverage on GitHub.\nThe following sample action demonstrates how that can be done.\n\n```yaml\nname: \"Run vitest tests\"\non:\n  pull_request:\n    branches:\n      - main\n\njobs:\n  test:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v3\n\n      - uses: actions/setup-node@v3\n        with:\n          node-version: 18\n\n      - name: Run `npm install`\n        run: |\n          npm install\n          npm run build\n\n      - name: Run vitest and report issues\n        uses: roerohan/vitest-github-action@v1\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n        with:\n          config: ./vitest.config.ts\n          coverage: true\n```\n\n### NPM Package\n\nThe package exports 2 classes:\n\n1. `GithubReporter` to report errors in the files section of a PR, and\n2. `GithubIstanbulCoverageProviderModule` to comment coverage reports on the PR.\n\nYou can use the `GithubReporter` exported by this package in your `vite.config.ts` or `vitest.config.ts` (or their JS equivalent) files to have your errors reported on your GitHub pull request.\n\n```ts\nimport { defineConfig } from \"vitest/config\";\nimport { GithubReporter } from \"vitest-github-action\";\n\nexport default defineConfig({\n  test: {\n    reporters: process.env.GITHUB_ACTIONS\n      ? [\"default\", new GithubReporter()]\n      : \"default\",\n  },\n});\n```\n\nThe `GithubIstanbulCoverageProviderModule` is a wrapper over the [istanbul](https://istanbul.js.org/) coverage provider that reports the coverage as\na PR comment alongside the default reporting methods such as `text`, `json`, `json-summary`, etc.\n\nTo use the `GithubIstanbulCoverageProviderModule`, first, you need to create a file called `vitest-github-coverage-provider.ts` which has the following lines:\n\n```ts\nimport { GithubIstanbulCoverageProviderModule } from \"vitest-github-action\";\n\nexport default GithubIstanbulCoverageProviderModule;\n```\n\nThe `customProviderModule` configuration of `vitest` requires the coverage provider module to be a default export. This is why we are re-exporting it\nfrom a file as a default export. Additionally, it's easier to write the path to this file rather than the entire path from `node_modules`.\n\nThen, you need to update your `vitest` configuration to the following.\n\n```ts\nimport { defineConfig } from \"vitest/config\";\nimport { GithubReporter } from \"vitest-github-action\";\n\nexport default defineConfig({\n  test: {\n    coverage: {\n      provider: \"custom\",\n      customProviderModule: \"vitest-github-coverage-provider\",\n      // @ts-expect-error github-summary is a custom reporter and is not recognized.\n      reporter: [\"github-summary\"],\n    },\n  },\n});\n```\n\nUpon adding this configuration, the coverage report will be generated and commented on the PR. To run this, just run `npm run coverage` in your action.\n\n\u003e NOTE: Make sure that the `GITHUB_TOKEN` is set to `${{ secrets.GITHUB_TOKEN }}` in the action where you run `npm run coverage`.\n\n\u003c!-- ROADMAP --\u003e\n\n## Roadmap\n\nSee the [open issues](https://github.com/roerohan/vitest-github-action/issues) for a list of proposed features (and known issues).\n\n\u003c!-- CONTRIBUTING --\u003e\n\n## Contributing\n\nContributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**.\n\n1. Fork the Project\n2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your Changes (`git commit -m 'feat: Add some AmazingFeature'`)\n4. Push to the Branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\nYou are requested to follow the contribution guidelines specified in [CONTRIBUTING.md](./CONTRIBUTING.md) while contributing to the project :smile:.\n\n\u003c!-- LICENSE --\u003e\n\n## License\n\nDistributed under the MIT License. See [`LICENSE`](./LICENSE) for more information.\n\n\u003c!-- MARKDOWN LINKS \u0026 IMAGES --\u003e\n\u003c!-- https://www.markdownguide.org/basic-syntax/#reference-style-links --\u003e\n\n[roerohan-url]: https://roerohan.github.io\n[issues-shield]: https://img.shields.io/github/issues/roerohan/vitest-github-action.svg?style=flat-square\n[issues-url]: https://github.com/roerohan/vitest-github-action/issues\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froerohan%2Fvitest-github-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froerohan%2Fvitest-github-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froerohan%2Fvitest-github-action/lists"}